Skip to content

Chapter 5 · Knowledge Conflicts and Faithfulness


5.1 Parametric vs Contextual Knowledge ★★

Two sources of knowledge

Parametric knowledge Contextual knowledge
Where it lives In the model weights, learned during pretraining and finetuning In the prompt: retrieved documents, user input, dialogue history, tool outputs
How to update it Retrain, finetune or edit the weights (slow, expensive) Change the input (instant, cheap)
Coverage Broad but frozen at the training cutoff; weak on long-tail facts Only what is retrieved or provided; can be fresh and private
Verifiable? No explicit source Can be traced back to a specific document
Typical failure Hallucination, outdated facts Retrieval noise, misinformation, missing information

An LLM can draw on two kinds of knowledge when answering. Parametric knowledge is knowledge "memorized" into the weights during pretraining, such as "Paris is the capital of France", generally thought to be stored mainly in the FFNs (see LLM Basic Chapter 1, §1.6). It is broad and always available, but it has three hard limits: it is frozen at the training cutoff; it remembers long-tail facts poorly; and it can't name a source, so it can't be verified. Contextual knowledge is information placed in the prompt at inference time, including retrieved documents, material from the user, dialogue history and tool results. It can be updated at any time, can include private data, and can be traced to a specific source, which is exactly why RAG exists.

RAG's basic assumption is that the model should prefer the knowledge in its context. But the two kinds of knowledge don't always agree. When a retrieved document says "the CEO of company X is A" while the model remembers B, whom should the model believe? If the document is up to date, it should believe the document; if the document is a wrong web page, it should trust its memory, or at least point out the contradiction. This chapter is about exactly these questions: what models do when the two kinds of knowledge conflict, what they should do, and how to make their answers faithful to the evidence.

Interview questions

  • ★★ What are parametric and contextual knowledge, and what are the pros and cons of each?

The ideal behavior: controllability and robustness ★★

Li et al. (2022) sum up the ideal behavior as two requirements:

  • Controllability: when the context is relevant to the task and conflicts with the model's memory, the model should go with the context. That way we can correct the model's answer just by changing the input, without retraining.
  • Robustness: when the context is irrelevant to the task, the model should ignore it and fall back on its own knowledge, without being led astray by irrelevant content.

There is tension between these two requirements. Controllability asks the model to "listen to the context", while robustness asks it "not to listen to everything". A model that always trusts the context scores perfectly on controllability, but a single wrong document can lead it astray; a model that always trusts its memory is robust, but can't be corrected with new information. So the true ideal is neither "always trust the context" nor "always trust memory" but conditional trust: deciding how much to trust based on whether the context is relevant, whether it is credible, and how strongly it conflicts with memory. When the evidence is insufficient or a conflict can't be resolved, the model should also say so or abstain (see 5.6). This idea runs through the whole chapter.

Interview questions

  • ★★ When a retrieved document conflicts with the model's memory, which should the model believe?
  • ★ What are controllability and robustness, and why are they in tension?

5.2 Types of Knowledge Conflict ★★

Type Definition Example Main causes
Context–memory Contextual knowledge contradicts parametric knowledge Retrieved text says the CEO is A; the model remembers B Temporal misalignment (outdated training data); misinformation in the context
Inter-context Pieces of contextual knowledge contradict each other Two retrieved documents give different release dates Misinformation (including LLM-generated); outdated documents with different timestamps
Intra-memory The model's own knowledge is inconsistent Paraphrased versions of the same question get different answers Noisy or biased pretraining data; sampling-based decoding; knowledge edits that don't generalize

The survey by Xu et al. (2024) divides knowledge conflicts into three types, and this taxonomy is now widely used.

Context–memory conflict is the most central type in RAG: the context and the model's memory disagree. It has two main sources. One is temporal misalignment: the model's knowledge stops at its training cutoff while the world keeps changing, so information in new documents naturally conflicts with old memories. This kind of conflict is a good thing; it is exactly the problem RAG is meant to solve, and the model should trust the context. The other is misinformation pollution: the retrieved documents or user input are themselves wrong, or even deliberately planted. Here the model should stick with its memory, or at least point out the contradiction. The difficulty is that, on the surface, the model can hardly tell these two cases apart.

Inter-context conflict is when retrieved documents contradict each other, for example one says the product launched in March and another says May. The cause may be misinformation (including content generated by LLMs that has spread online), or documents written at different times, each correct when written. This type of conflict requires the model to notice the contradiction and compare the sources' credibility and dates, rather than simply going with the first document or the majority.

Intra-memory conflict is when the model's own knowledge is inconsistent: ask the same question a different way and you get a different answer. The causes include contradictory or wrong content already present in the pretraining corpus, randomness from sampling-based decoding, and knowledge edits that change only some phrasings without generalizing consistently to others. This type is less directly tied to RAG, but it shows that the model's parametric knowledge is not a stable, consistent "database" in the first place.

