The GCC Engineer
  • Report
  • Companies
  • Roles
  • Guides
  • Pricing
Log inGet started
ReportCompaniesRolesGuidesPricing
Log inGet started

The GCC Engineer

The end-to-end AI engineering career roadmap for GCCs in India.

Explore

  • Companies
  • Roles
  • Guides
  • The blueprint
  • The GCC growth story

Tools

  • Resume Evaluate
  • Readiness check
  • Your roadmap

Company

  • Pricing
  • Contact

The GCC report

How fast India's GCCs are growing, where they hire and what makes a role there different.

Read the report
© 2026 The GCC Engineer
  • Privacy
  • Terms
  • Refunds
  • Delivery
  • Contact
The GCC Engineer
  • Report
  • Companies
  • Roles
  • Guides
  • Pricing
Log inGet started
ReportCompaniesRolesGuidesPricing
Log inGet started
  1. Home
  2. Guides
  3. Skills and roadmap
  4. What is RAG? Retrieval-augmented generation explained
Skills and roadmap

What is RAG? Retrieval-augmented generation explained

What is RAG? A plain explanation of retrieval-augmented generation: the pipeline, chunking, retrieval, re-ranking, evaluation and the ways it fails.

By The GCC Engineer editorial teamUpdated 13 November 20266 min read

Quick answer

RAG, or retrieval-augmented generation, is a way of building LLM applications in which the system first retrieves relevant passages from your own documents and then gives them to the model as context for its answer. The model answers from supplied evidence instead of from memory alone, which keeps answers current, lets them cite sources and reduces, but does not remove, made-up content.

On this page
  1. Why do LLM applications need RAG?
  2. How does a RAG pipeline work?
  3. How should you chunk documents for RAG?
  4. What are retrieval and re-ranking?
  5. How do you evaluate a RAG system?
  6. What are the common RAG failure modes?
  7. When should you use RAG instead of fine-tuning?
  8. What do interviews ask about RAG?

RAG, short for retrieval-augmented generation, is a method for building LLM applications in which the system looks up relevant passages from your own documents and hands them to the model along with the question. The model then writes its answer from that supplied context instead of relying on what it memorised in training. If you have asked what is RAG because it appears in every GenAI job description, the reason is simple: it is the standard way to make a general model useful on private, changing company knowledge.

RAG sits in the middle of the AI engineer roadmap. It depends on embeddings, vector search and prompting, and it is the prerequisite for agents.

Why do LLM applications need RAG?

LLM applications need RAG because a model on its own knows only what was in its training data. It has not read your policy documents, your product catalogue or yesterday's ticket. Asked about them, a model either says it does not know or produces a plausible invention.

RAG solves three problems at once. Answers can use private information without retraining anything. Knowledge stays current, because updating the document index updates what the system knows. And answers can point to the passages they came from, so a user or auditor can check them. That last property matters a great deal in regulated settings such as banking and healthcare.

How does a RAG pipeline work?

A RAG pipeline works in two phases. Indexing happens ahead of time: documents are split, converted to embeddings and stored. Answering happens per question: the system retrieves the best passages, builds a prompt and generates a reply.

The RAG pipeline, from document to answer
  1. 1

    Load and clean

    Extract text from files, pages and tables. Bad extraction here cannot be repaired later.

  2. 2

    Chunk

    Split documents into passages small enough to retrieve precisely and large enough to make sense alone.

  3. 3

    Embed and index

    Convert each chunk to a vector with an embedding model and store it with metadata such as source, date and access rights.

  4. 4

    Retrieve

    Embed the question and find the nearest chunks, often combined with keyword search and metadata filters.

  5. 5

    Re-rank

    Score the candidates against the question with a more accurate model and keep the best few.

  6. 6

    Generate

    Put the kept passages and the question in a prompt and have the model answer from them, with citations.

  7. 7

    Evaluate

    Measure whether the right passages were found and whether the answer is faithful to them.

An embedding is a list of numbers that represents the meaning of a piece of text, arranged so that texts with similar meaning have vectors that point in similar directions. Vector search finds the chunks whose embeddings are closest to the question's embedding.

How should you chunk documents for RAG?

Chunk documents so that each chunk is a self-contained unit of meaning, following the document's own structure wherever possible. There is no universally correct chunk size; it is a trade-off you tune against your own questions.

