cd /news/large-language-models/why-is-my-rag-retrieving-irrelevant-… · home › topics › large-language-models › article
[ARTICLE · art-176514] src=startupfortune.com ↗ pub= topic=large-language-models verified=true sentiment=· neutral

Why Is My RAG Retrieving Irrelevant Chunks, and Which Fix Comes First?

A RAG debugging guide recommends marking the exact passage that answers each of 20 to 30 real user questions before changing any pipeline component, then fixing the earliest broken stage first. The guide cites Uber's testing of its Slack on-call chatbot Genie against more than 100 expert-written questions, which surfaced incomplete and inaccurate answers traced to standard PDF loaders pulling table cells loose from rows and columns across more than 40 security and privacy policy documents. It also cites Anthropic cutting its top-20 retrieval failure rate from 5.7% to 1.9% using contextual chunks, BM25 keyword search and reranking, and Chroma's July 2024 tests finding 800-token chunks with 400 tokens of overlap gave slightly below-average recall.

recommendation

Build a 20-30 question set from real logs with the exact evidence passage marked, log retrieval, reranking and the final prompt, then fix the earliest failing stage before changing models.

more in playbook: Retrieval and RAG
by read12 min views9 publishedNov 26, 2026
Why Is My RAG Retrieving Irrelevant Chunks, and Which Fix Comes First?
Image: Startupfortune (auto-discovered)

Swapping models is a tempting first move when your assistant pulls the wrong passages, and it can leave the fault right where it was. You need to see where the correct text goes missing.

  • Mark the exact passage that answers each of 20 to 30 real user questions before you change any component.
  • Fix the earliest broken stage first, working from missing content and parsing through to ranking and generation.
  • A passage found in your top 100 results but absent from the few you send to the model points to a ranking problem.
  • Chroma's July 2024 tests found 800-token chunks with 400 tokens of overlap gave slightly below-average recall.
  • Anthropic cut its top-20 retrieval failure rate from 5.7% to 1.9% with contextual chunks, BM25 keyword search and reranking.
  • If the right passage reaches the prompt and the answer's still wrong, test the model with that passage alone.

When Uber tested Genie, its on-call chatbot in Slack, against more than 100 questions written by in-house experts, it found answers that were incomplete, inaccurate or missing the relevant material. Genie was drawing on more than 40 security and privacy policy documents saved as PDFs, and one problem sat upstream of any model. Standard PDF s were pulling table cells loose from their rows and columns, according to Uber's engineering blog. If you're asking "why is my RAG retrieving irrelevant chunks?", start with real questions, follow the right passage through your pipeline and find the step where it gets damaged or dropped.

Don't start by swapping the embedding model or paying for a bigger LLM. Neither can repair a table that was shredded on the way in. You may not even need retrieval. Anthropic's advice is that a knowledge base under 200,000 tokens, about 500 pages, can go into the prompt whole.

Pull 20 to 30 questions from your logs, support tickets or the Slack thread where people complain. Keep the typos and shorthand. Questions you write yourself tend to borrow the document's own wording, which makes search look better than it is. Your set should include some that hinge on an exact code or product name, a few that need two documents, and two or three that your documents can't answer at all.

For each one, write down the correct answer and copy out the sentence or table row that proves it, along with the file it came from. Give this job to someone who knows the material. Then run the set and save four things per question: the search results with filters switched off, the results with filters on, the order after reranking, and the final prompt exactly as the model received it. If your framework hides any of those, add logging before you touch anything else.

