BXUP Track progress & test yourself — free
AI at Work · Common Core · ~14 min read
AI AT WORK · COMMON CORE

RAG Literacy: How AI Grounds Itself in Your Data

Ask AI about your own wiki, tickets or contracts and it answers from nothing. This module explains retrieval-augmented generation end to end — the seven pipeline stages, what each one decides, the failure signatures you can spot as a user, and the access-control questions to ask.

Ask a frontier model about your company's leave policy, last quarter's incident postmortems, or the config conventions in your monorepo, and it will answer fluently — from nothing. The model was trained on the public internet up to some cutoff date; it has never seen your wiki, your tickets, or your contracts. Retrieval-Augmented Generation (RAG) is the industry's standard fix: fetch the relevant pieces of your data at question time, put them in front of the model, and instruct it to answer from those pieces — with citations. Nearly every "chat with our docs," "AI knowledge base," and "ask the codebase" product you'll touch this decade is RAG under the hood.

Key Takeaway:

RAG doesn't make the model smarter — it changes what the model reads before it answers. Every RAG system is a search engine bolted to an LLM, and almost every RAG failure is a search failure wearing an AI costume.

Why RAG Is in Two-Thirds of Applied-LLM Job Ads

Our Phase 1 employer research (2025–26 postings analysis) found RAG named in roughly 65% of applied-LLM job listings — making it the single most common applied-AI requirement after general API skills. And the postings aren't vague: data-engineering listings now spell out RAG sub-skills verbatim — "chunking strategy," "embedding selection," "hybrid search," "reranking," "RAGAS evaluation" — while "vector databases" has become boilerplate on par with SQL. Cloud-architect postings ask for RAG designs on managed stacks (AWS Bedrock Knowledge Bases, pgvector on Aurora); security postings ask about "securing RAG against data poisoning"; PM interview loops probe RAG-versus-fine-tuning trade-offs.

The reach matters as much as the number. Even if you never build a retrieval pipeline, you will almost certainly operate, evaluate, secure, or make decisions about one: the support engineer running a KB chatbot, the QA lead testing whether answers are grounded, the analyst deciding whether the sales team can trust the contract-search tool, the EM approving the budget for it. That's why this module targets literacy depth — enough to reason about every stage and catch failures — while the role tracks (data engineering, DS/ML, architecture) go implementation-deep.

The Retrieval Mental Model, End to End

Every RAG system, from a weekend project to an enterprise deployment, is the same seven-stage pipeline. The first four run offline when documents are added; the last three run online for every question.

OFFLINE (indexing)                    ONLINE (per query)
1. Ingest    — collect & clean docs   5. Retrieve  — find candidate chunks
2. Chunk     — split into pieces      6. Rerank    — reorder by true relevance
3. Embed     — pieces → vectors       7. Generate  — LLM answers from chunks,
4. Store     — vectors + text in DB                  with citations

Walk one question through it. You ask an internal bot: "What's our on-call compensation policy?" The system embeds your question into a vector, searches the vector store for the chunks whose vectors sit closest to it (likely paragraphs from an HR PDF and a 2024 policy update page), optionally reranks those candidates so the truly relevant ones come first, then builds a prompt roughly shaped like: "Using only the following excerpts, answer the user's question. Cite which excerpt supports each claim." The model writes the answer; the UI shows it with source links.

Two properties fall out of this design and explain most of what you'll observe in practice:

  • The model only sees what retrieval surfacesif the right paragraph isn't in the top handful of chunks, the model either says "I don't know" (good) or improvises (bad), no matter how capable it is.
  • Freshness is an indexing property, not a model propertythe bot knows the new policy the moment the index is updated, and keeps confidently citing the old one until it is.

What Each Stage Decides

Each stage embeds design decisions with visible consequences. You don't need to make these decisions yet — you need to recognize their fingerprints.

Ingest and chunk

Documents must be split because embeddings and prompts work on pieces, not 80-page PDFs. Chunking is a trade-off triangle:

  • Too large (whole pages): each chunk mixes topics, its embedding becomes a blurry average, and retrieval precision drops — plus you burn context-window tokens on padding.
  • Too small (single sentences): chunks match precisely but arrive without enough surrounding context for the model to answer from — you get answers that feel cut off mid-thought.
  • Structure-blind (fixed 500-token windows regardless of layout): tables split from their headers, steps 1–3 of a runbook separated from steps 4–6.

