Test Retrieval Before Your Local LLM Writes
I make my local LLM show its source plan before it writes. The preview gate catches weak retrieval while the fix is still cheap and easy to inspect.
TL;DR
- Stop the workflow after retrieval and inspect the source plan before the model writes. The preview shows selected file paths, match reasons, scores, and section assignments. It does not ask the local model to write yet.
- In the July 20, 2026 lab run, preview mode built the brief plan and stopped before generation. It grouped sources into decisions, coding, learning, and growth, and recorded the ranked files and match terms.
- Freeze the query, source snapshot, retrieval settings, and result limit. Save the preview as a run artifact. A blocked path should stop the run before generation, not appear as a warning after private text entered the prompt.
I used to judge a local LLM workflow by reading the final answer. That was too late. A polished answer can hide a weak source set, and a bad answer does not tell me whether retrieval or generation failed.
The short answer: I now stop the workflow after retrieval and inspect the source plan before the model writes. The preview shows what context the model would receive, why each source was selected, and whether a private or stale file slipped in. Canonical URL: https://bmdpat.com/blog/local-llm-retrieval-preview-gate-2026

Why test retrieval before generation?
Retrieval and generation are separate failure points. If I run both at once, the final answer mixes them together. I can see that the output is wrong, but I still have to work backward to find the cause.
A retrieval preview makes the boundary visible. It returns the selected file paths, match reasons, scores, and section assignments. It does not ask the local model to write yet.
That one pause changes the debugging job. I can inspect a small source plan instead of reading a full draft and guessing which sentence came from which file. The check is faster because the evidence is compact.
What did the preview expose in my local model lab?
I run a local vault assistant on owned hardware. Its job is to collect private notes for a daily brief, then hand the selected context to a local model. The source files and logs stay on the same machine.
In my July 20, 2026 lab run, preview mode built the brief plan and stopped before generation. It grouped sources into decisions, coding, learning, and growth. It also recorded the ranked files and the terms that caused each match.
That receipt let me inspect the retrieval path without treating fluent prose as proof. I could see when an exact keyword match beat a more useful semantic match. I could also see when an old reflection scored well because it shared many terms with the query.
The important result was not a better paragraph. It was a clear place to tune the system. I could change recency weight, path weight, or section rules, then rerun the preview against the same input.
What should a retrieval preview contain?
I keep the preview narrow. It needs enough data to explain the choice, but not so much that it becomes another report nobody reads.
For each selected source, I want:
- The exact file path or document ID.
- The section that will receive the source.
- The score and the parts that produced it.
- The matched terms or semantic reason.
- The source date and any private-data flag.
I also want the rejected sources near the cutoff. A ranking looks sensible until the best excluded file is clearly better than the weakest included file. That boundary is where tuning work pays off.
This is the same idea behind my local model promotion gate. A component does not earn trust because it runs. It earns trust when an outside check shows that it met the job contract.
How do I keep the preview deterministic?
I freeze the query, source snapshot, retrieval settings, and result limit. Then I save the preview as a run artifact. If I change one scoring rule, I can compare the new ranking with the old one.
I do not ask the local model to explain the ranking. The retriever should expose its own score parts. A model-written explanation can sound right while describing logic the retriever never used.
The preview also needs a fail-closed privacy rule. A blocked path should stop the run before generation, not appear as a warning after private text has entered the prompt. Local inference protects data only when retrieval and logs follow the same boundary.
My local AI research workbench uses the same split. Collection, ranking, generation, and review are separate stages. Each stage leaves an artifact I can inspect.
When should the local model finally write?
Generation starts only after the source plan passes its checks. I look for current sources, useful section coverage, no blocked paths, and no obvious ranking mistake near the cutoff.
Then the model gets a smaller, cleaner context. If the answer still fails, I know retrieval already cleared its gate. The next investigation can focus on the prompt, model, or output verifier.
This does not make every answer correct. It makes failures easier to locate. That is the point. A local AI system gets easier to improve when each stage can fail on its own terms.
Accompanying prompt
What the prompt does: This prompt reviews a retrieval preview and finds source-selection problems before a local LLM generates an answer.
Copy/paste this prompt:
Copy-ready prompt
Paste the exact block into your coding agent.
No article chrome, no footnotes, no formatting drift.
This prompt and every other one we publish live in the free prompt library.
Copy the block above.
I publish measured local AI tests, failure notes, and owned-hardware build details in The 5090 Reports. Join the email list to get the next report.
FAQ
Why test retrieval before generation?
Retrieval and generation are separate failure points. A polished answer can hide a weak source set. A preview returns paths, scores, and match reasons while the fix is still cheap.
What should a retrieval preview contain?
For each selected source: exact path or document ID, destination section, score parts, matched terms or semantic reason, source date, and any private-data flag. Keep rejected sources near the cutoff too.
When should the local model finally write?
Only after the source plan passes: current sources, useful section coverage, no blocked paths, and no obvious ranking mistake near the cutoff.
Get the Local AI Field Kit
Four copy-ready tools now, then one evidence-backed Local AI Lab Note on Friday when there is something worth sharing.
Try the free agent run check firstGet the requested artifact now, then at most one evidence-backed Local AI Lab Note on Friday when there is something worth sharing. One-click unsubscribe. No sponsored placements. Privacy.
Patrick Hughes
I build BMD and publish measured AI runs, failure reports, and reusable checks. Nashville, Tennessee.
More writing
- 5 min
Why I Did Not Promote My Smaller Local Model
My smaller local model existed and ran, but it did not beat the baseline. Here is the promotion gate I use before changing a working local AI route.
- 5 min
My local daily brief used 0 model calls
On September 4, 2026 my llama3.1:8b daily brief was ready with 0 model calls and 0 seconds. Preview-only file ranking is not a model run.
- 5 min
Long Context Cost Me VRAM, Not Tokens a Second
A 94x bigger prompt cost llama3.1:8b only 9.7% of its generation rate. VRAM rose 656 MiB, but num_ctx doubled in the same step. Budget memory first.
- 5 min
One model logged 14.5 and 6,178 prompt tokens a second
gemma4:26b read 53 prompt tokens at 14.5 tok/s and 4,470 at 6,178.9 on the same RTX 5090 run set. Prompt speed is not one number.
- 5 min
Ollama Load Time Can Hide a Fast Local LLM
My RTX 5090 run spent 43.48 seconds on model load and 0.17 seconds on output. Split wall time before you judge local LLM speed.