Small chunks retrieve precisely but may lack the context needed to interpret them: a sentence saying "the limit is doubled in this case" is useless without the preceding paragraph. Large chunks keep context but dilute the embedding, since one vector now has to represent several topics, and they use up more of the prompt.

Practical rules that hold up:

  • Split on headings, sections and paragraphs before falling back to a fixed length.
  • Overlap neighbouring chunks slightly so that a fact on a boundary is not cut in half.
  • Attach the document title and section heading to each chunk, so the chunk makes sense alone.
  • Treat tables, code and lists as units; splitting a table by character count destroys it.
  • Keep metadata with every chunk. Filtering by date, product or permission is often worth more than a better embedding.

What are retrieval and re-ranking?

Retrieval is the step that selects candidate passages for a question, and re-ranking is a second, more careful pass that reorders those candidates. Retrieval must be fast across the whole collection; re-ranking can afford to be slower because it looks at only a short list.

Two retrieval methods complement each other. Vector search matches meaning, so "how do I get my money back" finds a passage about refunds. Keyword search matches exact terms, which vector search handles poorly: product codes, error numbers, names and rare abbreviations. Hybrid search runs both and merges the results.

A re-ranker reads the question and each candidate passage together and scores how well the passage answers the question. That is more accurate than comparing two separately computed vectors, and it lets you retrieve a wide net of candidates and pass only the strongest few to the model.

How do you evaluate a RAG system?

You evaluate a RAG system by measuring retrieval and generation separately, using a fixed set of test questions with known answers. A single overall score cannot tell you whether a wrong answer came from missing passages or from a model that misused good ones.

For retrieval, the question is whether the passages that contain the answer were returned. Recall at k is the usual starting metric:

python
def recall_at_k(retrieved: list[str], relevant: set[str], k: int) -> float:
    """Share of the relevant chunk ids that appear in the top k results."""
    if not relevant:
        return 0.0
    hits = len(set(retrieved[:k]) & relevant)
    return hits / len(relevant)

For generation, two questions matter. Faithfulness: is every claim in the answer supported by the retrieved passages? Answer relevance: does the reply address what was asked? Both usually need a human or a carefully checked model as judge; how to evaluate an LLM application explains how to build the test set and where automated judges go wrong.

What are the common RAG failure modes?

The common RAG failure modes fall into retrieval failures, generation failures and data failures, and each has a different fix. Diagnosing which one you have is the core practical skill.

SymptomLikely causeFirst thing to try
The answer exists in the documents but was not retrievedChunks too large or too small, or vocabulary mismatchAdjust chunking, add keyword search
The right passage was retrieved but ranked too low to be usedWeak ranking among many similar chunksAdd a re-ranker, retrieve more candidates
The answer contradicts the retrieved passageThe model relied on memory or misread the contextTighten the prompt, require citations, measure faithfulness
A confident answer when nothing relevant existsNo way for the system to declineAllow "not found", add a relevance threshold
Out-of-date or conflicting answersStale or duplicate documents in the indexRefresh the index, de-duplicate, filter by date
A user sees content they should notPermissions not applied at retrievalFilter by access rights before ranking
RAG symptoms, causes and first fixes.

One more risk deserves a mention. Retrieved text is untrusted input: a document can contain instructions aimed at the model. Systems that act on retrieved content need the guardrails discussed in AI agents and tool use.

When should you use RAG instead of fine-tuning?

Use RAG when the problem is missing knowledge, and fine-tuning when the problem is behaviour. The two address different gaps and are often combined.

RAG or fine-tuning?

Choose RAG when

  • The knowledge is private or changes often
  • Answers must cite their sources
  • Different users may see different documents
  • You need to update knowledge without retraining

Choose fine-tuning when

  • The model must follow a fixed style or output format
  • The task is narrow and repeated at high volume
  • Prompting alone cannot produce consistent behaviour
  • You have good labelled examples of the desired output

A sensible order is prompting first, then RAG, then fine-tuning only if a measured gap remains. Each step costs more to build and maintain than the one before.

What do interviews ask about RAG?

Interviews ask about RAG as a system to be designed and debugged, not as a definition. Expect to be given a scenario, such as a support assistant over a large policy library, and asked how you would chunk the documents, which retrieval method you would use and why, how you would know it works, and what you would do when a specific answer is wrong.