Interview questions

  • ★★ What are the types of knowledge conflict, and what causes each?
  • ★ In a context–memory conflict, when should the model trust the context and when its memory?

How each type is addressed ★

For context–memory conflict, the survey summarizes several directions. If the goal is to be faithful to the context, one can use finetuning, prompting, context-aware decoding (see 5.8) and similar methods. If the context might be wrong, one needs to discriminate misinformation, for example by training a discriminator or augmenting the query. Another approach is to disentangle the sources, having the model give both "the answer according to the documents" and "the answer from memory", and leave the judgment to the user or a downstream step. For inter-context conflict, the main directions are detecting contradictions (with dedicated contradiction-detection models or external tools) and improving robustness (training the model to pick out the reliable parts among contradictory documents). For intra-memory conflict, the main directions are improving consistency (e.g. finetuning with a consistency loss, or ensembling several outputs) and improving factuality (e.g. DoLa, a decoding method that contrasts outputs from different layers, or intervening on internal representations at inference time).

Interview questions

  • ★ What are the main ways to address each of the three types of knowledge conflict?

5.3 Model Behavior Under Conflict ★★

On "whom does the model trust in a conflict", earlier and more recent studies reached seemingly opposite conclusions: some found models over-rely on memory, others found they over-rely on context. The two findings don't actually contradict each other; which one shows up depends on the form of the evidence, the size of the model and how popular the knowledge is.

Over-reliance on memory ★★

\[\mathrm{MR} = \frac{p_o}{p_o + p_s}\]

Longpre et al. (2021) were the first to study this systematically. Their approach was entity substitution: replace the answer entity in the retrieved passage with another entity of the same type (e.g. replace every "Obama" in the text with "Bush"), creating a context that conflicts with the model's memory, and see what the model outputs. The formula above is their memorization ratio: \(p_o\) is the fraction of outputs that give the original answer (the one in memory), and \(p_s\) is the fraction that give the substituted answer (the one in the context). The higher the MR, the more the model ignores the context and sticks to its memory.

On T5 generative readers they found three things:

  1. Models often ignore the context. Even when the passage states the substituted answer, the model frequently outputs the original one, at rates up to 75% on NewsQA. This is really a form of hallucination: the output can't be found anywhere in the given context.
  2. Larger models rely on memory more. From T5-small to T5-XXL, the memorization ratio on the training set and in-distribution dev set rose from under 15% to at least 50%, with no sign of leveling off. The reason is that larger models remember more, and more firmly.
  3. Worse retrieval during training means more reliance on memory. If the passages given during training often don't contain the answer, the model learns that "passages are unreliable, better rely on myself", and at inference it also tends to ignore the passage.

Their mitigation is simple: add entity-substituted examples to the training data, so the model sees cases of "when context and memory disagree, follow the context". The memorization ratio dropped to nearly 0, and out-of-distribution accuracy improved by 4–7 points. This kind of counterfactual data augmentation later became one of the standard ways to improve context faithfulness (see 5.8).

Interview questions

  • ★★ Why do models sometimes ignore the context and stick to their memory?
  • ★ How do model size and retrieval quality during training affect reliance on memory?

Over-reliance on context ★★

Later studies of instruction-tuned models like ChatGPT and GPT-4 reached almost the opposite conclusion. Xie et al. (2023) found that conflicting evidence built by entity substitution often fails because it is incoherent: a few words are swapped mechanically, the surrounding text often no longer fits, the model can sense that something is off, and so it sticks to its memory. But if an LLM generates coherent, convincing counter-memory evidence, such as a logically fluent, detailed explanation that simply reaches a different conclusion, the model accepts it very readily, even when it directly contradicts the model's memory.

ClashEval (Wu et al. 2024) tested this in a setting closer to RAG: retrieved content was perturbed from subtle to blatant errors, and across six leading models including GPT-4o, the models adopted the incorrect retrieved content more than 60% of the time, overriding their own originally correct knowledge.

The consequences are serious: when a RAG system faces retrieval noise, outdated web pages or even deliberately planted false documents, the model treats wrong content as fact and states it confidently. In other words, a well-written wrong document influences the model more than a poorly written correct one.

Interview questions

  • ★★ Early studies said models over-rely on memory, later ones said they over-rely on context. How do you reconcile these?
  • ★ How do you build test data for knowledge conflicts, and what are the problems with entity substitution versus LLM-generated counter-memory evidence?

Confirmation bias, popularity, quantity and order ★

