SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2512.08892 · ICLR · 2025

Toward Faithful Retrieval-Augmented Generation with Sparse Autoencoders

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

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 7 failures of our instrument; 3 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2512.08892.json · badge: /api/ran/2512.08892.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Teddy-XiongGZ/RAGLens canonical (classifier label)
classifier basis: census
8 ran · 3 no recorded run
FunctionStatusWhere it lives
compute_mutual_information_chunked Ran
ran; our contract draft was wrong, not the code
Teddy-XiongGZ/RAGLens/src/utils.py
pointer only (licence: NONE) · get_code("6f785f3051233faf")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

compute_mutual_information_vectorized Ran
ran; our contract draft was wrong, not the code
Teddy-XiongGZ/RAGLens/src/utils.py
pointer only (licence: NONE) · get_code("a03ff408b1a15b33")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

encode_outputs Ran
ran on a synthesized input
Teddy-XiongGZ/RAGLens/src/sae_encoding.py
pointer only (licence: NONE) · get_code("1fea12f6a78298c9")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

fused_encoder Ran
ran; our contract draft was wrong, not the code
Teddy-XiongGZ/RAGLens/src/sparsify/fused_encoder.py
pointer only (licence: NONE) · get_code("c839c072b645f3c8")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_columns_all_equal Ran
ran; our contract draft was wrong, not the code
Teddy-XiongGZ/RAGLens/src/sparsify/data.py
pointer only (licence: NONE) · get_code("b44a86959a6f33aa")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

hf_generator Ran
ran; our contract draft was wrong, not the code
Teddy-XiongGZ/RAGLens/src/mitigation.py
pointer only (licence: NONE) · get_code("88eb5c5724c378e5")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

quintic_newtonschulz Ran
ran; our contract draft was wrong, not the code
Teddy-XiongGZ/RAGLens/src/sparsify/muon.py
pointer only (licence: NONE) · get_code("1930bbdc2f82dc62")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

sae_encoding Ran
ran; our contract draft was wrong, not the code
Teddy-XiongGZ/RAGLens/src/sae_encoding.py
pointer only (licence: NONE) · get_code("251669896aaca2f6")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

chunk_and_tokenize Not yet run
unverified (harvested, no recorded run)
Teddy-XiongGZ/RAGLens/src/sparsify/data.py
pointer only (licence: NONE) · get_code("3fafa18bde72510f")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

encode_output_tokens Not yet run
unverified (harvested, no recorded run)
Teddy-XiongGZ/RAGLens/src/sae_encoding.py
pointer only (licence: NONE) · get_code("89cccd0c9373114f")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

vllm_generator Not yet run
unverified (harvested, no recorded run)
Teddy-XiongGZ/RAGLens/src/mitigation.py
pointer only (licence: NONE) · get_code("f867e8883cc4f7c1")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Teddy-XiongGZ/RAGLens when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 0 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
get_columns_all_equal 4 other papers
4 dated earlier
2303.08112 (2023-03)
Eliciting Latent Predictions from Transformers with the Tuned Lens
2406.04093 (2024-06)
Scaling and evaluating sparse autoencoders
2410.16090 (2024-10)
Analysing the Residual Stream of Language Models Under Knowledge Conflicts
and 1 more not named here
chunk_and_tokenize 3 other papers
3 dated earlier
2406.04093 (2024-06)
Scaling and evaluating sparse autoencoders
2410.16090 (2024-10)
Analysing the Residual Stream of Language Models Under Knowledge Conflicts
2501.18823 (2025-01)
Transcoders Beat Sparse Autoencoders for Interpretability
fused_encoder 2 other papers
2 dated earlier
2406.04093 (2024-06)
Scaling and evaluating sparse autoencoders
2501.18823 (2025-01)
Transcoders Beat Sparse Autoencoders for Interpretability
quintic_newtonschulz 2 other papers
2 dated earlier
2406.04093 (2024-06)
Scaling and evaluating sparse autoencoders
2501.18823 (2025-01)
Transcoders Beat Sparse Autoencoders for Interpretability

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2512.08892")
get_code_for_paper("2512.08892")
have("2512.08892")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2512.08892.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2512.08892.svg)](https://syntology.ai/paper/2512.08892)

Connect an agent — have() is free.