Strong answers move through the pipeline in order and name a trade-off at each step. The typical questions and how to structure answers are collected in GenAI interview questions on RAG, agents and evaluation. RAG is a core skill for the GenAI and LLM engineer role and for AI backend engineers, and a small RAG system with a real evaluation is one of the most useful AI portfolio projects you can build.

To see where RAG falls among the skills your target role needs, take the free readiness check and get a personal roadmap in order.

Key takeaways

  • RAG retrieves relevant text at question time and passes it to the model, so the model answers from evidence.
  • A RAG system has two halves, indexing and answering, and most quality problems start in indexing.
  • Retrieval quality sets the ceiling: the model cannot use a passage that was never retrieved.
  • Evaluate retrieval and generation separately, or you will not know which half to fix.
  • RAG suits knowledge that changes or is private; fine-tuning suits behaviour, style and format.

Frequently asked questions

Does RAG stop a model from hallucinating?

No, RAG reduces hallucination but does not remove it. A model can still ignore the retrieved passages, blend them with what it remembers, or answer confidently when retrieval returned nothing relevant. Instructing the model to answer only from the context, allowing it to say it does not know, and measuring faithfulness all help.

Do you always need a vector database for RAG?

No. Retrieval can use keyword search, a relational database with a vector extension, or a small in-memory index for a few thousand passages. A dedicated vector database earns its place when the collection is large, updates are frequent or you need metadata filtering at scale. Many systems combine keyword and vector search.

What is the difference between RAG and semantic search?

Semantic search finds passages by meaning and returns them to the user. RAG uses a search step, often semantic, and then has a language model write an answer from the passages found. Semantic search is one component of RAG; the generation step and the prompt that joins them are the rest.

Is a model with a very large context window a replacement for RAG?

Not usually. Placing an entire document collection in the prompt costs more per request, responds more slowly and can make the model miss details buried in the middle. Retrieval also handles access control and freshness. Large contexts do make RAG easier, because you can pass longer passages and worry less about chunk boundaries.

What should a RAG project show to impress an interviewer?

An evaluation. Anyone can connect a document loader to a model. A project that includes a set of test questions, measures retrieval and answer quality separately, and shows one change that improved a number demonstrates the skill the job needs. Honest notes on where the system still fails add credibility.

The GCC Engineer editorial team

Researched and reviewed by the team behind the GCC roadmap

Published 13 November 2026 · Updated 13 November 2026

On this page

  1. Why do LLM applications need RAG?
  2. How does a RAG pipeline work?
  3. How should you chunk documents for RAG?
  4. What are retrieval and re-ranking?
  5. How do you evaluate a RAG system?
  6. What are the common RAG failure modes?
  7. When should you use RAG instead of fine-tuning?
  8. What do interviews ask about RAG?

Read next

All 10 guides: Skills and roadmap
  • Skills and roadmapStart here

    AI engineer roadmap: what to learn and in what order

    An AI engineer roadmap across eight skill domains: what to learn first, what each role needs, and what you can skip for the job you want.

    6 min read
  • Skills and roadmap

    AI agents explained: tools, loops and when not to use one

    AI agents explained in plain terms: how tool use and the agent loop work, which guardrails matter, and when a fixed workflow is the better choice.

    6 min read
  • Skills and roadmap

    How to evaluate an LLM application

    LLM evaluation in practice: build a golden set, choose metrics, use LLM-as-judge with care, run regression tests and connect offline scores to online results.

    6 min read
  • Interviews

    GenAI interview questions: RAG, agents and evaluation

    Nine representative GenAI interview questions on RAG, agents, evaluation and production, each with the answer outline a strong candidate would give.

    7 min read

Turn this into your own plan

Answer a few questions and get a roadmap built around your target role and where you are now.

Get started free

The GCC Engineer

The end-to-end AI engineering career roadmap for GCCs in India.

Explore

  • Companies
  • Roles
  • Guides
  • The blueprint
  • The GCC growth story

Tools

  • Resume Evaluate
  • Readiness check
  • Your roadmap

Company

  • Pricing
  • Contact

The GCC report

How fast India's GCCs are growing, where they hire and what makes a role there different.

Read the report
© 2026 The GCC Engineer
  • Privacy
  • Terms
  • Refunds
  • Delivery
  • Contact