Common practice: a few hundred tokens per chunk, 10–20% overlap between neighbors, splitting along document structure (headings, sections) rather than raw character counts, and attaching metadata (source, title, date, access level) to every chunk. A newer refinement worth knowing by name — contextual retrieval — prepends a short generated summary of where the chunk sits in its document ("This excerpt is from the 2026 on-call policy, section 4: compensation") before embedding it, which measurably cuts retrieval misses.

Embed

An embedding model converts text into a vector — a list of numbers positioned so that semantically similar texts land near each other. "On-call pay" and "compensation for after-hours support" share almost no words but sit close in embedding space; that's what makes this better than keyword search alone. Named options employers actually use: OpenAI's text-embedding-3 family, Voyage AI (the provider Anthropic points its customers to), Google's Gemini embedding models, and open-weight models like the BGE/E5 families for self-hosted or data-residency-constrained stacks. They differ in quality, dimension size (storage cost), price, and language coverage.

Remember:

Queries and documents must be embedded with the same model. Swapping or upgrading the embedding model means re-embedding the entire corpus — mixed-model vectors aren't comparable, and the failure is silent: retrieval just quietly gets worse.

Store

The vector database stores chunk vectors and finds nearest neighbors fast. The market splits into dedicated vector DBs — Pinecone (managed), Qdrant, Weaviate, Milvus (open source), Chroma (lightweight, great for prototypes) — and vector extensions to databases you already run, led by pgvector for PostgreSQL.

Note

pgvector is the accessible default for most teams — if your organization already runs Postgres, you get vector search inside the database you already operate, back up, and control access to, with no new vendor. Dedicated vector DBs earn their place at large scale (tens of millions of vectors, high query rates) or for specialized features — not as a reflex.

Pure vector similarity is weak exactly where professionals need strength: exact identifiers. Search "error TLS-4012" or a part number, and semantic search returns conceptually similar chunks while missing the one containing that literal string. Production systems therefore run hybrid search — classic keyword ranking (BM25) and vector similarity in parallel, with the result lists fused (commonly via reciprocal rank fusion). If a RAG tool you use nails concepts but whiffs on ticket numbers and error codes, you've just diagnosed a missing keyword leg.

Rerank

Retrieval optimizes for speed over a huge corpus and returns, say, 20 plausible chunks. A reranker — a slower, more accurate model that reads the query and each chunk together (Cohere Rerank, Voyage rerankers, open-source cross-encoders) — re-scores those 20 and promotes the best 5 into the prompt. It's a cheap quality lever: better final chunks, fewer tokens sent to the LLM, no re-indexing required.

Generate with citations

The final prompt says, in effect: answer only from these excerpts; cite which excerpt supports each claim; say "not found" if the excerpts don't contain the answer. Citations aren't decoration — they're the verification hook. An answer that cites chunk 3 lets you click chunk 3 and check; an uncited answer from a RAG system deserves the same skepticism as an uncited claim from a stranger.

RAG vs Long Context vs Fine-Tuning

RAG is one of three ways to get your knowledge into a model, and "which one" is now a standard interview question across roles.

ApproachWhat it doesBest whenWatch out
RAGRetrieves relevant pieces at query timeLarge/changing corpora, freshness matters, citations and per-user access control neededYou're now operating a search system; quality depends on retrieval
Long contextPastes entire documents into the prompt (1M-token windows make this real)Corpus is small and stable — a handful of docs, a single contract review, one codebase questionYou re-pay those input tokens every call; recall degrades on huge stuffed prompts; no access control story
Fine-tuningTrains the model's weights on your examplesTeaching behavior — style, format, domain jargon, tool patternsTerrible at facts: knowledge bakes in stale, no citations, no per-user permissions; re-training per update
Exam Tip

The clean heuristic assessors look for — fine-tuning teaches a model how to behave; RAG tells it what is true right now; long context is RAG-without-retrieval for corpora small enough to paste. "Our product docs change weekly and answers need citations" is a RAG answer, not a fine-tuning answer.

These combine: a fine-tuned model for tone, RAG for facts, long context for the one meeting transcript pasted into today's session.

Failure Modes — and How to Spot Them as a User