Xie et al. (2023) also identified several factors that affect the model's choice:

  • Confirmation bias. When evidence both for and against its memory is given at the same time, the model strongly favors the piece that agrees with its memory, most clearly so for GPT-4. That is, given only counter-memory evidence, the model is easily persuaded; but as soon as one piece of evidence agrees with its memory, it holds on to that piece.
  • Popularity. The more popular the entity, the more the model sticks to its memory. On the most popular questions, GPT-4 stuck to its memory about 80% of the time. The reason is intuitive: popular facts appear many times in pretraining, so the model's "belief" is stronger. This echoes the finding of Mallen et al. (2022) in Chapter 4, §4.2: for popular facts, retrieval brings more risk than benefit.
  • Quantity. The model tends to side with whichever answer has more supporting documents, roughly "majority rules". This is dangerous when several documents conflict: the same piece of misinformation copied by several websites can outweigh one authoritative source.
  • Order. Apart from GPT-4, which is relatively stable, models are sensitive to the order of the evidence; some favor evidence that appears first, others favor what appears later. Order shouldn't affect factual judgment, which shows the model isn't really "weighing the evidence". (This relates to the "lost in the middle" effect, where models use information in the middle of a long context poorly; Liu et al. 2023.)

Interview questions

  • ★ What is confirmation bias, and how does it affect RAG?
  • ★ Why is a piece of misinformation more dangerous once it has been copied by several websites?

A unified view ★★

These seemingly scattered phenomena can be unified with one framework: the model's choice depends on a contest between prior strength and evidence persuasiveness. Prior strength is how confident the model is in its memory, shaped by entity popularity, model size and how often it saw the fact in training; evidence persuasiveness depends on whether the evidence is coherent, whether several pieces corroborate each other, and how far it deviates from memory. ClashEval's two findings correspond exactly to the two ends: the less confident the model is in its initial answer (the lower its token probability), the more likely it is to adopt the retrieved content; the more outlandish the retrieved content (the further it is from the truth), the less likely it is to be adopted.

This framework explains the earlier contradiction: Longpre's entity-substituted evidence is incoherent and weakly persuasive while large models have strong priors, so they appear to rely on memory; Xie's generated evidence is coherent and highly persuasive, so models appear to rely on context.

The problem is that this contest has nothing to do with whether the evidence is correct. The model compares "how sure am I" with "how true does this text sound", not "which source is more credible". That's exactly why extra mechanisms are needed: source credibility, contradiction detection and abstention.

Interview questions

  • ★★ What factors decide whether a model trusts the context or its memory in a conflict?

5.4 Faithfulness vs Factuality ★★

The two concepts

\[\mathrm{Faith}(y, c) = \frac{1}{|A(y)|} \sum_{a \in A(y)} \mathbb{1}\big[c \models a\big], \qquad \mathrm{Fact}(y) = \frac{1}{|A(y)|} \sum_{a \in A(y)} \mathbb{1}\big[\mathcal{K} \models a\big]\]

These two concepts are often confused, but they measure different things. Faithfulness asks: is the answer supported by the given context? Factuality asks: does the answer match the facts of the real world? The formula above shows a common way to measure them: split the answer \(y\) into atomic claims \(A(y)\), and check for each claim \(a\) whether it is entailed. Faithfulness checks whether the context \(c\) entails it (\(c \models a\)); factuality checks whether world knowledge \(\mathcal{K}\) (such as Wikipedia or a reliable knowledge base) entails it. \(\mathbb{1}[\cdot]\) is the indicator function, equal to 1 when the condition holds.

This distinction was first discussed systematically in summarization. Maynez et al. (2020) divided hallucinations in summaries into two kinds: intrinsic hallucination distorts information in the source, such as getting a name or number from the source wrong; extrinsic hallucination adds information that isn't in the source. Extrinsic hallucinations aren't necessarily wrong: the model may add a true background fact from memory. Such content is factual but not faithful. They also found that metrics based on textual entailment (NLI) reflect faithfulness better than overlap metrics such as ROUGE, which is why most automatic faithfulness evaluation today (including the RAG metrics in Chapter 7) is based on NLI or LLM judgments.

Interview questions

  • ★★ What is the difference between faithfulness and factuality?
  • ★ What are intrinsic and extrinsic hallucinations, and is an extrinsic hallucination always wrong?
  • ★ How can faithfulness be evaluated automatically?

When they disagree ★★

Factual Not factual
Faithful Ideal: grounded and true Context is wrong or outdated, and the model faithfully repeats it
Not faithful Model adds a true fact from memory that the context doesn't contain Hallucination: neither in the context nor true

There are two main ways they can disagree, matching the two off-diagonal cells of the table:

  1. Faithful but not factual. The context itself is wrong (an outdated web page, misinformation), and the model dutifully repeats it. By faithfulness it did well; by factuality it is wrong.
  2. Factual but not faithful. The context doesn't contain the information, and the model adds a sentence from memory that happens to be correct. By factuality there's no problem, but the user can't verify it through the cited documents, and the same behavior becomes a hallucination whenever the model misremembers.

