Chiosa
AI & Agents

Attention statistics can be extracted without storing full matrices

FlashAttention with Statistics: Low-Overhead Attention Features for Compact Hallucination Detectors · arXiv:2610.21483

3 min
Updated
Cost of extracting all implemented attention statistics for hallucination detection in every layer of Qwen3-8B and Qwen3-0.6B using our kernels. Top: model forward-pass latency. Bottom: relative…
Cost of extracting all implemented attention statistics for hallucination detection in every layer of Qwen3-8B and Qwen3-0.6B using our kernels. Top: model forward-pass latency. Bottom: relative overhead compared with the same forward using standard scaled dot-product attention…Figure 1 · FlashAttention with Statistics: Low-Overhead Attention Features for Compact Hallucination Detectors · Andrei Volodichev et al. · CC BY 4.0

In plain words

The paper builds a way to collect clues from a language model’s attention without saving a huge table of all attention weights. A separate, frozen Qwen3 model reads a context, question, and answer, then a trained classifier uses those clues to judge whether the answer is supported by the context.

In one reported setup, collecting statistics for five detectors added less relative time to a Qwen3-8B model’s forward pass on longer inputs than on shorter ones. The detector checks support from the supplied context, not general truth.

The research

A detector of unsupported answers may need to inspect a model different from the one that wrote them, because the writer may not expose its internal workings.

Can a separate model use attention clues to check whether an answer fits its supplied context, and can those clues be collected without storing a huge attention matrix?

The paper adds an attention-statistics method and Triton backend that avoids storing full attention matrices, then tests proxy detectors for contextual support.

Can a detector check whether an answer fits its supplied context when the model that wrote it cannot be inspected? The paper tests a separate frozen Qwen3 proxy, which reads the context, question, and answer and uses a trained classifier to predict whether the context supports it.

Across three datasets, the authors compare classifiers with and without attention features and compare proxy detectors with prompted judges. A 4B proxy exceeded the strongest evaluated judge in test F1 on two datasets, while a 0.6B proxy did so on the third. F1 balances caught unsupported answers against false alarms.

These results cover the tested datasets, Qwen3 proxies, judges, and implementation. The proxy assesses support by the supplied context, and two implemented statistics differ from their published definitions; those versions were not compared in detection.

What the evidence shows

  • Check support from context

    The paper presents an attention-statistics extraction method and Triton backend, then tests frozen Qwen3 proxy models as detectors of unsupported answers. A proxy reads the context, question, and completed answer, so it can assess whether the context supports an answer written by another model.

    This addresses a practical measurement gap in the task: the answer's original writer need not expose its internal workings. The detector's target is contextual support, not general factual truth.

  • Test whether features help

    The authors evaluate on RAGTruth QA, HaluBench, and TRIVIA+, datasets that test whether an answer is supported by its supplied context. They report test F1, a score balancing how many flagged answers are unsupported with how many unsupported answers are caught.

    For feature-addition tests, they compare trained classifiers with and without attention features across four proxy sizes and three datasets, using test groups and a correction for multiple comparisons.

  • Attention helps in some pairs

    After that correction, adding attention features significantly improved F1 in 6 of the 12 dataset–proxy pairs, and none of the tested additions significantly lowered it. The result supports a limited conclusion: attention features can add useful information to other proxy signals, but the gains were not significant in every tested pair.

    The authors also report that attention-only feature sets often performed well, though those sets differ in feature count and coverage.

  • Compare against prompted judges

    The authors compare proxy detectors with nine prompted language-model judges on the same three test sets. A 4B proxy had higher test F1 than the strongest evaluated judge on HaluBench and TRIVIA+, while a 0.6B proxy did so on RAGTruth QA.

    This is a comparison of complete approaches, which use different models and decision procedures; it does not show that model size alone explains the differences.

  • Measure cost and scope

    Separately, the authors measure the cost of extracting statistics for five published detectors. For Qwen3-8B on an H100 NVL at batch one, extraction added 16% latency at 2K tokens and 1.4% at 35K, relative to the same forward without statistics.

    The result varies with input length and model size. The implementation also computes a complete response in one call, and two features use restricted definitions that were not compared with the published versions.

Deep

Next paperA language model grows exact answers by checking new code