You will spend more time using RAG systems than building them. These five failure signatures are what literacy is for.

  1. Retrieval miss dressed as hallucination. The answer is fluent and wrong because the right chunk never reached the model. Tell: citations point to plausible-but-irrelevant documents, or there are no citations at all. Probe: ask the question using the exact vocabulary of the source document — if the answer snaps into focus, retrieval (not the model) was the weak link.
  2. Bad chunking. Answers that start mid-procedure, tables summarized without their headers, "step 4" advice with no steps 1–3. Tell: open a cited chunk and find it begins or ends mid-sentence. This is an indexing configuration problem — report it; no amount of prompt cleverness on your end fixes it.
  3. Stale index. The system confidently cites the superseded policy, the old price list, the deprecated API. Tell: cited sources carry old dates while you know a newer version exists. Always check the date on citations, not just their existence — and find out the re-indexing cadence of any RAG tool you rely on.
  4. Poisoned or wrong sources. The index ingested something it shouldn't have: an outdated draft, a random Confluence sandbox page — or, adversarially, content planted so retrieval will surface attacker-written instructions to the model (data poisoning, now named explicitly in security job postings). A related trap: retrieved text that contains instructions ("ignore previous rules and...") can act as an indirect prompt injection. Tell: an answer citing a source that surprises you is a red flag worth escalating, not shrugging off.
  5. Lost or fabricated citations. The prose is right but citations point to the wrong chunk — or the model invented a source label that doesn't exist in the retrieved set. Dangerous because citations are your trust anchor; spot-check them occasionally even when answers look good.
Pro Tip

The two cheapest probes for any RAG system you're handed — ask something you can verify and click through the citation; then ask something you know isn't in the corpus and see whether it says "not found" or improvises. A system that can't say "I don't know" can't be trusted when it "knows."

Evaluating Groundedness

The property that separates a trustworthy RAG system from a fluent one is faithfulness (also called groundedness): is every claim in the answer actually supported by the retrieved chunks? Note what this doesn't ask — whether the answer is true in the world, only whether it's backed by the sources shown. A faithful answer from a stale index is faithfully wrong; that's why faithfulness and index freshness are separate checks.

Practitioner evaluation splits RAG quality into stage-shaped questions: did retrieval find the relevant chunks (context recall/precision)? Is the answer supported by them (faithfulness)? Does it actually address the question (answer relevance)? Frameworks like RAGAS — named verbatim in data-engineering job postings — score these automatically over test-question sets, typically using an LLM as the judge. At literacy level, the takeaway is the decomposition itself: when a RAG system disappoints, ask which stage failed before asking which model to blame. Module cc-6 turns this idea into a general evaluation discipline.

Privacy and Access Control

RAG creates a new data surface, and the most common serious mistake is treating the vector index as a harmless cache.

  • ACLs must propagate to retrieval. If HR documents are restricted in SharePoint but embedded into a shared index, the chatbot becomes a permissions bypass: anyone who can ask can retrieve. Retrieval must filter by the requesting user's permissions (metadata filters, per-tenant collections, or row-level security — a genuine argument for pgvector, where Postgres access controls already exist) at query time, every query.
  • Embeddings are data, not encryption. Vectors can be partially inverted back toward their source text and their metadata is often plaintext. A vector DB holding embedded client contracts is confidential infrastructure — same residency, retention, and access rules as the documents themselves. For India-based services companies this is contractual: embedding client data into a third-party managed vector service may violate the same clauses as uploading the raw files, which is why self-hosted stacks (pgvector, Qdrant, local embedding models) keep appearing in that context.
  • Deletion must reach the index. "Right to be forgotten" and document-retention obligations apply to chunks and vectors, not just source files. Ask any RAG vendor how deletion propagates and how long it takes.
Warning

Before piloting any "chat with our documents" tool at work, get three questions answered — who can retrieve what (do source permissions carry over?), where do embeddings live (whose infrastructure, which region?), and what happens on deletion? A RAG deployment that can't answer all three is a data-leak incident on a timer.

Hands-On: Build a Tiny RAG Over Your Own Notes

Nothing builds the mental model like watching your own documents flow through the pipeline. Two free paths — do at least one; doing both teaches you what the no-code tools hide.

Variant 1 — No-code: NotebookLM (10 minutes)

Google's NotebookLM (notebooklm.google, free tier) is a polished RAG system in a box. Create a notebook, upload 5–10 of your own documents — meeting notes, a project README, exported wiki pages — and ask questions. Every answer carries inline citations that jump to the exact source passage. You're watching stages 5–7 (retrieve, rerank, generate-with-citations) through a UI, with Google operating stages 1–4 invisibly. Use real work-adjacent documents (nothing confidential) so the failure modes have stakes.