So which should RAG optimize? In most settings, RAG's primary goal is faithfulness. The reason is that a faithful answer can be verified: every sentence traces back to some document, and when something goes wrong you can locate whether retrieval or generation was at fault. Users often choose RAG precisely because they want answers with sources. This is even more true for enterprise knowledge bases, law and medicine: the answer must be based on the given documents, even if the model "thinks" it knows more. But faithfulness alone isn't enough either: if the context is wrong, faithfully repeating the error is just as harmful. So an ideal system stays faithful to the evidence while also spotting obvious errors in it, and flags it to the user when the evidence conflicts with common knowledge (back to the "conditional trust" of 5.1).

Interview questions

  • ★★ Give an example of an answer that is faithful but not factual, and one that is factual but not faithful.
  • ★★ Should a RAG system prioritize faithfulness or factuality, and why?

5.5 Robustness to Noisy and Misleading Retrieval ★★

Kinds of noise

Noise type What it looks like Why it is harmful
Irrelevant Off-topic passages with no connection to the question Wastes context; can distract weaker models
Distracting (related but unhelpful) On-topic passages that don't contain the answer, e.g. about a similar entity Looks relevant, so the model is tempted to extract an answer from it
Counterfactual / misinformation Passages that state a wrong answer fluently The model may adopt it over correct memory (see 5.3)
Conflicting Several passages that disagree with each other The model may follow order or majority rather than credibility
Adversarial Passages deliberately crafted or planted to steer the answer Targeted attacks on the retrieval corpus (knowledge poisoning)

The top-k returned by a retriever can't all be useful. Ordered roughly from least to most harmful, noise falls into the categories in the table above. Intuitively, completely irrelevant documents are the easiest for the model to ignore and do the least damage; the most dangerous are documents that look relevant, because the model tries hard to "find" an answer in them. (There are also poisoning attacks aimed specifically at the retrieval corpus; that is a security topic and isn't expanded here.)

Interview questions

  • ★★ What kinds of retrieval noise are there, which is most harmful, and why?

Empirical findings ★★

Several studies characterize the impact of noise from different angles:

  1. Related but unhelpful documents hurt more than random ones. Cuconasu et al. (2024) found that highly ranked documents that are on topic but don't contain the answer clearly lower LLM accuracy; counter-intuitively, adding completely random documents to the prompt can actually raise accuracy (they report gains of up to 35%). This shows that "relevant according to the retriever" and "useful for generation" are different things, and that optimizing only the retriever's relevance metrics isn't enough.
  2. In multi-hop reasoning, irrelevant documents cause cascading errors. Yoran et al. (2023) analyzed when retrieval actually lowers accuracy on five open-domain QA benchmarks, and pointed out that the problem is especially serious in multi-hop reasoning: once one step misuses irrelevant evidence, every later step builds on that error, which compounds (cascading errors).
  3. The more irrelevant documents, the worse the filtering. Xie et al. (2023) found that when relevant evidence is present, models can partly ignore irrelevant passages, but this ability weakens as more irrelevant passages are added, and smaller models are hit harder.
  4. The abilities RAG needs are all still lacking. The RGB benchmark (Chen et al. 2023) splits the abilities RAG needs into four: noise robustness (extracting the right information from noisy documents), negative rejection (refusing to answer when no document contains the answer), information integration (combining several documents to answer), and counterfactual robustness (spotting errors in the documents). Tests showed models have some noise robustness but fall clearly short on rejection, integration and spotting misinformation.

Interview questions

  • ★ Why are on-topic documents that don't contain the answer more harmful than completely random ones?
  • ★ What four RAG abilities does the RGB benchmark test?

Improving robustness ★★

Methods for improving robustness can be grouped into three kinds by where they act:

  1. Filter before generation. Use a reranker or an NLI model to screen out irrelevant documents, or, as in CRAG, use an evaluator to judge retrieval quality and refine documents (see Chapter 4). Yoran et al. (2023) tried a simple NLI filter that keeps only passages entailing the question–answer pair. It does prevent performance drops, but it also wrongly removes some useful passages. This is the fundamental trade-off of filtering: the harder you filter, the less noise, but the lower the recall.
  2. Train the model to ignore noise. Deliberately mix irrelevant and distracting documents into the training data so the model learns to find useful information amid noise. Yoran et al. (2023) found that only about 1,000 training examples mixing relevant and irrelevant contexts were enough to make the model robust to irrelevant context while still performing well when the context is relevant. (RAFT and other methods that add distractor documents during training are covered in Chapter 7.)
  3. Have the model assess the evidence before answering. In the prompt or in training, ask the model to first judge, document by document, whether each one is relevant and credible, and then answer based on those judgments; for example, Chain-of-Note (Yu et al. 2023) has the model write a reading note for each document first. One can also add source metadata (website, publication date) to the prompt so the model can compare credibility and recency. The cost of this approach is longer outputs and more latency.

Interview questions

  • ★★ How can a RAG system be made more robust to irrelevant or misleading retrieval results?
  • ★ What is the cost of filtering documents before generation?

5.6 Abstention and Calibration ★★

When should the model say "I don't know"? ★★

