Single logo
  • Courses
  • Blog
  • About
Join free on SkoolJoin free on Skool

In this topic

AI Engineering
  • The AI Stack in One Picture: Six Layers Every AI Product Is Built From
  • Tokenization: What an LLM Actually Sees When You Type
  • LLM Tokens, Context Windows and Cost: What One Question Really Costs
  • What an LLM Can and Cannot Do: One Prediction Loop, Its Strengths and Its Gaps
  • Structured LLM Output with Pydantic: Describe the Shape Once, Check Every Reply
  • Temperature, Top-p and Sampling: Why the Same Prompt Gives a Different Answer
  • Open vs Closed LLMs: Cost, Control, Privacy and Capability, Decided per Workload
  • Streaming and Error Handling for LLM Calls: Show the First Word Early, Retry Politely, Fail Calmly
  • Practice: Build a CLI Chat Tool with Memory, Commands, Error Handling and a History Cap
  • Explicit Criteria vs Vague Prompts: Turn Every Adjective Into a Check a Script Can Run
  • Few-Shot Prompting Done Right: How Many Examples, How Different, What Order, and the Leak That Lies
  • Prompt Caching: Keep the Start of Every Request Identical and Pay for the Long Part Once
  • Prompt Versioning and Testing in a Repo: Prompt Files, a Registry, a Hash per Answer and Tests That Gate
  • Context Engineering: What Belongs in the Context Window, Turn by Turn
  • Context Engineering for a Long-Running Agent: Clear, Compact, Take Notes, Prove It
  • What an Embedding Actually Is: Meaning as Numbers, Search by Closeness, and Where Hand-Made Numbers Break
  • The RAG Pipeline Explained: 7 Stages From Documents to a Cited Answer
  • Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
  • Why RAG Exists: The Problem It Solves, Compared With Pasting Everything and Fine-Tuning
  • Real Embedding Models: an Open Model or a Provider API, Then Search, Duplicates and Recommendations
  • Chunking Strategies for RAG: Fixed Size, Sentences or Headings, Measured on One Handbook
  • Vector Databases Hands-On: The Same Search in Chroma and pgvector
  • RAG Prompt Assembly and Citations: Number the Blocks, Fit a Token Budget, Check Every Claim
  • Hybrid Search: BM25 Plus Dense Embeddings, Merged With Reciprocal Rank Fusion
  • Reranking With a Cross-Encoder: When the Second Pass Helps, and When It Doesn't
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Choosing a Vector Index: Flat, HNSW or IVF-PQ, a Memory Estimate, and Filters That Starve Small Customers
  • Citations and Abstention in RAG: What a Citation Proves, and When the Right Answer Is "It's Not in the Documents"
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Cosine, Dot Product or Euclidean Distance: Why Three Measures Pick Three Winners, and the One Fix
  • Choosing an Embedding Model: Dimension, Context Length, Domain and Cost, Tested on Your Own Questions
  • Loading and Parsing Real Documents for RAG: PDF Headers, Wrapped Lines, Tables and HTML Chrome, Scored
  • Where Naive RAG Fails: Five Ways the Simplest Retriever Hands the Model the Wrong Pages
  • RAG Generation Metrics: Faithfulness, Groundedness and Relevance, One Claim at a Time
  • Context Engineering for a Long-Running Agent: Clear, Compact, Take Notes, Prove It
  • What LangChain Is For, and When to Skip It: Five Standard Parts, One Pipe, and a Decision Table
  • Why Chains Break: No Branch, No Retry, No Pause, and the Same Refund Assistant as a LangGraph Graph
  • LangGraph Nodes, Edges and State: Build Your First Graph, Route With a Conditional Edge, and Read the Run Three Ways
  • Human-in-the-Loop and Checkpointing in LangGraph: interrupt, a SQLite Save Slot and Command(resume=...)
  • Multi-Agent Patterns: Hub and Spoke in LangGraph, With Short Briefs, Owned Tools and a Retry the Hub Decides
  • A Research Agent in LangGraph: Plan, Search, Read, Write, and a Check Node That Rejects Citations Nobody Read
  • From ML Metrics to LLM Evals: Same Ruler, New Targets
  • Why You Cannot Ship an LLM Feature Without an Eval: Five Parts, Three Graders, One Tiny Eval
  • Building a Golden Dataset for LLM Evals: Cases, a Schema, a Coverage Table and a Seeded Split
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Regression Testing an LLM Bot in CI: A Golden Set, Two pytest Gates and GitHub Actions
  • Testing a RAG Bot Before It Ships: Slices, a Release Gate per Slice, and the Week After
  • RAG Generation Metrics: Faithfulness, Groundedness and Relevance, One Claim at a Time
  • LLM-as-Judge: Write a Rubric, Check Every Verdict, and Trust the Grader Only After Kappa Says So
  • RAGAS and Custom Evals: Framework Faithfulness Plus Your Own Citation and Required-Fact Checks, Behind One Gate
  • Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
  • Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
  • Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
  • A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
  • Caching for AI Apps: Four Layers, What Goes in Each Key, and How a Delete Travels
  • Semantic Caching: Why a Similarity Threshold Can't Stop Confident Wrong Answers
  • LLM Model Routing: Rules, a Classifier or a Cascade, Judged on Cost per Win and Every Topic
  • Cutting p95 and Cost in Half for an LLM App: Read the Bill, Match the Lever, Guard Success
  • Observability and Tracing for LLM Apps: A Span per Stage, Redaction First, Bad Traces Become Tests
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Design a Multi-Tenant RAG Assistant, Part 1: Requirements, Rough Numbers and a Contract
  • Design a Multi-Tenant RAG Assistant, Part 2: Tenant Isolation, a Scoped Cache and Walking an Outage
  • A 500 MB PDF Takes 50 s to Answer, Get It to 2 s: Measure First, Then Promise Per Path
  • A 500 MB PDF From 50 s to 2 s, the Fast Path: Queue, Status, Streaming and an Acceptance Test That Fails
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  1. Blog
  2. /
  3. AI Engineering
  4. /
  5. Retrieval and RAG

