Concept-Anchored Decoding: Ontology-Triggered Attention Steering for Faithful Domain RAG

When a language model answers a medical question from retrieved documents, the most dangerous errors are rarely wrong grammar or bad transitions. They are wrong things: a drug that appears nowhere in the evidence, a dose taken from the donor rather than the patient, a guideline that does not exist. This proposal treats those domain concepts as the unit of grounding. A medical ontology (a curated dictionary of terms, synonyms, and parent–child relations such as UMLS) is used to detect, during generation, the moments when the model is about to emit a domain concept. Only at those moments, the model's attention is pushed toward retrieved sentences that contain a compatible concept, and its internal parametric memory is pushed down. If no compatible concept exists anywhere in the evidence, the model hedges or abstains. Everywhere else, the model writes freely.

In two sentences: retrieval-augmented generation (RAG, where a model answers from passages fetched at query time) mostly fails by inventing unsupported content rather than contradicting the evidence, and in specialist domains that content is usually a nameable concept. We therefore steer the model hard but sparsely, only at ontology-detected concept positions, using a passage→sentence attention hierarchy. The goal is to get the faithfulness of copy-the-source methods without their rigidity.

Core Claim

Three findings in the literature point to this design. RAGTruth, a large span-annotated corpus of RAG outputs, found that models are far more prone to adding baseless information than to contradicting the source. Those additions also cluster toward the end of responses. ReDeEP, a mechanistic study of RAG hallucination, found that in roughly 65–77% of hallucinations the attention heads that copy from context did look at the right tokens. Deeper feed-forward layers then overwrote that signal with pretrained knowledge. Its inference-time fix, AARF, boosts copying heads and damps those feed-forward layers, but it does so uniformly and needs manual tuning. CopyPasteLLM showed that training models to copy source text sharply improves counterfactual faithfulness. Its authors acknowledge that the copy bias produces awkward or wrong output when the context is incomplete.

Our claim is that uniform steering and uniform copying are both too blunt. A domain lexicon tells us cheaply and precisely where faithfulness matters most. Steering only at concept positions, toward sentence-level evidence that is compatible under the ontology, should cut concept-level hallucination at least as much as global steering or copy training. It should also preserve abstractive connective text and give a principled abstention path when evidence is missing.

The ReDeEP finding also constrains us. Because attention is often already correct, better routing alone cannot be the whole fix. The intervention must combine routing with suppression of parametric override, and the experiments must separate the two.

Mechanism

Concept trigger. Domain dictionaries have long been used to repair how specialist text is segmented, for example in clinical part-of-speech tagging (High-Performance Tagging on Medical Texts) and biological lexicon tagging (Three BioNLP Tools Powered by a Biological Lexicon). We reuse that idea at decoding time. UMLS surface forms are compiled into a prefix tree over the generator's own subword vocabulary. A step $t$ counts as a concept position if any of the model's top-$k$ next tokens begins or continues a lexicon entry. The retrieved evidence is mapped to concepts with MetaMap, following Bhattarai et al.. Each concept is expanded to its synonyms and ancestors, so a paraphrase like "beta blocker" can be anchored to a sentence mentioning "metoprolol".

Hierarchical gating. Landmark Attention multiplies token attention by the attention given to the token's parent block. DHSA routes at chunk level before selecting tokens. Both learn these blocks over arbitrary or statistically detected spans and need training per backbone. We apply a training-free version over a structure we already have, retrieved passage → sentence → token. At a concept position $t$, the attention weight $a_{tj}$ from the current token to context token $j$ in copying heads is reweighted as

$$a'_{tj} \propto a_{tj}\cdot g_t\big(s(j)\big), \qquad g_t(s)=\begin{cases}\lambda & s \text{ contains a concept compatible with the candidate}\\ \epsilon & \text{otherwise,}\end{cases}$$

Here $s(j)$ is the sentence containing token $j$, $\lambda>1$ boosts compatible sentences, and $\epsilon<1$ damps the rest. The weights are renormalized afterward. At the same positions, feed-forward contributions in the layers ReDeEP identifies are scaled down. At non-concept positions the model runs unmodified.

Abstention. If no retrieved sentence contains a concept compatible with any concept-starting candidate, the decoder is restricted to an abstention or hedge continuation instead of naming the concept. This is the fallback CopyPasteLLM lacks.

Calibration. The settings $\lambda$, $\epsilon$, and the feed-forward scale are selected once per backbone on a small development split and then frozen. This reduces AARF's per-task manual tuning to a single small search.

Relation to Prior Work

Several systems inject domain structure, but all of them flatten it into prompt text read by an unmodified model. Bhattarai et al. put UMLS medication concepts into GPT-4 prompts and report F1 gains of 4% on n2c2 and 12% on ADE. Li et al. align LLM-mined rules with SNOMED-based guidelines and still report persistent hallucinations. HiRAG builds a hierarchical knowledge graph, at large indexing cost. We use the ontology differently: as a trigger and compatibility test inside decoding, not as more prompt tokens.

Structure-aware retrieval work makes retrieval structural but leaves generation untouched. SAKI-RAG links chunks through sentence-level attention and loses recall on the medical corpus NFCORPUS because its filter misreads terminology. EBCAR separates within-document from cross-document attention when reranking. Our sentence gating spans all retrieved passages at generation time, which sidesteps SAKI-RAG's single-document limit.

ReDeEP and CopyPasteLLM supply the core method we build on: steer copying heads and feed-forward layers, and anchor on source text. We make both conditional on ontology-detected concept positions.

Research Program

