Use local RAG when each question needs a small part of a large or frequently changing collection. Start with the whole document in context when it fits comfortably and the question needs relationships across many sections; compare both approaches on ten questions with known evidence.
Choose by the shape of the question
Retrieval-augmented generation has two separate jobs: select useful passages, then answer from them. A long-context approach skips that selection step by providing more of the source directly. Require supported conclusions and citations with either approach. Your reference answer should name both the required fact and the source that establishes it.
| Workload | Starting approach | Failure to test |
|---|---|---|
| One short policy and a few questions | Whole policy in context | Ignoring an exception or revision date |
| Thousands of changing support articles | Retrieve a small evidence set | Missing the right article or retrieving an obsolete one |
| Comparison across many contract sections | Long context or retrieval with section expansion | Separating a definition from the clause that uses it |
| Exact product codes and part numbers | Test lexical lookup alongside embeddings | Returning a semantically similar but different identifier |
A practical first implementation is deliberately simple: preserve document headings and version metadata, retrieve five candidate chunks, then build a prompt within a fixed evidence budget. If a chunk refers to a neighboring exception, expand that evidence before generation. Tune that initial five-chunk setting against your evaluation questions.
The original Lost in the Middle research found position-dependent retrieval and answering performance in the models it studied. Test evidence positions on your chosen model and score answer accuracy separately from context capacity.
Budget evidence and embeddings separately
Suppose you allocate an 8,192-token generation context. Reserve 1,024 tokens for the answer and 1,024 for instructions, the question and conversation overhead. That leaves 8,192 − 1,024 − 1,024 = 6,144 tokens for evidence. Six 700-token passages use 4,200, leaving 1,944 for headings, source identifiers and additional context.
Use the generation model's tokenizer for that final prompt budget. The embedding model has its own input limit and tokenizer. A passage that fits the embedding model can still overflow the generation prompt when combined with other passages.
| Open embedding model | Dense vector dimensions | Model-card input limit |
|---|---|---|
BAAI/bge-m3 |
1,024 | 8,192 tokens |
Qwen/Qwen3-Embedding-0.6B |
Up to 1,024 | 32K tokens |
Use these current model-card specifications to pick candidates for local retrieval. Begin with coherent sections of a few hundred tokens and test the exact language and terminology your users bring. Follow the chosen model's query formatting and keep it fixed during the comparison.
Store document ID, version, heading and page or section alongside each vector. Return these identifiers with the text so the answer can cite something a reader can open. Apply the user's document permissions before selecting evidence so every retrieved passage is authorized.
Diagnose retrieval and answering independently
For each evaluation question, label the smallest sufficient source passage or set of passages. Check retrieval first: does the selected evidence contain every fact required for the answer? If it does not, a different generation model cannot reliably recover the missing document fact.
Then bypass retrieval and give the generator the correct evidence manually. If it still produces the wrong answer, investigate instructions, model capability or conflicting wording. This direct-evidence test prevents you from spending days adjusting chunk sizes to compensate for an answering failure.
Question: What is the replacement deadline for a damaged shipment?
Evidence [shipping-policy-v3, section 4]:
Replacement requests must arrive within 14 days of delivery.
For damage documented by the carrier, the deadline is 30 days.
Instruction: Answer only from the evidence. Cite the section.
If the evidence does not answer the question, say so.
The expected answer uses 30 days for documented carrier damage and identifies the condition. If retrieval returns only the first sentence, the failure is evidence selection. If both sentences arrive but the model answers 14 days unconditionally, the failure is downstream.
Version updates need their own test. Replace the fictional 30-day exception with 21 days in a new version, rebuild the affected index entries and ask again in a fresh chat. Confirm citations identify the new document. Old chat history can otherwise make a correct new index appear stale.
Try it on your workload
Build ten questions: four single-passage facts, two rule-and-exception questions, two cross-section comparisons and two questions your collection cannot answer. Record expected sources and answers before running the model. Keep the same generator and output budget across all runs.
Run three conditions: retrieved evidence, manually supplied correct evidence and the complete relevant document when it fits. Record evidence coverage, answer correctness, citation validity, input tokens and elapsed time. Count a confident unsupported answer as a failure, including on the two deliberately unanswerable questions.
Move the key passage to the beginning, middle and end of the long-context input while keeping the content constant. For retrieval, inspect the top five passages and any duplicate chunks that waste the evidence budget. Save the raw selected passages with each result so you can explain a score later.
Choose the smallest approach that solves your questions. A small stable handbook may need no vector index at all. A large collection with frequent updates benefits from explicit document versioning even when retrieval itself is straightforward.
How to decide
- Improve retrieval when the required passage is absent from the prompt.
- Expand context when the necessary evidence is spread across sections that cannot fit together.
- Change the generator or instructions when direct correct evidence still yields an incorrect answer.
Run ten retrieval agents for about thirteen cents
Ten question-answering agents working in parallel on 100 answers on deepseek/deepseek-v3.2 cost about thirteen cents in tokens on TrustedRouter using retrieved context. On 2026-11-22, the live catalog listed approximately $0.274 per million input and $0.401 per million output tokens. Each agent handles ten questions with 4,000 total input and 500 output tokens each: 10 × 10 × 4,000 = 400,000 input and 10 × 10 × 500 = 50,000 output. Cost = 0.4 × $0.274 + 0.05 × $0.401 = $0.12965, about thirteen cents. Sending 40,000 input tokens per question gives 4 × $0.274 + 0.05 × $0.401 = $1.11605, about $1.12.
On one local GPU, those agents share throughput, and requests beyond its parallel capacity wait in line; through a per-token API, independent questions can run at the same time for the same token bill as sequential execution. Keep the index local and send only approved passages, accounting separately for indexing costs.
Prices change; check current prices, confidential routing and agent setup. Choose fully local retrieval and generation when source passages must remain offline.
Sources
- BAAI BGE-M3 model card: dimensions and input length
- Qwen3 Embedding model card: dimensions and context
- Lost in the Middle: original long-context evaluation research
- TrustedRouter live model catalog