In RAG, there are three main situations where the model should abstain:

  1. Neither the context nor memory has the answer. Retrieval found nothing, and the model doesn't know either. Any answer would be made up.
  2. The context is insufficient. The retrieved documents are related to the question but lack a key piece of information. For example, the question asks for 2024 data, and the documents only have 2023 data. The model can easily "patch together" an answer from nearby information; this is exactly the "negative rejection" ability tested in RGB.
  3. The conflict can't be resolved. Several documents contradict each other with no good clues as to which is credible. Here it's better to say there is disagreement and list the different claims than to pick one at random.

Joren et al. (2024) make the second case clearer with the notion of sufficient context: whether the retrieved context contains enough information to answer the question. They found that strong models like Gemini 1.5 Pro, GPT-4o and Claude 3.5 answer well when the context is sufficient, but when it is insufficient they often give a wrong answer instead of abstaining; smaller models often hallucinate or abstain even when the context is sufficient. Another interesting finding is that insufficient context can still sometimes help the model answer correctly, because it may provide partial clues that trigger the model's memory. So "always abstain when the context is insufficient" isn't optimal either.

Abstention has its own cost. Abstaining too little produces hallucinations; abstaining too much makes the model useless, afraid to answer anything (over-refusal). This is fundamentally a trade-off, and it needs calibration to support it.

Interview questions

  • ★★ When should a RAG system abstain?
  • ★ What is "sufficient context", and what do models usually do when the context is insufficient?

Calibration for abstention ★★

The abstention decision relies on a confidence: "how sure am I that I'm right". Calibration is about whether that confidence can be trusted: among all answers given with 80% confidence, are about 80% actually right? (The definition, the ECE measure, why RLHF makes calibration worse, and the ways to get a confidence are covered in LLM Basic Chapter 7 §7.5.) If confidence doesn't match actual accuracy, the abstention threshold can't be set: if the model is equally confident about wrong and right answers, then wherever the threshold is placed, it will block good answers and let bad ones through at the same time.

In RAG, calibration has one more complication than in closed-book QA: how sure the model should be depends not only on whether it "remembers", but also on the context. Given a convincing but wrong document, the model may change its answer and state it just as firmly (see 5.3); given a related document that lacks a key piece of information, strong models still tend to give an answer rather than abstain (Joren et al. 2024, see the previous subsection). So in RAG the model's own confidence isn't enough; it has to be combined with retrieval-side signals that separately judge whether the context is sufficient and credible. The same logic applies to the decision "should I retrieve at all": it essentially asks the model to judge "do I already know this", which also depends on calibration (see Chapter 4, §4.2 and §4.8).

Interview questions

  • ★★ Why does abstention depend on calibration?
  • ★ Why isn't the model's own confidence enough to decide abstention in RAG?

Selective prediction ★

\[\text{output} = \begin{cases} \hat{y}, & \mathrm{conf}(x) \ge \tau \\ \text{abstain}, & \text{otherwise} \end{cases} \qquad \text{coverage}(\tau) = \Pr\big(\mathrm{conf} \ge \tau\big), \quad \text{risk}(\tau) = \Pr\big(\text{wrong} \mid \mathrm{conf} \ge \tau\big)\]

Formalizing abstention gives selective prediction: output the answer \(\hat{y}\) when the confidence \(\mathrm{conf}(x)\) is at least the threshold \(\tau\), otherwise abstain. Coverage is the fraction of questions the model is willing to answer, and risk is the fraction of answered questions that are wrong. Raising \(\tau\) lowers both coverage and risk; lowering it does the opposite. Connecting the (coverage, risk) pairs across all thresholds gives the risk–coverage curve, and lower is better; one can also, as in R-Tuning (see 5.8), rank all answers by confidence and compute average precision (AP). The specific threshold depends on the application: in medicine and law wrong answers are costly, so one should choose low risk and low coverage; a chitchat assistant can tolerate more risk.

In RAG, the confidence can come from the model itself (token probability, verbalized confidence, sample consistency) or from retrieval-side signals, such as whether the context is sufficient and how high the retrieval scores are. Joren et al. (2024) combined a judgment of "is the context sufficient" with model confidence to decide whether to abstain, raising the share of correct answers among the questions answered by 2–10%.

Interview questions

  • ★ What is selective prediction, and how do you evaluate an abstention policy?
  • ★ What goes wrong if a model abstains too often, and how do you strike a balance?

5.7 Attribution and Citation ★★

Why attribution matters ★

Attribution means mapping each claim in an answer to a source that supports it. In RAG, the most common form is adding citation markers like [1] and [2] after sentences. Attribution serves three purposes: first, verifiability: users can open the source and check instead of trusting the model blindly; second, accountability: when something is wrong, you can tell whether the source itself was wrong or the model distorted it; third, constraining generation: requiring a source for every sentence by itself makes the model fabricate less.

