AI Dictionary of Terms

RAG (Retrieval-Augmented Generation)

An AI framework that improves the accuracy and reliability of Large Language Models by grounding their responses in external, up-to-date, or proprietary data sources.

The Simple Version

Imagine you have a very smart friend who has read a lot of books. But sometimes, when you ask them a question, they might make up an answer because they want to be helpful, even if they don’t really know. That’s what happens with AI sometimes — it tries its best, but it can get things wrong.

Now, imagine that same smart friend has a big filing cabinet right next to them, full of all the right answers. When you ask a question, instead of guessing, your friend opens the filing cabinet, finds the exact page that talks about your question, reads it carefully, and then gives you an answer based on what they just read.

That’s what RAG does. It gives the AI a filing cabinet of trustworthy information to look through before answering your question. That way, the answer is more likely to be right, and you can even check the source to make sure.

Detailed Explanation

Instead of relying solely on the static, pre-trained knowledge of an LLM (which can lead to hallucinations or outdated info), RAG works in two steps:

  1. Retrieval: When a user asks a question, the system searches a vector database or document store for relevant context.
  2. Augmentation & Generation: That retrieved context is appended to the user’s prompt and sent to the LLM, which then generates an answer based only on the provided facts.

Key Characteristics

Business Context

In an enterprise environment, RAG is essential for customer support, internal knowledge bases, and document analysis. It allows organizations to build AI tools that answer employee or client questions by retrieving exact clauses from proprietary documentation, internal wikis, or specific codebases, ensuring answers are accurate, up-to-date, and compliant with industry standards.

Real-World Analogy

Taking an open-book exam. Instead of memorizing the entire textbook (pre-training), you are allowed to look up the exact page you need (retrieval) to answer the specific question (generation).

Code Example

# Conceptual RAG flow
query = "What is the compliance validation rule for this document?"

# 1. Retrieve relevant chunks from vector DB
context = vector_db.search(query, top_k=3)

# 2. Augment prompt
prompt = "Answer based on this context: " + context + "\n\nQuestion: " + query

# 3. Generate
response = ai_gateway.generate(prompt)

Common Misconceptions

Sources & Further Reading