Papers › Toward Faithful Retrieval-Augmented Generation with Sparse Autoencoders

Toward Faithful Retrieval-Augmented Generation with Sparse Autoencoders

9 Dec 2025ICLRarXiv:2512.08892added by Syntology

Guangzhi Xiong, Zhenghao He, Bohan Liu, Sanchit Sinha, Aidong Zhang

Title, abstract, authors and date from arXiv's metadata (CC0); this paper is not in the Papers with Code archive (frozen 2025-07-28).

Retrieval-Augmented Generation (RAG) improves the factuality of large language models (LLMs) by grounding outputs in retrieved evidence, but faithfulness failures, where generations contradict or extend beyond the provided sources, remain a critical challenge. Existing hallucination detection methods for RAG often rely either on large-scale detector training, which requires substantial annotated data, or on querying external LLM judges, which leads to high inference costs. Although some approaches attempt to leverage internal representations of LLMs for hallucination detection, their accuracy remains limited. Motivated by recent advances in mechanistic interpretability, we employ sparse autoencoders (SAEs) to disentangle internal activations, successfully identifying features that are specifically triggered during RAG hallucinations. Building on a systematic pipeline of information-based feature selection and additive feature modeling, we introduce RAGLens, a lightweight hallucination detector that accurately flags unfaithful RAG outputs using LLM internal representations. RAGLens not only achieves superior detection performance compared to existing methods, but also provides interpretable rationales for its decisions, enabling effective post-hoc mitigation of unfaithful RAG. Finally, we justify our design choices and reveal new insights into the distribution of hallucination-related signals within LLMs. The code is available at https://github.com/Teddy-XiongGZ/RAGLens.

PaperPDFCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2512.08892")

Code

Syntology Ran 0 of 11 code samples harvested from 1 repository linked to this paper; 11 have no recorded run.

By repository: found in paper text by Syntology: 11 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Teddy-XiongGZ/RAGLens found in paper text by Syntology report

Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

11 samples harvested; 0 ran; 0 honoured the contract we drafted; 11 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

11unverified

Licence: 11 of the 11 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from Teddy-XiongGZ/RAGLens. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

chunk_and_tokenize Teddy-XiongGZ/RAGLens/src/sparsify/data.py found in paper text by Syntology unverified no licence file found · pointer only · 3fafa18bde72510f · report
compute_mutual_information_chunked Teddy-XiongGZ/RAGLens/src/utils.py found in paper text by Syntology unverified no licence file found · pointer only · 6f785f3051233faf · report
compute_mutual_information_vectorized Teddy-XiongGZ/RAGLens/src/utils.py found in paper text by Syntology unverified no licence file found · pointer only · a03ff408b1a15b33 · report
encode_output_tokens Teddy-XiongGZ/RAGLens/src/sae_encoding.py found in paper text by Syntology unverified no licence file found · pointer only · 89cccd0c9373114f · report
encode_outputs Teddy-XiongGZ/RAGLens/src/sae_encoding.py found in paper text by Syntology unverified no licence file found · pointer only · 1fea12f6a78298c9 · report
fused_encoder Teddy-XiongGZ/RAGLens/src/sparsify/fused_encoder.py found in paper text by Syntology unverified no licence file found · pointer only · c839c072b645f3c8 · report
get_columns_all_equal Teddy-XiongGZ/RAGLens/src/sparsify/data.py found in paper text by Syntology unverified no licence file found · pointer only · b44a86959a6f33aa · report
hf_generator Teddy-XiongGZ/RAGLens/src/mitigation.py found in paper text by Syntology unverified no licence file found · pointer only · 88eb5c5724c378e5 · report
quintic_newtonschulz Teddy-XiongGZ/RAGLens/src/sparsify/muon.py found in paper text by Syntology unverified no licence file found · pointer only · 1930bbdc2f82dc62 · report
sae_encoding Teddy-XiongGZ/RAGLens/src/sae_encoding.py found in paper text by Syntology unverified no licence file found · pointer only · 251669896aaca2f6 · report
vllm_generator Teddy-XiongGZ/RAGLens/src/mitigation.py found in paper text by Syntology unverified no licence file found · pointer only · f867e8883cc4f7c1 · report

Results from the paper

The Papers with Code archive ends with its 2025-07-28 snapshot. This paper's arXiv identifier, 2512.08892, was issued in December 2025, after that date, so the archive has no leaderboard rows for it.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections