Guide
The RAG pipeline, step by step
A RAG pipeline is five steps in order. Load the document into clean text, chunk it into passages, embed each passage so it can be searched by meaning, retrieve the passages that match a question, and answer from them with a citation on every sentence. Each step hands the next a smaller, more exact input.
See it run on a real handbook
Step 1, Load
Takes in: handbook.pdf, 5 pages
Hands on: 136 words of clean text
Step 2, Chunk
Takes in: 136 words, cut in windows of 40 words that overlap by 8
Hands on: 5 passages, each keeping its page number
Step 3, Embed
Takes in: 5 passages
Hands on: 5 lists of numbers, 384 each with a real embedding model. The free X-ray skips this step and matches words.
Step 4, Retrieve
Takes in: the question "Can I work remotely?"
Hands on: 1 passage: page 9, score 4.694
Step 5, Answer
Takes in: 56 words: the rules, the question and that passage
Hands on: an answer with a citation on every sentence, checked against the passage
Counted on the free X-ray's sample handbook with its own code. Run the X-ray to watch your own AI go through the last two steps. The sample is the free X-ray's handbook, 5 short pages. Every number here is computed when the page loads, from that text, with the X-ray's own way of reading words.
Where a pipeline breaks
A wrong answer usually comes from a step before the last one: text lost on load, a passage cut in half, or the right passage not retrieved. Read what came back from each step before you judge the answer.
What to build first
Build the five steps small and run one real question through all of them. A pipeline you can read end to end on one question is easier to improve than a large one you cannot.
Sources
- Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020)
- What is RAG?, Amazon Web Services
Keep going
Build the whole pipeline on your documents
Works with the AI you already use: Claude, ChatGPT, any. We do not make the model smarter. We make your pipeline visible.