Variant 2 — Local open-source: Ollama + Chroma (~40 lines, $0)

The build-it path runs entirely on your laptop — no API key, no data leaving the machine. Install Ollama, pull one chat model and one embedding model (ollama pull llama3.2 and ollama pull nomic-embed-text), then pip install ollama chromadb:

import ollama, chromadb, glob

# OFFLINE: ingest → chunk → embed → store
db = chromadb.Client().create_collection("notes")
for path in glob.glob("notes/*.md"):
    text = open(path).read()
    chunks = [text[i:i+1200] for i in range(0, len(text), 1000)]  # ~1200 chars, 200 overlap
    for j, chunk in enumerate(chunks):
        vec = ollama.embed(model="nomic-embed-text", input=chunk)["embeddings"][0]
        db.add(ids=[f"{path}-{j}"], embeddings=[vec],
               documents=[chunk], metadatas=[{"source": path}])

# ONLINE: retrieve → generate with citations
question = "What did we decide about the deployment schedule?"
qvec = ollama.embed(model="nomic-embed-text", input=question)["embeddings"][0]
hits = db.query(query_embeddings=[qvec], n_results=4)

context = "\n\n".join(f"[{m['source']}]\n{d}"
                      for d, m in zip(hits["documents"][0], hits["metadatas"][0]))
answer = ollama.chat(model="llama3.2", messages=[{
    "role": "user",
    "content": f"Answer ONLY from these excerpts, citing [source] for each claim. "
               f"If the answer isn't in them, say so.\n\n{context}\n\nQuestion: {question}"
}])
print(answer["message"]["content"])

That's a complete RAG system minus reranking and hybrid search — which is exactly the point: you now know precisely which stages a "minimal" system skips, and where production systems spend their added complexity.

Exercises

  1. Grounding vs. memory. In either variant, ask a question your documents answer, then the same question with the documents removed (or in a plain chat session). Write down the difference in specificity and confidence — that gap is what RAG buys.
  2. Trigger three failure modes. (a) Stale index: edit a fact in one source note but don't re-index; ask about it and catch the outdated citation. (b) Retrieval miss: ask about something using vocabulary completely different from your notes, then rephrase using the note's own words — compare. (c) Absent knowledge: ask something your corpus can't answer and record whether the system admits it or improvises.
  3. Chunking experiment (Variant 2). Re-run indexing with chunk sizes of ~300 and ~3000 characters. Ask the same five questions under each. Which failure signatures from this module appear at each extreme?
  4. Groundedness spot-check. Take any five cited answers from your system (or NotebookLM). For each claim, mark Supported / Not in cited source / Contradicted, by reading the cited passage. Compute your faithfulness rate — you've just run a manual version of what cc-6 automates.
  5. Access-control thought experiment. List three document sets at your workplace that must never land in a shared index, and for one real or hypothetical internal chatbot, write the two questions you'd ask its owner about permission propagation and deletion.

Key Takeaways

  • RAG = retrieve your data at question time, then generate from it with citations; it changes what the model reads, not what the model knows.
  • The seven stages — ingest, chunk, embed, store, retrieve, rerank, generate — each carry decisions (chunk size, embedding model, pgvector-vs-dedicated-DB, hybrid search, reranking) whose fingerprints you can now recognize.
  • The model only sees what retrieval surfaces, and freshness lives in the index — most "AI is wrong" complaints about RAG systems are search or staleness problems.
  • Fine-tuning teaches behavior, RAG supplies current facts with citations, long context is for small stable corpora — and they compose.
  • As a user: click citations, check their dates, ask unanswerable questions on purpose, and treat surprising sources as escalations.
  • Faithfulness — every claim supported by the retrieved sources — is the measurable core of RAG trust, and evaluating it per-stage (RAGAS-style) beats blaming the model.
  • The vector index is real data: source ACLs must filter retrieval per-user, embeddings deserve the same governance as the documents, and deletion must propagate.

Further Reading

This is the free reading view. Open BXUP to track your progress, run the hands-on labs, and prove it with original, exam-pattern assessments.
© Anvi Innovate · BXUP — Be Exponentially Upskilled · BXUP is an independent learning platform, not affiliated with or endorsed by AWS, Microsoft, Google, NVIDIA, IBM, Salesforce, Databricks, Oracle or Anthropic. All trademarks belong to their respective owners. · bxup.in