[How to Write AI Agent Tool Descriptions That Stop Wrong Tool Calls](https://startupfortune.com/how-to-write-ai-agent-tool-descriptions-that-stop-wrong-tool-calls/)

Each description should answer five questions, including which tool to use instead. A three-tool customer support example, get_customer, search_orders and update_record, shows the rewrite, and a test of 40 real requests finds which pair of tools keeps getting swapped. - how to write AI agent tool descriptions - prevent wrong AI agent tool calls

How to measure recall at k for RAG #

Recall at k is the share of your marked passages that show up in the top k results. A question with two evidence passages, only one of which appears in the top five, scores 0.5 at a k of five. Average the scores across the answerable questions and you've got your number.

Match on the text, never on chunk IDs. IDs change the moment you re-chunk, and your answer key goes stale with them. Count a chunk as a hit if it contains the evidence you copied out, after tidying up whitespace. Record a half-contained answer as a miss and flag it, because it usually means a boundary fell in the wrong place.

Run the calculation at two depths. Recall at 100 tells you whether search can find the evidence at all, while recall at the number of chunks you actually send, say five, tells you whether it ranks high enough to be used. With only 25 single-passage questions, one result flipping moves the average by four points. Then label every failed question with the first stage where its evidence disappears.

Check the corpus and the parser first #

Start with the dull test. Search your source files for each piece of evidence and confirm those files were indexed. Vector search will normally hand back the nearest k chunks whether or not any of them is close, so a missing policy or an unsynced folder can look like bad retrieval.

Then read the parsed text, the string your chunker received, for every failing question. Look for table rows that have lost their headers, or two columns read straight across as one. Page footers turn up in the middle of sentences. Scanned pages come out garbled or empty.

Uber's team tried PdfPlumber, PyMuPDF and LlamaParse and couldn't find a universal solution for its documents, where some tables ran past five pages and had nested cells. It moved to Google Docs and wrote its own with Google's Python API to extract paragraphs, tables and the table of contents. An LLM turned the tables into markdown, and those chunks were tagged so they'd stay intact during splitting. Your source files may have to stay as they are. You can still run two parsers over your ten ugliest pages and compare the output side by side.

Be especially wary of scans. The authors of OHR-Bench, a benchmark covering 8,561 document images and presented at ICCV 2025, found that even the best OCR tools left a performance gap of at least 14% against the clean ground-truth data.

Why Does My AI Coding Agent Bill Keep Increasing Overnight Why does my AI coding agent bill keep increasing when nobody touched the keyboard overnight? Usually it's a runaway tool-call loop compounding token costs with every retry. This guide walks through the mechanism, a real incident involving Replit's agent, and the specific guardrails that stop it. - why AI coding agent bills spike overnight - preventing runaway tool call loops in agents

RAG chunk size and overlap best practices #

Clean text can still be cut badly. If the evidence is split across two chunks, or buried in a long one that covers six other topics, fix the splitter. Check what you inherited. OpenAI's file search, left on its automatic setting, uses 800-token chunks with 400 tokens of overlap.

Chroma tested that size and overlap in a July 2024 report, using OpenAI's text-embedding-3-large and five retrieved chunks. A token splitter at those settings reached 87.9% recall, which Chroma described as slightly below average, and it had the lowest scores on the other measures. A recursive character splitter set to 200 tokens with no overlap scored 88.1%, essentially level, with token precision of 7.0% against 1.4%, so far less unwanted text came along with the answer. Raise that recursive splitter to 400 tokens, still without overlap, and recall was 89.5%.

Those results come from Chroma's own test data and vary widely from query to query, so 200 isn't a magic number. Overlap can earn its place: with the small all-MiniLM-L6-v2 model, a 250-token splitter fell from 82.4% recall to 77.1% when the overlap was removed. A sensible first trial is a recursive splitter at 200 to 400 tokens with modest or zero overlap, measured against your questions.

No chunk size will help a passage that doesn't say what it's about. Anthropic's example is the line "The company's revenue grew by 3% over the previous quarter." Which company, and which quarter? Its Contextual Retrieval method has a model write a short note onto each chunk before indexing, in this case identifying an SEC filing on ACME's second quarter of 2023 and giving the earlier quarter's revenue of $314 million. For a cheaper first attempt, add the document title and section headings to the top of every chunk.

Check embedding settings before changing models #

Length limits are the first suspect. The model card for all-MiniLM-L6-v2 says input longer than 256 word pieces is truncated by default. Feed it 800-token chunks and most of each one never reaches the vector, however good the text is.

Input labels come next. E5 models expect text to begin with "query: " or "passage: ", and the e5-large-v2 card says plainly that leaving the prefixes off degrades performance. That model also truncates at 512 tokens. Cohere's embedding models take an input_type value, set to search_document when you index and search_query when someone asks a question. Confirm that both sides use the same model and version, especially if an older script built the index.

Then rule out the index itself. Approximate nearest-neighbour search gives up some accuracy for speed, so compare it with an exact search. In pgvector, run SET LOCAL enable_indexscan = off inside a transaction and repeat the query. Evidence that appears only in the exact results means the index needs tuning. If both searches miss it and your settings check out, try a second embedding model on the same chunks and questions.

Filters can remove the right chunk before ranking #

Compare the filtered and unfiltered logs. A passage that shows up only with filters off sends you to the filter or the metadata, where you might find a date stored as text or older files with no product tag. Permission rules stricter than anyone intended turn up there too. If a model writes your filters from the user's question, read what it wrote. It can pick the wrong year.

Correct metadata can still leave you short. With pgvector's approximate indexes, filtering happens after the index is scanned, according to the project's documentation. At the default hnsw.ef_search of 40, a condition matching 10% of rows leaves four matches on average.

Version 0.8.0 introduced iterative index scans, which keep looking until enough rows pass the filter or a limit is reached, such as the default of 20,000 for hnsw.max_scan_tuples. You can also raise ef_search, build partial indexes for a few common filter values or partition the table. Test with the most restrictive filter your users really trigger.

Hybrid search and reranking for RAG #

Exact strings are a known weak spot for embeddings. Anthropic uses a query for "Error code TS-999", where semantic search might return general material about error codes and miss the one passage containing that identifier. BM25, a long-standing keyword ranking method, is built to catch such matches, and Uber ran it beside vector search. Hybrid setups commonly merge the two lists with reciprocal rank fusion, which rewards a result for its position in each list and avoids comparing raw scores on different scales. OpenAI's retrieval API lets you weight the embedding and keyword sides.

A reranker works on order. A cross-encoder reads the query and a candidate passage together, which is more accurate than comparing vectors made separately and much too slow to run across a large corpus, so you give it a shortlist. Anthropic retrieved 150 candidates, reranked them with Cohere's model and kept 20.

Anthropic's figures show the layers adding up. It started with 5.7% of relevant documents missing from the top 20. Contextual embeddings lowered that to 3.7%, adding contextual BM25 took it to 2.9%, and reranking finished at 1.9%. These are averages on Anthropic's test sets, and your corpus will behave differently. A reranker also can't promote a passage it never received, so get the candidate pool right before you pay for one.

When retrieval works and the answer is still wrong #

Open the saved prompt. Retrieved evidence can be cut by a token budget, an overeager deduplication step or a score cutoff. OpenAI's guide warns that a higher score_threshold may exclude useful results.

If the evidence is there, give the model that passage alone with the same question. A correct answer now suggests the other chunks were getting in the way. Try sending fewer, or move the strongest toward the start or end of the context, since research by Nelson Liu and colleagues, published in 2024, found models often performed best with relevant material in those positions. Fewer won't always win. Anthropic tried 5, 10 and 20 chunks and got its best results with 20. If the model still fails with only the right passage in front of it, work on your instructions or test another model. Save your unanswerable questions for last. Google researchers reported in May 2025 that the Gemma model went from wrong answers on 10.2% of questions with no context to as high as 66.1% when given context that was insufficient to answer them. Tell your model to say when the material doesn't cover a question, then check that it does.

Which RAG fix comes first #

Count your labels and repair the earliest stage causing a meaningful share of failures, even if a later stage has a bigger pile, because later results were measured on whatever that stage handed over. Put the order on the ticket as questions. Is the answer in the corpus? Did it survive parsing, and does it sit whole in a chunk that names its subject? Was it embedded correctly, kept by the filters and ranked high enough? Did the model get it and use it?

Change one thing, rebuild whatever depends on it and rerun every question, including those that already passed. Uber's redesign, which added agent steps on top of its new and keyword search, produced a relative 27% rise in acceptable answers and a relative 60% drop in incorrect advice, by the company's own measure. Keep your question set in the repository and add each new complaint to it.

Also read: Why Is My Prompt Cache Hit Rate Low and How Do I Get the Discount Back? • Why Is LLM Output Different at Temperature 0, and Can You Stop It? • AI support agent cost per resolved ticket runs 2 to 4 times the sticker

This article is posted in AI News, check it out for more related stories.

Join the discussion #

Open in the community → Almost there. Sign in and your reply posts straight away.

── more in #large-language-models 4 stories · sorted by recency
── more on @uber 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/why-is-my-rag-retrie…] indexed:0 read:12min 2026-11-26 · —