News

日本語 · English · 中文

RAG or Ingesting All Documents: A Comparison Using 68 Articles and Approximately 60,000 Tokens in an Enterprise LLM

Method for Getting AI to Answer Based on Long Documents: We compared RAG, which retrieves and passes only the necessary parts, with the “All-In” approach that passes the entire document. After introducing recent research, we conducted one trial each using a small-scale dataset of 68 public articles and approximately 60,000 tokens. Both methods achieved a perfect score on the question requiring fact extraction, while RAG failed completely on the question requiring article counting, and the All-In method’s performance depended on the model. We also organize the temporal characteristics—slower for the first question but faster from the second onward.

There are two main approaches to having AI answer based on lengthy documents. One method involves searching the document for sections likely related to the question, selecting those parts, and providing only them to the AI. The other method involves stuffing the entire document into a prompt (the input text to the AI), which we refer to as "putting it all in." In one word, the conclusion is that if you are merely extracting facts, there is no visible difference between the two methods. However, in tasks requiring counting, RAG underperformed, while "putting it all in" was subject to the model's characteristics. Note that our experiments used a small amount of documents and questions, with each condition tested only once. Please interpret the following figures within this scope.

RAG and "Putting It All In"

RAG stands for Retrieval-Augmented Generation, a mechanism that generates answers based on information supplemented by search results. Documents are divided into fine-grained units to create an index. When a question arrives, several highly relevant units are retrieved and sent to the AI along with the question. While this suppresses the amount of data sent to the AI, if the correct answer lies in a unit that was not retrieved, the AI simply cannot see the answer.

There are also different types of search methods. BM25 is a classic method that measures relevance based on the overlap of common terms between the question and the document. While vector search, which is commonly used in recent years, looks at the semantic proximity of words, BM25 straightforwardly looks at character and word matches. A "token" is the minimum unit of text processing for an AI and does not correspond directly to the number of characters or words. The more input tokens there are, the heavier the computation becomes.

"Putting it all in" eliminates the principle of missing information during retrieval, but each input becomes larger. What helps here is caching. This refers to a mechanism that saves calculation results for parts of the document and reuses them for subsequent questions. By fixing the document at the beginning and placing the question at the end, the calculations for the document part can be reused from the second question onward. This initial calculation is called prefill, and it becomes heavier as the document grows larger. Details on caching and prefill are covered in episodes Local LLMs Current Status Episode 3 and Episode 4 of the series.

What Recent Research Has Revealed

First, there are reports indicating that even models advertised as capable of handling long contexts see performance drop when there is little overlap in wording between the question and the answer. NoLiMa (arXiv 2502.05167) reported that out of 13 models claiming support for 128K or more, 11 models dropped to less than half their performance at the 32K mark. GPT-4o dropped from 99.3% to 69.7%. It is important for engineers to realize that just because something fits in, it does not mean the long document is being read uniformly.

Research has also been conducted on the comparison of methods themselves. Long Context vs. RAG (arXiv 2501.01880) reports that "putting it all in" is generally better than RAG, with the difference being particularly pronounced for questions based on Wikipedia. On the other hand, it states that methods using summaries for search are equivalent to "putting it all in," while methods that search by splitting into paragraphs are inferior. RAG was advantageous in cases of conversation or general questions. This suggests that the outcome changes depending on how the search is constructed.

There are also examples measured with real-world documents. The Token Tax of Epistemic Accuracy (arXiv 2606.20898) used manufacturing site safety education documents, where "putting it all in" achieved 73.1% and semantic search-based RAG achieved 65.4%. However, "putting it all in" increases the input tokens per question by 26 times. It is necessary to compare the difference in accuracy with the difference in cost.

Another weakness of long contexts has been pointed out. Diagnosing and Mitigating Context Rot (arXiv 2606.29718) showed that during long explorations, the model might give up or provide uncertain wrong answers even far before reaching the context limit. This means that the capacity it can handle and the amount it can stably read through are separate matters.