The method is implemented on LLaMA-2-7B, where ReDeEP's copying-head and feed-forward localization exists, and on Llama-3.1-8B to test transfer. Head localization is rerun with ReDeEP's procedure on the second model.

The analysis has two parts. The first is a mechanistic one that answers ReDeEP's open question for domain text. At medical concept positions where the model hallucinates, we measure ReDeEP's two diagnostics. The external-context score asks whether copying heads attended to a compatible sentence. The parametric-knowledge score asks whether feed-forward override dominated. This tells us whether domain hallucinations are mainly routing failures or override failures, and so which half of the intervention matters.

The second part is the decoding study below. Hallucinated outputs are labeled into four types: baseless concept, role or entity swap, unsupported overconfidence (Tang et al.), and non-concept errors. The method should help with the first two and is not expected to help with the last.

Baselines

The naive reference is vanilla RAG with the same retriever and passages and unmodified greedy decoding, plus a no-retrieval closed-book run. Every other method is measured against these.

The simplest serious competitor, and the biggest threat, is a post-hoc ontology string-match filter. MetaMap is run on both output and evidence, and any response containing a concept absent from the evidence (after synonym and ancestor expansion) is flagged and regenerated or replaced with an abstention. It uses exactly our lexicon and expansion, so it isolates whether intervening inside decoding adds anything. Beating it means lower concept-level hallucination at equal or better answer accuracy on answerable items, with the gain concentrated on role swaps, where a concept is present in the evidence but taken from the wrong sentence.

The strongest detection-and-filtering competitor is the RAGTruth fine-tuned Llama-2-13B critic. It reports 78.7% response-level F1 and a 63.2% hallucination-rate reduction for Llama-2-7B through candidate filtering. We run it with the same number of sampled candidates our method's compute budget allows. On detection, the external comparison point is ReDeEP's reported chunk-level AUC of 0.7458 on RAGTruth with LLaMA2-7B, against 0.7290 for RAGAS. Our concept-position diagnostic is scored on the same split.

The strongest mitigation competitors are global AARF and CopyPasteLLM. AARF gets the same development-split tuning budget as our three parameters. CopyPasteLLM is trained with the released code (CopyPasteLLM repository) on its 365-pair recipe, using the same base model. Its reported 92.8% on FaithEval, against 47.5% for GPT-4o, is the bar on counterfactual robustness. We do not expect to exceed it there. Instead, we must match it within a few points while beating it on incomplete-context items and fluency.

The domain-prompting competitor is UMLS concepts in the prompt, following Bhattarai et al.

The ablations isolate the key ingredient. The first applies the same steering at random positions matched in count, testing whether the ontology trigger matters. The second applies it at all positions, which approximates global steering under our gate. The third removes sentence gating and keeps only feed-forward suppression. The fourth removes feed-forward suppression and keeps only gating. The fifth replaces ontology compatibility with exact string match.

Why not just…?

Why not just match ontology concepts post hoc and filter? This may well capture most of the baseless-concept gains, since RAGTruth says baseless additions dominate. It cannot see role swaps, because the swapped concept is in the evidence. It also discards whole responses rather than repairing the one concept. The baseline comparison is designed to settle this. If the filter ties us on all four error types, the honest conclusion is that the lexicon, not the attention steering, does the work. The paper would then report that result.

Why not just apply AARF everywhere, or train with CopyPasteLLM? Both treat every token as equally risky. CopyPasteLLM's own authors flag failures on incomplete context. Global feed-forward damping should hurt the abstractive synthesis that HiRAG shows matters for knowledge-intensive questions. The random-position and all-position ablations, plus incomplete-context splits, test whether sparsity buys fluency and abstention without losing faithfulness.

Why not just put UMLS concepts in the prompt? It helps extraction by 4–12% F1 in Bhattarai et al.. However, it had to be restricted to medications because of prompt length. It also does nothing about the feed-forward override ReDeEP identifies, since the model can read the concept and still overwrite it. It is run as a baseline and is also composable with our method.

Why not just use a 128K-context model or a stronger judge? Long flat contexts dilute attention and are what DHSA exists to avoid. Judges themselves fall for traps: MHB reports a 29.1% hallucination rate for Claude-4-Sonnet and 59.0% for Llama-4-Scout. A judge baseline is included through the RAGTruth critic.

Proposed Experiments

Data. Faithfulness is measured on RAGTruth, FaithEval, and ConFiQA. For RAGTruth, the trigger lexicon falls back to named entities and numbers, which makes it the out-of-domain check. Domain performance is measured on PubMedQA, PubMedQA, and on the Medical Hallucination Benchmark. For PubMedQA, the reported reference points are 68.1% accuracy for fine-tuned BioBERT and 78.0% for humans (PubMedQA). For MHB, we use the PMC-Patients-based report items as the retrieved context and score with its physician-validated rubrics. Its open-source models exceed 57% hallucination. Extraction transfer is tested on n2c2 and ADE.

Scoring. New generations lack gold span labels. Concept-level hallucination is therefore scored by the RAGTruth critic, plus a stratified human-annotated sample of 300 responses per domain labeled with our four-way error taxonomy. Answer accuracy is reported only on answerable items, and abstention rate is reported separately, so a method cannot win by refusing.

Decisive checks. There are three. The first: on MHB and PubMedQA, our method must lower concept-level hallucination below both the string-match filter and global AARF at no loss in answerable-item accuracy. The second: on items where we delete the gold evidence sentence, it must abstain where CopyPasteLLM fabricates or forces quotes. The third: the random-position ablation must lose most of the gain. If the third fails, the ontology trigger is not doing the work and the central claim is false.