Citations and Abstention in RAG: What a Citation Proves, and When the Right Answer Is "It's Not in the Documents"

In a small simulation, 6 of 7 wrong answers carried a neat citation. A floor at 0.30 makes the bot refuse "Who founded the company?" (top score 0.13), but a made-up code ERR-4141 scores 0.39 and gets a wrong, cited answer until an evidence check refuses it. Plus format, registry and support checks, and a human-labelled set with slices.

Chaand Sheikh

·27 November 2026Retrieval and RAG

What you will learn

  • Explain why a neat citation shows which page was used, not that the answer is right
  • Make a RAG bot refuse with a similarity floor plus an evidence check
  • Separate three citation checks: format, registry and support
  • Measure citations and refusals with a human-labelled golden set, a holdout and slices

Before you start

  • The RAG Pipeline Explained
  • RAG Prompt Assembly and Citations

The interview version: your assistant answers from PDFs with page numbers, and a user finds a cited page that doesn't back up the claim. What do you do? Most people say "we validate the citations with a pattern check". That checks the wrong thing.

A strong answer has two halves. A citation must be well formed, point to a real, current source, and that page must support the claim. And when nothing in the documents supports an answer, the right move is to abstain: refuse. Numbers here come from a small simulation, with synthetic pages and a simulated writer, so no model wrote anything.

Neat and wrong

We set up seven failures and got seven wrong answers. Six of the seven carried a citation, and each one was neat. Two of them:

Q: What is the refund policy?          (simulated)
A: Refund policy, version 1. Customers may ask for a refund within 30 days of purchase. [refunds-v1 p.3]

Q: Who founded the company?            (simulated)
A: To claim a warranty repair, send the order number and a photo of the fault to the repair desk. [warranty p.6]

The first page exists, and it's been replaced: version 2 says 14 days. The second quotes a warranty page with nothing about any founder. A citation tells you which page was used. It doesn't tell you that page was the right one.

When it isn't there: a floor

Sometimes the correct answer is "it's not in the documents". For "Who founded the company?", the top similarity is only 0.13, because no page says. So add a floor: below it, the bot says I can't find that in the documents. In this small set the floor is 0.30, and that value suits this set only.

A floor catches one absent answer and misses the other floor 0.30 founder? 0.13: refuses ERR-4141? 0.39: passes the floor Bar length is the top similarity. Simulated, synthetic pages.
A near match can pass the floor. That's why a floor needs a second check.

Now ask about ERR-4141, a code that doesn't exist. Similarity is 0.39, above the floor, because ERR-4147 looks almost the same:

Q: What does ERR-4141 mean?            (simulated, floor only)
A: Error ERR-4147 means the export job ran out of disk space. Free some space and retry. [errors p.12]

Well formed, real and current, and wrong.

The evidence check

The fix is an evidence check: the exact code in the question has to appear in the pages we retrieved. ERR-4141 doesn't, so the bot refuses:

