Uploading a 300-page financial audit, a 600-page legal discovery binder, or a multi-volume technical manual to an AI tool used to be an exercise in disappointment. You would wait minutes for an opaque embedding pipeline to chop your document into tiny fragments, ask a synthesis question, and watch the model hallucinate numbers because the relevant clause was sliced across three disparate vector chunks.
Kimi changed this expectation in early 2024 by scaling context length to 2 million tokens. But what actually happens when you drop a massive PDF into Kimi—whether on the web app or via the Moonshot AI platform API? How does it retrieve critical information without drowning in latency, and how does its context caching architecture actually work?
At 365Finds, we look at Kimi’s architecture not as another incremental RAG (Retrieval-Augmented Generation) patch, but as a deliberate departure from chunk-based search in favor of whole-document attention powered by a disaggregated KV-cache engine called Mooncake. Here is how Kimi parses, indexes, caches, and retrieves across massive document uploads, along with the operational rules you must follow to avoid blowing your budget or corrupting table data.
1. The Architectural Shift: Full-Attention Retrieval vs. Chunk-Based RAG
Most enterprise document tools rely on traditional RAG:
- Break the PDF into 500-to-1,000 token text chunks.
- Generate mathematical vector embeddings for each chunk.
- Perform cosine similarity searches against the user prompt.
- Pass the top 5 or 10 matching chunks to the LLM context window.
This setup fails when dealing with complex corporate PDFs. Traditional RAG cannot perform holistic cross-referencing, multi-hop reasoning, or global summaries. If you ask, "Did operational expenses in Q3 exceed the cumulative cost cap outlined in Section 4.2?", traditional RAG rarely pulls both the table and the governing clause simultaneously.
Kimi takes the opposite path: Native In-Context Full Attention.
[ Traditional RAG ]
Huge PDF ---> Slicing (Chunks) ---> Vector Database ---> Top-K Chunks (5-10) ---> LLM Context
Result: Broken tables, missed cross-chapter context, zero global synthesis.
[ Kimi's Native Long-Context Retrieval ]
Huge PDF ---> Document Parsing Layer ---> Full Sequential Prompt (up to 2M tokens) ---> Transformer Attention Field
Result: The entire document lives inside attention. Every token can attend to every other token.
When you upload an 80MB PDF to Kimi, it extracts the document’s sequential text structure and injects the entire file into the model's active attention field. Retrieval does not happen through an external vector search engine prior to inference; retrieval happens inside the transformer's self-attention layers during inference. Every token across your 300 pages can attend to every other token.
365Finds considers this difference night and day. For complex legal due diligence, forensic accounting, and code audits, Kimi's native context retrieval avoids the "lost in translation" failure modes inherent to chunked vector search.
2. Ingestion and Extraction: What Happens During Upload
Before any attention calculation can occur, Kimi must turn binary PDF structures into clean linguistic sequences. This happens through the ingestion pipeline:
The Text Layer Extraction
When you upload a digital PDF (a PDF generated from Word, LaTeX, or Google Docs), Kimi’s parser extracts the raw digital text stream while maintaining structural hierarchies (headings, subsections, paragraph boundaries, and list hierarchies). On the Moonshot open API, this is accessed via the /v1/files endpoint with purpose="file-extract".
The Table Parsing Reality Check
Here is where messy reality enters. PDF format specifications were created for printing fidelity, not semantic parsing. A table in a raw PDF is often just coordinates and floating text strings without underlying HTML <table> tags.
- If a table has clear borders and single-line cells, Kimi’s parser reconstructs it cleanly into Markdown table format.
- If a document contains borderless tables, multi-line nested cells, or complex multi-column balance sheets, standard text extraction can occasionally scramble column alignments.
- 365Finds Recommendation: Never assume Kimi will untangle a 50-column borderless scanned balance sheet automatically. When extracting tabular data, explicitly prompt: "Extract the tabular data from Section 5 strictly as a structured Markdown table, maintaining column headers exactly as printed."
Scanned PDFs and OCR
Digital PDFs parse within seconds. However, if your PDF consists of scanned document images, text layer extraction alone yields nothing. In the Kimi web interface, multimodal OCR routines parse visible page images, but processing speeds drop and token overhead increases. For API workflows handling high volumes of scanned records, we recommend running layout-aware pre-processors (such as Docling or Marker) before pushing context into Moonshot.
3. The Context Caching Engine: Mooncake Architecture
The fundamental dilemma of a 2-million-token context window is computational economics. In a standard Transformer, computing self-attention over 2 million tokens consumes massive GPU compute (Prefill phase). If a user asks five consecutive follow-up questions about a 500-page PDF, recalculating 2 million tokens of attention each turn would introduce 30-to-60 second latency spikes and bankrupt both the infrastructure provider and the user.
Moonshot AI solved this by engineering Mooncake, a specialized KV-cache-centric disaggregated serving architecture (detailed in their published research paper, arXiv:2407.00079).
[ Kimi Serving Infrastructure: Mooncake ]
[ Prefill Cluster ] [ Decode Cluster ]
Takes raw 2M-token PDF ---> Generates KV Cache Blocks ===========> Streams answer tokens
| (High-Speed RDMA) to user in real-time
v
[ Distributed Mooncake Store ]
- GPU High-Bandwidth Memory (Tier 1)
- Host CPU DRAM Pools (Tier 2)
- High-Speed NVMe SSD Pools (Tier 3)
Instead of treating GPU compute as the primary bottleneck, Mooncake organizes the entire infrastructure around the Key-Value Cache (KV Cache):
- Disaggregated Prefill and Decode: The compute-intensive prefill phase (reading the 500-page PDF once) is completely separated from the memory-bandwidth-bound decoding phase (generating answers token by token).
- Tiered KV Cache Storage: The resulting attention states (KV pairs) of your massive PDF are stored across a tiered storage fabric—combining GPU HBM, host CPU DRAM, and local NVMe SSDs via high-speed RDMA networks.
- Prefix Reuse: Once your document is loaded and prefilled, subsequent queries do not recompute the document's KV cache. The inference engine simply pulls the existing attention cache from the Mooncake Store and routes directly to the decode cluster.
4. How Context Caching Works in Practice (Web vs. API)
Understanding how this architecture surfaces to you depends on whether you are using the consumer web application or building on the Moonshot API.
On Kimi Web (kimi.moonshot.cn)
When you upload a document in a chat thread:
- The initial upload and first query trigger the parsing and KV cache generation.
- Follow-up questions about the document feel snappy and responsive because your session reuses the active KV cache prefix.
- If you start a brand-new chat session with the same document, Kimi’s global cache storage can detect identical document hashes, avoiding cold-start latency.
On Moonshot API (api.moonshot.cn)
For developers, context caching is an explicit economic lever:
- Cache Hit vs. Cache Miss Pricing: On flagship models like
kimi-k3andkimi-k3.1-pro, input tokens hitting an active cache cost roughly 90% less than cold cache-miss input tokens (e.g., dropping from $2.00–$3.00 down to $0.20–$0.30 per million tokens). - Configurable TTL (Time-To-Live): Moonshot supports explicit cache retention windows:
5m(5 minutes): Default. Best for interactive multi-turn conversations where responses arrive back-to-back.1h(1 hour): Incurs a higher initial write fee, but keeps the KV cache alive across an entire hour. Ideal for recurring scheduled agent tasks or batch document evaluations.
- Cache Renewal: Every successful cache hit within the window refreshes the TTL counter without charging another write fee.
5. The Golden Rules for Long-Document Workflows
Context caching and native retrieval provide immense power, but they punish careless prompting. 365Finds adheres to four operating rules when processing massive documents on Kimi:
| Workflow Stage | The Mistake | 365Finds Operating Rule |
|---|---|---|
| Prompt Ordering | Putting dynamic timestamps or query text before the document. | Anchor the prefix strictly: Place system prompt and static PDF context at the very top; place variable user questions at the very end. Any token difference at index 0 invalidates downstream cache. |
| Document Quality | Uploading raw, low-contrast scans directly. | Verify the digital text layer: If you cannot highlight and copy text in Adobe Acrobat or Preview, pre-process the document through OCR before feeding it to Kimi. |
| Table Extraction | Asking generic questions like "Summarize the balance sheet." | Force explicit structure: Ask Kimi to reconstruct data as raw Markdown tables or JSON arrays, explicitly specifying row headers. |
| API Cost Optimization | Using default 5m TTL for intermittent tasks spaced 15 minutes apart. | Match TTL to usage cycles: If your background worker queries a legal dossier every 20 minutes, configure ttl="1h" to avoid continuous cache-write penalties. |
6. 365Finds Final Take
Kimi’s document retrieval succeeds because it abandons the clumsy compromises of traditional chunk-based RAG. By pairing native 2-million-token in-context attention with the Mooncake KV-cache storage engine, Kimi delivers forensic-grade document comprehension without the latency penalties that typically cripple large-context models.
If your daily workflow revolves around 400-page prospectuses, regulatory filings, or large code repositories, Kimi is among the most practical and cost-effective engines available today—provided you respect strict prefix discipline and verify your document text layers before uploading.