AIS (Attributable to Identified Sources), proposed by Rashkin et al. (2021), gives attribution a clear definition: a statement \(s\) is attributable to a source \(P\) if a generic reader, after reading \(P\), would agree that "according to \(P\), \(s\) holds". Note that attribution and correctness are different things: a sentence can be fully supported by its source while the source itself is wrong. Attribution measures faithfulness, not factuality (see 5.4).

Interview questions

  • ★ What is the difference between attribution and correctness?

Ways to generate citations ★★

Approach How it works Pros Cons
In-context citation Number the retrieved passages and instruct the model to cite them inline while answering Simple; no training; citations come from the actual generation process Citations may be wrong or decorative; depends on instruction following
Post-hoc attribution Generate first, then search for evidence for each claim and attach or revise Works with any generator; can also fix unsupported claims Extra retrieval and LLM calls; the answer wasn't actually generated from the cited evidence
Training for citation Finetune or preference-optimize the model to cite correctly and to refuse when unsupported Best citation quality; learns to cite and abstain together Needs labeled or constructed data and training

There are three main ways to generate citations:

  1. In-context citation. Number the retrieved passages, put them in the prompt, and instruct the model to tag each sentence with its source number while answering. The ALCE benchmark (Gao et al. 2023) evaluates models in this setting. It is the simplest and needs no training, but the model may cite the wrong number or add a "decorative" citation: it looks sourced, but the document doesn't actually support the sentence.
  2. Post-hoc attribution. Generate the answer normally first, then find evidence for each claim. For example, RARR (Gao et al. 2022) first generates a set of verification questions about the answer, uses search to find evidence, checks whether the evidence agrees with the answer, revises the answer where it doesn't, and finally attaches an attribution report. Its advantages are that it works with any generator and can fix unsupported content along the way; its downsides are the extra retrieval and call costs, and the fact that the answer wasn't generated from the cited evidence; the citations are added after the fact. ALCE's experiments also found that closed-book generation with post-hoc citations gives good answer correctness but poor citation quality.
  3. Training the model to cite. Use finetuning or preference optimization to teach the model to cite correctly and to abstain when there is no support. Self-RAG's IsSup token is one example (see Chapter 4, §4.5). Trust-Align (Song et al. 2024) builds about 19K preference pairs, using various "bad answers" as negatives: wrong answers, answering an unanswerable question, refusing an answerable one, citing unnecessary documents, and citing documents that don't support the claim. It then trains with DPO and improves both refusals and citation quality on ASQA, QAMPARI and ELI5.

Interview questions

  • ★★ How do RAG systems generate citations, and what are the pros and cons of in-context citation versus post-hoc attribution?

Evaluation: citation recall and precision ★★

\[\text{Citation recall} = \frac{1}{|S|} \sum_{s \in S} \mathrm{rec}(s), \qquad \mathrm{rec}(s) = \mathbb{1}\Big[C_s \neq \emptyset \ \wedge\ \mathrm{NLI}\big(\textstyle\bigoplus_{c \in C_s} c,\ s\big) = \text{entail}\Big]\]
\[\text{Citation precision} = \frac{1}{\sum_s |C_s|} \sum_{s \in S} \sum_{c \in C_s} \mathbb{1}\big[\mathrm{rec}(s) = 1 \ \wedge\ c \text{ is not irrelevant}\big], \qquad c \text{ is irrelevant} \iff \neg\,\mathrm{NLI}(c, s) \ \wedge\ \mathrm{NLI}\big(C_s \setminus \{c\},\ s\big)\]

ALCE (Gao et al. 2023) provides the most widely used citation evaluation, using an NLI model (TRUE, a T5-11B finetuned on NLI data) to judge entailment automatically. \(S\) is the set of all statements in the answer, \(C_s\) is the set of passages cited by statement \(s\), and \(\bigoplus\) means concatenating those passages, and \(\mathrm{rec}(s)\) is the recall score of a single statement.

  • Citation recall measures "does everything that needs a source have enough source": a statement scores 1 if and only if it has at least one citation and the concatenated cited passages entail it. Average over all statements. Low recall means many statements are unsupported.
  • Citation precision measures "is every citation useful": a citation is judged "irrelevant" if and only if it does not entail the statement on its own and the remaining citations still entail the statement without it, i.e. it is redundant. Also, a citation can only score 1 if its statement has a recall score of 1 (the \(\mathrm{rec}(s) = 1\) in the formula): if the citations together can't support the statement, it doesn't matter how "relevant" a single one is. Average over all citations. Low precision means the model is piling on citations.

These two metrics involve the same kind of trade-off as recall and precision in retrieval: citing every document for every sentence gives high recall but very low precision; citing only the single most similar document may give high precision, but many statements won't be fully supported.

Real systems don't do well. Liu et al. (2023) audited generative search engines such as Bing Chat and Perplexity and found that only about 51.5% of sentences were fully supported by their citations, and only about 74.5% of citations actually supported the sentence they were attached to, while the answers read fluently and look informative, which easily gives users false trust. ALCE's experiments also found that on ELI5, even the best-performing models lacked full citation support in about half of their answers.