absent-code: What does ERR-4141 mean?      (simulated)
  before: abstention ['E6', 'E3']
  after : ok         []
    I can't find that in the documents.

Watch the other side, too. A strict floor refuses good questions. Set yours on your own labelled questions, and treat a wrong refusal as a failure just like a wrong answer.

Three checks on a citation

Back to the citation itself. A legal brief puts a footnote on every claim. A junior checks the footnote is written correctly; that's useful, and that's all it tells you. So the lawyer opens the book: does the case exist, and is it current? Then she reads the page: does it say what the brief claims?

Format, registry, support 1 Format looks like doc + page pass 2 Registry page exists, current pass (catches old v1) 3 Support page says 14, not 30 fail For illustration: a claim of "30 days" citing refunds v2, p.3. The first two are cheap. Only the third says the claim is true.
A made-up claim against the synthetic refund pages, not from this run.
  • Format. A pattern check confirms it looks like a document and a page. That's all a regex can ever prove.
  • Registry. A list of every document, its versions and its pages. Does this page exist, and is it current? This is the check that catches the old version 1.
  • Support. Split the answer into claims, and ask of each one: does this page say this? It's the hard one.

How to number blocks and build a checker for missing and unsupported citations is covered step by step in RAG Prompt Assembly and Citations. No registry or claim-level checker ran in this simulation.

Who checks the checker

Measure all of this with a golden set: questions with known answers, labelled by people. For each question, the right page, the claims that page supports, or that it should refuse.

  • Why humans? A model used as a judge can score a plausible wrong answer as correct. Check the judge against human labels before you trust it. No judge model ran here, so there's no judge number.
  • Keep a holdout. If you set the floor on the same questions you score on, the result flatters you.
  • Slice it. For illustration: answerable, not in the documents, exact codes, old versions. A good average can hide a bot that never refuses.

For building that set, see Building a Golden Dataset.

The follow-ups

  • Your regex check passes. Are the citations right? Not necessarily. It proves the format, never the support.
  • How does it refuse when the score looks fine? A floor plus an evidence check, because a near match can pass the floor.
  • Can a model grade your citations? Yes, once you've checked it against human labels, on questions it didn't tune on.
LevelWhat it sounds like
Weak"We show citations, so it's grounded."
OkayChecks format and source, and adds a similarity floor.
StrongChecks support claim by claim, uses human labels, and treats a refusal as a correct result.

Recap

IdeaRemember
CitationsShow which page was used, not that it's right (6 of 7 wrong answers were cited, simulated)
Three checksFormat, registry, support; only support says it's true
RefusalA floor (0.30 here, this set only) plus an evidence check
MeasurementHuman labels, a holdout, and slices that include "should refuse"

Try it yourself

Next time a chatbot gives you a citation, open the page and check whether it really says that. Then ask it something you know isn't in its documents, and see whether it refuses.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in AI Engineering · 28 of 66

Previous
Choosing a Vector Index: Flat, HNSW or IVF-PQ, a Memory Estimate, and Filters That Starve Small Customers
Next post
Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag

Related course on Udemy

Machine Learning Engineer: From First Model to ML Engineer

Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)

Related posts

What an Embedding Actually Is: Meaning as Numbers, Search by Closeness, and Where Hand-Made Numbers Break

A customer types "I cannot log in" and keyword search finds nothing, although a password-reset article exists. Turn meaning into numbers by hand, find the nearest point with math.dist, build a three-topic toy embedder that finds the right article at 1.00, and watch it score 0.00 on "I can't get into my account".

The RAG Pipeline Explained: 7 Stages From Documents to a Cited Answer

Ingest, chunk, embed, store, retrieve, rerank and generate, in one Python file. Follow one question through a 26-chunk employee handbook to an answer that cites its source.

Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors

Ask one question of a whole collection of vectors: which items are closest to this one? Normalise, score every row with one matrix multiply, keep the top k or everything above a threshold, and check it with NearestNeighbors.

Why RAG Exists: The Problem It Solves, Compared With Pasting Everything and Fine-Tuning

A smart model has never read your company's files, and they change every month. Three ways to give it the facts: paste everything, fine-tune, or retrieve only the right pieces. Follow a refund-policy question through all three and see why RAG wins when documents change.

On this page

  • Neat and wrong
  • When it isn't there: a floor
  • The evidence check
  • Three checks on a citation
  • Who checks the checker
  • The follow-ups
  • Recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Machine Learning Engineer: From First Model to ML Engineer

Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.