Where Naive RAG Fails: Five Ways the Simplest Retriever Hands the Model the Wrong Pages
A naive retriever (300-character chunks, cosine, top 2, no minimum score, every file in the folder) fails five ways on one handbook: PTO never finds annual leave, the ethics line is cut in half, the 2023 edition comes back at 0.70 next to today's 0.73, a two-part question gets one fact, and parking returns chunks at 0.22 anyway.
What you will learn
- Build the simplest RAG retriever and name each shortcut it takes
- Reproduce five failures: different words, a cut sentence, an old version, a two-part question and nothing to find
- Read every failure in the retrieved chunks before the model writes a word
- Match each failure to the fix it points at
Before you start
- The RAG Pipeline Explained
- Chunking Strategies for RAG
The simplest RAG retriever works in a demo and fails in production. In this article we build that retriever on purpose, ask it five questions about a small company handbook, and watch it hand the model the wrong pages five different ways.
The useful part: every one of these failures is visible in the retrieved chunks, before the model writes a single word. That's where you look first.
The new intern at the filing cabinet
Picture a new intern at the filing cabinet. Fast, eager, and takes every request literally.
- You ask for the PTO rules, but the folder says "annual leave", so the intern finds nothing.
- The answer starts at the bottom of one page and ends on the next, and the intern brings only one page.
- Last year's binder is still on the shelf, and it comes back too.
- Your question needed two folders, and the intern brings one.
- When nothing fits, the intern never says no. Something always comes back.
Naive RAG is exactly this intern, and the model then answers from whatever it was handed.
naive_rag.py: the simplest retriever
Two files, the current Brightfield handbook and an archived 2023 edition that was never removed from the folder, give us 22 chunks. They're embedded with all-MiniLM-L6-v2 and compared with cosine. No API key is needed.
"""A naive RAG retriever: fixed-size chunks, plain cosine, top k, no checks.
Every shortcut here is one of the failure modes in fails.py."""
import pathlib
import re
import numpy as np
from sentence_transformers import SentenceTransformer
HERE = pathlib.Path(__file__).parent
model = SentenceTransformer("all-MiniLM-L6-v2")
def load(name):
text = (HERE / name).read_text(encoding="utf-8")
text = re.sub(r"^#.*\n", "", text, flags=re.M) # drop the headings
return re.sub(r"\s+", " ", text).strip()
def chunk(text, size=300):
# cut every 300 characters, wherever that lands
return [text[i:i + size] for i in range(0, len(text), size)]
def build(files=("handbook.md", "handbook-2023.md")):
chunks = [(f, c) for f in files for c in chunk(load(f))]
vecs = model.encode([c for _, c in chunks], normalize_embeddings=True)
return chunks, vecs
def search(index, question, k=2):
chunks, vecs = index
scores = vecs @ model.encode([question], normalize_embeddings=True)[0]
top = np.argsort(-scores)[:k]
# no minimum score: the top k always go to the model
return [(*chunks[i], round(float(scores[i]), 2)) for i in top]
Five shortcuts, and each one becomes a failure:
loaddrops the headings, so chunks lose their section names.chunkcuts every 300 characters, even in the middle of a sentence.buildindexes every file in the folder, including the 2023 handbook.searchkeeps only the top two chunks.- There's no minimum score. Whatever comes back always goes to the model.
fails.py asks five questions, each with the words the answer needs, and prints what comes back with a verdict:
CASES = [
("1 words differ", "What is our PTO allowance?", "twenty-five days"),
("2 cut in half", "Who do I call about harassment at night?", "ethics line, which is open at all hours"),
("3 two versions", "How many unused leave days can I carry over?", "up to five unused days"),
("4 needs two pieces", "What do I get for meals on a trip and for courses each year?", ["forty euros", "one thousand euros"]),
("5 nothing to find", "What is the parking policy?", None),
]
Failure 1: the words differ
What is our PTO allowance? The answer needs "twenty-five days" from the annual leave section. The top chunk is about the learning budget, at 0.42. The second is the meal allowance, at 0.31. Missed: annual leave never shows up.
The handbook never uses the word PTO. A small embedding model doesn't link the two, so the right section scores too low.
Failure 2: the answer is cut in half
Who do I call about harassment at night? The answer is the confidential ethics line, "which is open at all hours". Now look where the 300-character cut fell:
end of one chunk: ... If you see or experience a problem, speak to your manager, the
start of the next: people team or the confidential ethics line, which is open at all hours ...
The retriever brings back the start of the code of conduct (0.35) and a security chunk (0.23). Missed: the ethics line isn't in the top two, because neither half carries the whole answer.
Failure 3: two versions disagree
How many unused leave days can I carry over? Today's answer is "up to five unused days". The current handbook comes first at 0.73. But right behind it, at 0.70, is the 2023 edition: twenty days of leave and up to ten unused days to carry over.
The answer is found, but the 2023 version is sent too. The model now sees two different rules for the same question, and nothing tells it which one is current.
Failure 4: it needs two pieces
What do I get for meals on a trip, and for courses each year? This needs two facts from two sections: forty euros a day, and one thousand euros a year. The top chunk (0.35) is mostly about remote work, and only its last words start the expenses section, cut off at "A daily meal a". The second chunk (0.31) has the learning budget.
Missed: 1 of 2 facts. With k=2, a half-relevant chunk took the second seat, and forty euros never came back.
Failure 5: there is nothing to find
What is the parking policy? The handbook has no answer at all. The retriever still returns two chunks: the meal allowance at 0.22 and remote work at 0.19.
Nothing relevant, but chunks are still sent. The best score is only 0.22, and the model gets these chunks anyway. A confident, made-up answer is now just one step away.
Five failures, five directions
Put all five side by side. Each one points somewhere different, and none of them is "use a bigger model":
| Question | Naive result | Direction |
|---|---|---|
| PTO allowance | Missed | Match words too: keyword or hybrid search, query rewriting |
| Ethics line at night | Missed | Chunk on sentences and sections, with some overlap |
| Carry-over days | Found, but the 2023 version is sent too | Metadata: a version or date, and filter out archived files |
| Meals + courses | Missed (1 of 2 facts) | Retrieve more, then rerank, or split the question |
| Parking | Nothing relevant, but chunks are still sent | A minimum score, and permission to say "I don't know" |
Each direction has its own article: hybrid search, chunking strategies, metadata filters in a vector database, reranking, and citations and abstention.
Common mistakes
- Blaming the model first. In all five cases the model never had a chance; the wrong chunks were already in the prompt. Check retrieval first.
- Indexing a whole folder blindly. Archived and draft files compete with the current ones, at almost the same score.
- Cutting by character count. A 300-character knife doesn't know where a sentence ends.
- A tiny fixed k. Two seats is not enough for a question that needs two sections and gets one half-relevant chunk.
- No floor. Without a minimum score, "nothing found" silently becomes "here are two random chunks".
Quick recap
- Different words, cut sentences, old versions, two-part questions and missing answers all break naive retrieval.
- Every one of them shows up in the retrieved chunks, before the model writes a word.
- So the first check is always: does the top k hold the words the answer needs?
Try it yourself
Run python fails.py and read all five verdicts. Then change one setting: k=5 in search(), or remove handbook-2023.md from build(), and see which cases recover. Finally, add a question of your own, with the words its answer needs.
Related course on Udemy
Become an AI Engineer: LLMs, RAG, Agents and MCP
Build real AI systems in Python: LLM APIs, RAG, evals, agents and MCP.View on Udemy ↗: Become an AI Engineer: LLMs, RAG, Agents and MCP (paid course, opens in a new tab)Related posts
What an Embedding Actually Is: Meaning as Numbers, Search by Closeness, and Where Hand-Made Numbers Break
A customer types "I cannot log in" and keyword search finds nothing, although a password-reset article exists. Turn meaning into numbers by hand, find the nearest point with math.dist, build a three-topic toy embedder that finds the right article at 1.00, and watch it score 0.00 on "I can't get into my account".
The RAG Pipeline Explained: 7 Stages From Documents to a Cited Answer
Ingest, chunk, embed, store, retrieve, rerank and generate, in one Python file. Follow one question through a 26-chunk employee handbook to an answer that cites its source.
Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
Ask one question of a whole collection of vectors: which items are closest to this one? Normalise, score every row with one matrix multiply, keep the top k or everything above a threshold, and check it with NearestNeighbors.
Why RAG Exists: The Problem It Solves, Compared With Pasting Everything and Fine-Tuning
A smart model has never read your company's files, and they change every month. Three ways to give it the facts: paste everything, fine-tune, or retrieve only the right pieces. Follow a refund-policy question through all three and see why RAG wins when documents change.