Retrieval-augmented generation
Retrieval-augmented generation (RAG) improves the accuracy and specificity of large language model responses by providing relevant context from a knowledge base at runtime.
A topic page: a summary of what my posts say, with each claim quoted from the post it came from. The posts are the authority. Last checked 2026-11-06.
Summary. Retrieval-augmented generation (RAG) improves the accuracy and specificity of large language model responses by providing relevant context from a knowledge base at runtime. This approach ensures that the model relies on retrieved data rather than its own internal memory to generate answers.
What the posts say
RAG provides context by finding relevant text before the model generates an answer.
βRetrieval-Augmented Generation, RAG for short, is the pattern behind most of the useful AI applications being built right now: instead of asking a language model to answer purely from what it happened to be trained on, you find the specific, real, relevant text first, hand that to the model as context, and ask it to answer from that.β β Model Context Protocol (Part 3)
The system ensures citations are accurate because the metadata is pulled from the database rather than generated by the LLM.
βThe detail I think matters most here: citation metadata β case name, medium-neutral citation, page number β is read straight off the retrieved database rows, never generated by the model.β β Agentic AI for Professionals (Part 2)
The system prevents hallucinated citations by reading metadata directly from the database.
βThe citation metadata β case name, page number β is read directly off the retrieved database row, never generated by the model, so which excerpt gets cited is the LLM's call, but the citation itself can't be hallucinated.β β Agentic AI for Professionals (Part 3)
The embedding model is only used to find passages, while a separate model writes the final answer.
βThe agent uses a separate model to write the answer from the passages that the search returns.β β Azure Search (Part 2)
The strict agent correctly used the knowledge base and provided clickable sources.
βI asked about DWI while asleep in a parked car, and the strict agent answered with the section name and two clickable references into the search indexβ β Azure Foundry Agent (Part 5)
The system is restricted to performing tasks within that specific catalog and using a curated, scoped document set.
βIt is restricted to only performing tasks inside that catalog.β β Agentic AI for Professionals (Part 1)
Context injection improves the accuracy and specificity of the model.
βThis helps guide the modelβs response and enhances its accuracy, relevance, and specificity.β β Context Injection
The system ensures that prompts are written more efficiently.
βThis technique has two specific benefits: (1) prompts are always more efficiently written, and (2) your data are always up to date.β β Context Injection
The posts behind this page
- Azure Foundry Agent (Part 6) β Rules from the statutes, a small model that only reads, and a side-by-side test against GPT, DeepSeek and Google on the same arrests
- Azure Foundry Agent (Part 5) β Following Microsoft's Foundry IQ learning module with my six Minnesota law documents: a knowledge base, an agent with vague versus strict instructions, 17 questions, and a comparison with my other RAG posts
- Model Context Protocol (Part 3) β Building a Retrieval-Augmented Generation stack and finally exposing the search function to Claude Code over MCP
- Agentic AI for Professionals (Part 3) β Giving nsw-legal-research-assistant a real interface and an MCP server exposing the same skill to Claude Code, then running it through the same demo Thomson Reuters used to introduce CoCounsel, live, with real output β grounded Q&A, pinpoint citations, Review, and skill-chaining drafting
- Agentic AI for Professionals (Part 1) β Using a structured LLM-wiki research process to study Thomson Reuters CoCounsel's architecture, then turning that research into an implementation plan for a simplified legal research assistant
- Agentic AI for Professionals (Part 2) β Building the RAG core of a legal research assistant entirely on a 32GB M4 MacBook Air β page-safe chunking, a provider-agnostic LLM layer, and citations that can't be hallucinated
- Azure Search (Part 2) β Creating an AI agent in Azure AI Foundry backed by Azure AI Search with vector embeddings for retrieval-augmented generation (RAG)
- LangChain (RAG) β Using LangChain to create a medical report application
- Context Injection β How context injection works in LLM applications β injecting relevant documents, data, and instructions into the model's prompt at runtime for RAG