Why LLMs Can't Read Your Entire Long Document: Compute, Memory, and Cost Constraints Explained
When you feed a long document to a large language model, you may hit a limit like "only the first 20 pages or 10,000 tokens are read." This isn't laziness—it's a rational trade-off under compute, memory, and cost constraints. This article explains why attention complexity makes long inputs expensive, what a one-shot 600,000-character input actually costs, and how to handle long documents with chunking, RAG, prompt caching, and preprocessing.
Why LLMs “Can’t Finish Reading” Your Long Documents
Many developers encounter this message when chatting with a large language model or calling its API: the document is too long, and the system will only read the first 20 pages or the first 10,000 tokens. At first glance, this looks like the platform cutting corners. From an engineering perspective, however, it’s a rational trade-off under three constraints: compute, memory, and cost. Understanding why these constraints exist is the first step toward designing a better long-text processing pipeline.
1. Limited Compute Is Just the Symptom—Attention Complexity Is the Root Cause
Mainstream LLMs are built on the self-attention mechanism, which requires every token in a sequence to compute its relevance to every other token. Both computation and GPU memory usage grow roughly quadratically with sequence length. In other words, expanding the context from 10,000 tokens to 100,000 tokens doesn’t increase theoretical compute 10x—it approaches 100x.
For inference providers, extremely long contexts mean:
- A sharp rise in GPU memory per request, drastically reducing how many requests a single accelerator can serve concurrently;
- Significantly longer time-to-first-token (TTFT), which degrades user experience;
- Harder cluster scheduling, since long requests can block the throughput of an entire batch.
Setting a per-conversation reading limit is therefore an engineering decision to preserve overall service availability under finite compute—not a capability flaw.
2. The Cost Perspective: What a One-Shot 600,000-Character Input Means
A very practical question: whether you pay per token or subscribe to a fixed quota, would a single 600,000-character input with zero cache hits hurt your wallet? The answer is almost certainly yes.
Here’s a rough estimate: 600,000 Chinese characters translate to roughly 600,000–900,000 tokens. At typical industry input token prices, a single call could cost anywhere from under a dollar to several dollars. If this is an iterative workload—say, analyzing a book chapter by chapter—and each turn re-sends the full conversation history, costs grow linearly or faster with each round.
What’s less obvious is the “zero cache” condition. In long-context scenarios, prompt caching is the key lever for cost control: when multiple requests share the same long prefix, the server can reuse previously computed intermediate results, charging only for the incremental portion or at a discount. Once the cache breaks—say, a timestamp gets inserted into the prefix, or the document is re-concatenated every turn—every call becomes a full-price computation, and your bill can spiral out of control fast.
3. Engineering Approaches to Long-Text Processing
Rather than hoping platforms will endlessly expand their context windows, optimize at the architecture level. Here are several widely adopted practices.
1. Chunking with rolling summarization
Split the long document into semantically complete chunks, call the model to generate intermediate summaries for each chunk, then merge the summaries and summarize again. This “divide and conquer” approach converts quadratic attention overhead into roughly linear call overhead:
chunks = split_by_semantics(document, max_tokens=4000)partial_summaries = [llm.summarize(c) for c in chunks]final_summary = llm.summarize(merge(partial_summaries))
Keep in mind that consecutive chunks should retain a small overlap to avoid losing key information at chunk boundaries.
2. Retrieval-augmented generation (RAG) instead of stuffing the full text
If the task is question answering over a long document, feeding in the entire text is both expensive and ineffective—the model’s attention gets diluted by massive amounts of irrelevant content, and answer quality actually drops. A better approach is to chunk the document, embed it, and store it in a retrieval system, then recall only the most relevant passages for each query. This controls token consumption and improves answer relevance at the same time.
3. Explicitly manage cache friendliness
When calling APIs that support prompt caching, keep the request prefix stable: place the long document at the very front of the message sequence, byte-for-byte identical across calls, and put anything dynamic (user questions, timestamps) at the end. This simple ordering habit can cut input costs by more than half in multi-turn long-document Q&A scenarios.
4. Preprocessing and dimensionality reduction
Many documents are full of redundancy: headers and footers, repeated disclaimers, formatting noise. Cleaning, deduplicating, and extracting structured content before sending to the model often shrinks the payload by 30% or more without information loss. For structured content like tables and code, convert them to compact text representations first.
4. Selection Tips and Pitfalls to Avoid
When planning a long-text application, focus on the following:
- Clarify the task type: whole-document comprehension tasks (e.g., proofreading an entire book) suit chunking plus summarization; localized lookup tasks (e.g., contract clause Q&A) should prioritize retrieval augmentation.
- Model your real costs: build a cost model based on “input tokens per call × number of calls × cache hit rate” to avoid runaway bills after launch.
- Distinguish advertised context windows from effective context: “lost in the middle” behavior on very long inputs has been widely observed even in models claiming huge windows, so place critical information near the beginning or end.
- Prefer cache-aware invocation: when deploying such applications in the cloud, you can combine object storage for document chunks, message queues for batch job scheduling, and monitoring and alerting to track token consumption curves, building a controllable cost governance system. Major cloud platforms such as Baidu AI Cloud offer these general-purpose capabilities and can serve as infrastructure options for building such pipelines.
Conclusion
“Only the first 20 pages will be read” isn’t a dismissive message—it’s a tangible manifestation of the economics of compute in the LLM era. For developers, the real solution isn’t hunting for an “infinite context” silver bullet, but understanding token cost structures and leveraging caching, chunking, and retrieval to find your own optimal balance between quality, latency, and budget.
