AI
#AIIn60SecondsRAG in 60 Seconds
An LLM only knows what it was trained on. RAG lets it go look something up before it answers. Here's the whole loop in six steps.
Note · AIIn60Seconds
RAG in 60 Seconds
On this page
A model like ChatGPT only knows what was in its training data.
Picture a football fan who stopped following the news last year. They still know the rules, still know the old squad — but ask who won last weekend and they'll guess. And the guess will sound exactly as confident as a fact.
That's the problem. A wrong answer delivered confidently is more dangerous than "I don't know."
RAG (Retrieval-Augmented Generation) fixes it by letting the model look something up before it answers.
The six steps
- The user asks a question — in plain language.
- An embedding model turns the query into a vector — a list of numbers standing for the meaning, not the words.
- A vector database finds relevant documents — comparing that vector against your own content to find what's closest in meaning.
- Pull out the important chunks — not whole documents, just the passages that actually answer the question.
- Combine those chunks with the query — into a single prompt.
- The LLM answers from that context — and can cite where each claim came from.
Step 6 is the whole point: the model stops answering from memory and starts answering from what you just handed it.
Why it matters
- Answers grounded in your own data, not general internet knowledge.
- Access to the latest information without waiting for a new model generation.
- No retraining — adding a document just means adding it to the index.
- Fewer hallucinations, because there's real text underneath the answer.
That last one isn't a total fix. RAG reduces invention, but if retrieval pulls the wrong passage the model will be confidently wrong about that instead. Retrieval quality is the thing that actually determines whether any of this works.
Want to try it?
I've written up building this pipeline on the Postgres you already have, using pgvector — no separate vector database required. And the lab on this site lets you run retrieval yourself and watch which chunks get selected, and why.