This evaluation approach has limits too: the NLI judge itself makes mistakes, and is especially unreliable on statements that need multi-step reasoning or arithmetic to derive; it gives only a binary "entailed / not entailed" judgment, so partial support earns nothing: if the citations support only the first half of a statement, that statement's recall is 0; and high citation quality doesn't mean the answer is correct, so it should be read together with correctness metrics.

Interview questions

  • ★★ How do you evaluate citation quality, and how are citation recall and precision computed?
  • ★ Why can't you look at citation recall alone?
  • ★ What are the limitations of automatic citation evaluation?

5.8 Mitigation Approaches ★★

Prompting ★

The simplest approach is to work on the prompt, with no training at all:

  • Explicit instructions. Tell the model "answer only based on the given documents; if the documents don't contain the answer, say it can't be determined from them". This helps somewhat for models that follow instructions well, but models often still mix in their own memory.
  • Opinion-based prompts. Zhou et al. (2023) found that rewriting the context as a narrator's statement and then asking "according to this person, what is the answer?" makes the model more faithful to the context than asking directly. The intuition: when asked "what did Zhang San say", the model no longer has to judge whether the claim is true in the real world, so its memory doesn't interfere. This was among the most effective methods in their experiments.
  • Counterfactual demonstrations. Put a few examples in the few-shot prompt where the context contradicts common knowledge and show answering according to the context, so the model understands that "the context takes priority here".
  • Quote first, separate sources. Ask the model to first extract the passages that support the answer and then answer from them; or have it give both "the answer according to the documents" and "the answer from its own knowledge", showing both when they conflict.

The advantage of prompting is that it costs nothing and works immediately; the downside is that its effect depends on the model's instruction following and is unstable, so it may change with a different model or a different phrasing.

Interview questions

  • ★ What prompting methods can improve a model's faithfulness to the context?
  • ★ Why do opinion-based prompts improve faithfulness?

Context-Aware Decoding (CAD) ★★

\[y_t \sim \mathrm{softmax}\Big[(1 + \alpha)\, \mathrm{logit}_\theta(y_t \mid c, x, y_{<t}) - \alpha\, \mathrm{logit}_\theta(y_t \mid x, y_{<t})\Big]\]
\[\tilde{p}(y_t \mid c, x, y_{<t}) \ \propto\ p_\theta(y_t \mid c, x, y_{<t}) \left(\frac{p_\theta(y_t \mid c, x, y_{<t})}{p_\theta(y_t \mid x, y_{<t})}\right)^{\alpha}\]

CAD (Shi et al. 2023) is a training-free method that only changes decoding. The problem it targets: during generation, the influence of the context and the influence of prior knowledge are mixed together, and when they conflict, the prior often wins. CAD's idea is to separate the two influences and then amplify the context's part.

Concretely, each step runs two forward passes: one with the context \(c\), giving \(\mathrm{logit}_\theta(y_t \mid c, x, y_{<t})\); one without the context, with only the question \(x\), giving \(\mathrm{logit}_\theta(y_t \mid x, y_{<t})\). The latter represents "what the model wanted to say without looking at the documents", i.e. its prior. They are then combined as in the first formula: multiply the with-context logit by \((1+\alpha)\), subtract \(\alpha\) times the no-context logit, and sample after softmax. \(\alpha\) controls how strongly to amplify, and \(\alpha = 0\) is ordinary decoding.

The second formula is the equivalent probability form, which shows more clearly what's going on. The ratio in the brackets is "how many times more likely this token becomes once the context is added", and its log is exactly the pointwise mutual information (PMI) between the context and the token. So CAD multiplies the original distribution by a weight: tokens that the context noticeably raises get amplified further, while tokens that are likely with or without the context (i.e. tokens from the prior) are relatively suppressed.

An example: the context says "In 2023 the prize went to A", but the model remembers B. With the context, A and B may have similar probabilities; without it, B is very likely and A is not. Computing the ratio, A is strongly raised by the context and B isn't, so CAD picks A.

In terms of results, the paper clearly improves faithfulness metrics on summarization (\(\alpha = 0.5\)), e.g. LLaMA-30B's factKB on CNN-DM rises from 76.8 to 87.8; the gains on knowledge-conflict tasks (\(\alpha = 1\)) are larger, e.g. GPT-Neo 20B's EM on NQ-Swap rises from 16.1 to 36.8. The gains on knowledge-conflict tasks also grow with model size, which matches the finding in 5.3: the larger the model, the stronger its prior, and the more it needs suppressing.

CAD's costs and limitations are just as clear:

  1. Two forward passes per step, doubling decoding compute (the no-context pass has a short prompt and can run in parallel, but it still adds cost).
  2. It trusts the context unconditionally. If the context is wrong, CAD amplifies the error and makes the model repeat the misinformation more firmly. So it improves faithfulness, not factuality.
  3. It doesn't suit irrelevant contexts. If the retrieved documents are unrelated to the question and the model should answer from memory, CAD is suppressing that memory. It solves only the controllability of 5.1 while sacrificing robustness.