In practical documents, Anthropic's "Contextual Retrieval" states that "if knowledge is less than 200,000 tokens (about 500 pages), you should just put it all into the prompt, and RAG is unnecessary." Furthermore, it presents improvement measures for cases where search is used. By adding context to paragraphs for search, missed retrievals among the top 20 dropped from 5.7% to 3.7% (a 35% reduction). When combined with BM25, it dropped to 2.9% (a 49% reduction), and when reordering was added, it dropped to 1.9% (a 67% reduction). Caching prompts reduced wait times by more than half and decreased costs by up to 90%.

An example of changing how search is constructed comes from Amazon's "Keyword search is all you need" (arXiv 2602.23368), which reported that by not maintaining vector indexes and instead having an agent use keyword search as a tool, it reached over 90% of RAG's performance. This is an example showing the possibility of skipping the preparation of indexes.

How Enterprises Use It

In enterprise question-answering systems, architectures that repeatedly shuttle between search and generation are becoming widespread. Uber's "Enhanced Agentic-RAG" reported that in internal question-answering, usable answers increased by 27% relative to baseline, and incorrect advice decreased by 60% relative to baseline. This was based on an evaluation of over 100 questions. It can be read as an example where the design of fetching additional missing information, rather than a single-shot search, led to results.

Looking at the research thus far, we can see both scenarios where "putting it all in" is strong and scenarios where search or custom construction is effective. Since the conditions differ across studies, one cannot simply say which is superior. We decided to verify this with our own documents.

Our Attempt (Documents, Questions, Methods)

