One Problem at a Time: Building RAG From Scratch - part 1

Ai · July 8, 2026 · 20 min read

when you ask an LLM a question, it answers instantly and confidently.

this creates a dangerous illusion, that the model knows things, the same way a person knows things. it does not.

we can think of a model as a function that predicts the next token given a sequence of previous tokens.

everything it "knows" is frozen at the moment its training data was collected, with no mechanism to look anything up.

consequently, we run into two main problems:

confidence and correctness are not the same signal.

so the question is not always:

"how do we make the model smarter?"

sometimes the better question is:

"how do we put the right information in front of the model at the exact moment it needs to answer?"

RAG is one attempt to answer that question.

retrieval-augmented generation means: before asking the model to answer, we retrieve relevant external information and inject it into the model's context.

simple idea. hard execution.

because the quality of the whole system depends heavily on the first word: retrieval.

if retrieval brings the wrong documents, the model will answer from the wrong evidence.

if retrieval misses the important detail, the model may confidently fill the gap.

if retrieval brings too much noise, the model may use the wrong part.

if retrieval works only for obvious keyword matches, it fails the moment the user asks the question differently.

this series is about that problem.

roadmap

  1. preprocessing

  2. scoring relevance: TF-IDF and BM25

  3. semantic search: embeddings

  4. chunking

  5. hybrid search

  6. language model as a query enhancer

  7. reranking

  8. evaluation

  9. augmented generation

  10. agentic retrieval

  11. multimodal retrieval


or you can just load documents with langchain, dump them into chroma, query the vector database, and call it a day.