So CAD fits best where the context is reliable and must take priority, such as summarizing a given document or QA over internal documents. Later work (e.g. AdaCAD, Wang et al. 2024) measures the degree of conflict by the difference (Jensen–Shannon divergence) between the distributions with and without the context, and sets \(\alpha\) adaptively token by token: strong correction when the conflict is large, almost no intervention when it is small, which partly eases the third point.

Interview questions

  • ★★ Explain how context-aware decoding works and write down its formula.
  • ★★ How does CAD relate to PMI?
  • ★ What are CAD's limitations, and when shouldn't it be used?

Training approaches ★

If the model can be trained, its behavior can be changed more fundamentally. By goal, training methods fall roughly into four groups:

  1. Counterfactual data augmentation → controllability. Add training examples where the context conflicts with memory (e.g. the entity substitution of Longpre et al. 2021), labeled with the answer from the context, to teach the model to follow the context in a conflict. KAFT (Li et al. 2022) builds on this by adding counterfactual contexts and irrelevant contexts together: for the former the context takes priority, for the latter the model must ignore the context and answer from its own knowledge. This trains controllability and robustness at the same time and avoids the lopsidedness of training only one side. They also found that these two abilities don't improve automatically as models get bigger; they have to be trained deliberately.
  2. Noise training → robustness. Mix distractor documents into the training contexts so the model learns to pick out useful information amid noise (see 5.5; RAFT and related methods in Chapter 7).
  3. Refusal-aware training → learning to say "I don't know". R-Tuning (Zhang et al. 2023) first has the model answer the training questions; those it gets right go into a "certain set" and those it gets wrong into an "uncertain set". Each example is then followed by the question "Are you sure you accurately answered the question based on your internal knowledge?", labeled "I am sure" for the certain set and "I am unsure" for the uncertain set, and the model is finetuned on this data. The model thus learns to express uncertainty outside its knowledge boundary. The paper also found that this abstention ability transfers to domains unseen in training, like a "meta-skill".
  4. Preference optimization → citations, refusals and correctness together. Build preference pairs of "good answer vs bad answer" and train with DPO (see Post-Training Chapter 3). The key is the design of the negatives: they must cover both "failing to refuse when it should" and "refusing when it shouldn't", or the model easily slides to one extreme. Trust-Align (see 5.7) is designed this way.

The shared risk of these methods is overcorrection. Train only "follow the context" and the model becomes easier to mislead with misinformation; train only refusals and it becomes overly conservative. So the training data must include several opposing situations at once: the context is correct and conflicts with memory (trust the context), the context is irrelevant (ignore it), the context is insufficient (abstain), and the context can answer the question (must answer). What the model must learn is not a fixed leaning but choosing the right behavior based on the state of the evidence.

Interview questions

  • ★★ How can training improve a model's faithfulness to the context?
  • ★ How does R-Tuning build its training data?
  • ★ Why add both counterfactual and irrelevant contexts when training for faithfulness?

Comparing the mitigations ★

Method Targets Training needed Inference cost Main limitation
Prompting (instructions, opinion-based, counterfactual demos) Faithfulness, abstention No ~None Unstable; depends on instruction following
Pre-generation filtering (reranker, NLI, evaluator) Robustness to noise Filter model only Extra scoring calls Lower recall: useful passages get dropped
Context-aware decoding Faithfulness (controllability) No 2 forward passes per step Amplifies wrong context; hurts when context is irrelevant
Counterfactual + irrelevant-context training (e.g. KAFT) Controllability and robustness Yes None Needs constructed data; risk of over-trusting context
Refusal-aware tuning (e.g. R-Tuning) Abstention, calibration Yes None Risk of over-refusal; labels tied to one model's knowledge
Preference optimization (e.g. Trust-Align) Citations, refusals, correctness Yes None Needs careful negative design and NLI-based labels

In practice these methods are complementary, not mutually exclusive: first use filtering to keep noise out of the context, then use a trained model or prompting to answer faithfully and abstain appropriately, and finally use citation evaluation or NLI to check whether the output is supported by the evidence. The choice mainly depends on three things: whether you can train the model, how reliable the context is, and how much the application tolerates wrong answers versus refusals.

Interview questions

  • ★★ If a RAG system often gives answers inconsistent with the retrieved documents, how would you diagnose and fix it?

    First figure out which stage is failing: sample the failure cases and check whether the retrieved documents actually contain the answer. If they don't, it's a retrieval problem: improve retrieval or teach the model to abstain. If they do but the model didn't use it, check whether it was distracted by other noisy documents (stronger filtering, noise training) or stuck to its own memory (counterfactual training, CAD, better prompts). After the fix, monitor faithfulness, accuracy and refusal rate together, so improving one doesn't break another.