The experiment was conducted on 2026-11-10, with each condition tested only once. The documents consisted of 68 publicly available articles from blueqat news, including translations of recent overseas news (last 60 days) and our own company articles. The volume was approximately 57,000 tokens (by Qwen's count), which is about 65,000 tokens by DeepSeek's count. We used only publicly available articles without any special preprocessing.

There were two types of questions. One was a question asking to extract one fact from a single article, totaling 29 questions. The answers were words appearing exactly as written in the text. One of these was excluded because the question construction was flawed, making the answer ambiguous, resulting in all models answering "unknown." The other type was a question asking to count the number of articles containing a specific word across the entire document, totaling 5 questions. The correct answers, counted mechanically, were: IonQ 6, IBM 11, Quantinuum 4, IQM 5, and NVIDIA 5.

For RAG, we divided the articles into 359 paragraphs of approximately 400 characters each, adding the article title to each paragraph. Search was performed using BM25 based on 2-character n-grams, passing the 8 closest paragraphs. The input was approximately 1,500–2,300 tokens. We confirmed whether the correct article was among the 8 retrieved paragraphs, and it was for all 29 questions. Thus, the RAG in this experiment had no retrieval misses, allowing us to observe only the weaknesses of the generation side.

For "putting it all in," we placed the entire document at the beginning and the question at the end. From the second question onward, the calculation for the document part could be reused. We used three models: our internal Qwen3.6 (Fast, V100), our internal Qwen3.8-27B (4-bit, 1 V100), and DeepSeek V4.1 (API). Temperature was set to 0, and thinking (reasoning) was disabled. Evaluation was done based on content; numbers without units or minor notational variations were considered correct.

Results

The results for 28 fact-extraction questions and 5 counting questions. For the fact questions, all 3 models × 2 methods achieved 28/28. For the counting questions, RAG scored 0/5 across all 3 models, tending to answer with fewer responses such as "0 articles" or "unknown." "Putting it all in" yielded 2/5 for Qwen3.8 (errors were 6→5, 11→10, 5→3) and 2/5 for Qwen3.6 (errors were 11→10, 5→6, 5→4). DeepSeek scored 0/5 (tending to give higher answers, e.g., 6→9, 11→9, 4→7).

ModelRAG FactAll-In FactRAG CountingAll-In Counting
Qwen3.628/2828/280/52/5
Qwen3.8-27B28/2828/280/52/5
DeepSeek V4.128/2828/280/50/5
Both methods scored full marks on facts; RAG failed completely on counting
Both methods scored full marks on facts; RAG failed completely on counting

Under strict mechanical evaluation, where units had to match exactly, Qwen3.6's RAG scored 24/29, and "all-in" scored 26/29. This was due to point deductions for answers given without units.

We measured time per question. For RAG, DeepSeek took about 0.7 seconds, Qwen3.6 about 1.0 seconds, and Qwen3.8 about 2.3 seconds. For "all-in," the first question took 32.1 seconds for Qwen3.6, 104.6 seconds for Qwen3.8, and 1.97 seconds for DeepSeek (the DeepSeek value was measured during a dry run before the actual execution, with no reuse). From the second question onward, Qwen3.6 took about 2.2 seconds, Qwen3.8 about 2.4 seconds, and DeepSeek about 1.2 seconds. From the second question onward, over 90% of the input was reused: for Qwen3.8, 56,640 out of 57,149 tokens, and for DeepSeek, 65,024 out of 65,233 tokens were reused. The sheer volume of input for "all-in" was about 25–40 times that of RAG.

ModelRAGAll-In 1st QuestionAll-In From 2nd Question
Qwen3.6About 1.0 sec32.1 secAbout 2.2 sec
Qwen3.8-27BAbout 2.3 sec104.6 secAbout 2.4 sec
DeepSeek V4.1About 0.7 sec1.97 secAbout 1.2 sec
All-in is heavy only for the 1st question; faster from the 2nd onward
All-in is heavy only for the 1st question; faster from the 2nd onward

What We Learned

First, for fact-extraction questions, there was no difference between the two methods. This is attributed to the RAG search hitting the correct answers for all questions and the fact that the answers appeared verbatim in the text. The results could differ in setups where search misses occur or where questions require paraphrasing.

Second, for counting questions, RAG failed completely. A design that passes 8 paragraphs does not provide enough material to count across the entire document. This is, in a sense, a natural result given the mechanism. On the other hand, with "all-in," depending on the model, Qwen series had some hits, while DeepSeek tended to overcount. Merely putting everything in does not guarantee correct counting.

Third, regarding time characteristics. The first question for "all-in" is heavy, exceeding 100 seconds for Qwen3.8. However, from the second question onward, since the calculation for the document part is reused, it drops to a level comparable to RAG. If the usage pattern involves asking multiple questions of the same document, the slowness of "all-in" is limited to the first attempt. Conversely, if there is only a single one-off question, the heaviness of the first attempt remains.

Fourth, the method of fixing the document at the beginning and placing the question at the end proved effective. If the document part remains the same even if the question changes, the cache can be used directly. Placing the question at the beginning shifts the position of the document, breaking the reuse. This arrangement was a conscious premise of our experiment.

How to Choose

From our small experiment, we can only say the following. If the document is small and the questions are primarily fact-extraction, we did not see a significant difference between the two methods. If questions involving counting or summarizing the whole are mixed in, RAG's paragraph-passing is insufficient, and either "all-in" or a separate mechanism for aggregation is required. If you are asking multiple questions of the same document, there are scenarios where "all-in" is easier to handle despite paying the initial cost. If handling many one-off questions, RAG with smaller inputs is more suitable.

Combining this with insights from research, the judgment to try "all-in" first if the document is less than 200,000 tokens serves as one guideline. However, given reports of misses in long contexts and errors resembling giving up, it is not a matter of "if it fits, just hand it over"; verification is necessary. If using search, improvements such as adding context to paragraphs, combining BM25, and adding reordering have been reported. Since our experiment covered a small scope of 1 attempt per condition, approximately 60,000 tokens, and 68 articles, please read the figures as applicable to those specific conditions.

References

This article was translated from the Japanese original. 日本語で読む

← Latest articles