Cross-Layer Attention Probing for Fine-Grained Hallucination Detection
Organizations: Robert Gordon University, Aberdeen, United Kingdom · Toyota Motor Europe, Brussels, Belgium
Abstract
With the large-scale adoption of Large Language Models (LLMs) in various applications, there is a growing reliability concern due to their tendency to generate inaccurate text, i.e. hallucinations. In this work, we propose Cross-Layer Attention Probing (CLAP), a novel activation probing technique for hallucination detection, which processes the LLM activations across the entire residual stream as a joint sequence. Our empirical evaluations using five LLMs and three tasks show that CLAP improves hallucination detection compared to baselines on both greedy decoded responses as well as responses sampled at higher temperatures, thus enabling fine-grained detection, i.e. the ability to disambiguate hallucinations and non-hallucinations among different sampled responses to a given prompt. This allows us to propose a detect-then-mitigate strategy using CLAP to reduce hallucinations and improve LLM reliability compared to direct mitigation approaches. Finally, we show that CLAP maintains high reliability even when applied out-of-distribution. Code available at: https://github.com/itsmemala/CLAP
Figures & tables
| LLM | PE | AH-g | LP-g | NLP-g | CLAP-g | AH-s | LP-s | NLP-s | CLAP-s |
| Greedy Test Responses | |||||||||
| Llama 7B | 69.0 | 64.0 | 77.7 | 77.2 | 78.1 | 69.2 | 75.3 | 75.6 | 77.8 |
| Alpaca 7B | 78.6 | 81.2 | 85.2 | 85.8 | 86.6 | 83.6 | 86.3 | 86.4 | 87.3 |
| Vicuna 7B | 80.4 | 78.0 | 88.4 | 88.2 | 88.5 | 85.7 | 88.8 | 88.8 | 88.7 |
| Gemma 2B | 62.8 | 73.5 | 70.2 | 71.2 | 72.7 | 74.1 | 70.1 | 71.6 | 72.7 |
| Llama3.1-I 8B | 69.7 | 66.6 | 66.1 | 66.5 | 68.1 | 67.6 | 67.8 | 68.3 | 69.0 |
| % Non-Hallucinations (NH) | %Abs | %Abs but NH | |||||||
| Data | Def | Def+Abs * | Alt | +CLAP-I | +CLAP-II * | Def+Abs | +CLAP-II | Def+Abs | +CLAP-II |
| L-7B TQA | 57.3 | 75.6 | 48.6 | 56.3 | 71.3 | 36.0 | 26.4 | 9.1 | 5.5 |
| L-7B STR | 60.0 | 69.9 | 64.0 | 65.9 | 67.6 | 45.0 | 7.2 | 21.4 | 3.9 |
| A-7B TQA | 34.2 | 68.3 | 33.8 | 41.9 | 68.1 | 62.7 | 44.2 | 8.7 | 6.3 |
| A-7B STR | 43.4 | 67.0 | 60.5 | 64.8 | 65.2 | 44.3 | 16.1 | 6.1 | 2.6 |
| V-7B TQA | 14.6 | 59.2 | 28.3 | 31.0 | 57.7 | 80.7 | 59.9 | 3.2 | 2.6 |
| LLM | %gain-over-last | %gain-over-MA | %gain-over-MC | %gain-over-MV | %gain-over-SEP |
| Llama 7B | 4.9 | 2.1 | 4.9 | 1.7 | 45.2 |
| Alpaca 7B | 0.9 | 1.4 | 1.1 | 1.3 | 18.0 |
| Vicuna 7B | 5.1 | 1.3 | -1.8 | 5.2 | 35.6 |
| Gemma 2B | 6.3 | 3.6 | 1.4 | 3.8 | 25.1 |
| Llama3.1-I 8B | 2.4 | -1.6 | -2.2 | 5.9 | 15.1 |
| TQA | NQ | STR | TQA | NQ | STR | ||||
| 1 | 128 | 84.3 (0.2) | 86.1 (0.8) | 64.6 (0.7 | 2 | 128 | 84.3 (0.2) | 86.0 (0.8) | 64.5 (0.8) |
| 1 | 256 | 84.3 (0.3) | 86.1 (1.0) | 64.2 (0.8) | 2 | 256 | 84.3 (0.2) | 86.2 (1.0) | 64.7 (0.3) |
| 1 | 512 | 84.2 (0.1) | 86.0 (1.1) | 64.8 (0.8) | 2 | 512 | 84.3 (0.3) | 86.1 (1.1) | 65.1 (0.3) |
| 1 | 1024 | 84.2 (0.4) | 86.0 (0.7) | 64.7 (0.9) | 2 | 1024 | 84.3 (0.5) | 86.3 (0.7) | 65.2 (1.0) |
| 1 | 2048 | 84.1 (0.4) | 85.8 (1.0) | 64.4 (0.5) | 2 | 2048 | 84.4 (0.4) | 86.0 (1.1) | 65.7 (1.2) |
| 1 | 4096* | 83.8 (0.1) | 86.0 (0.9) | 63.6 (0.6) | 2 | 4096* | 83.9 (0.4) | 86.0 (1.0) | 66.7 (1.6) |
| Probe | # Params | In Distribution | Out Of Distribution | ||||
| TQA | NQ | TQA-¿City | NQ-¿City | ||||
| Maxpool | - | 4096* | 4K | 77.4 (0.7) | 82.9 (0.3) | 50.9 (2.8) | 51.8 (2.5) |
| Project + Concat | - | 128 | 528K | 82.7 (0.1) | 87.0 (0.3) | 56.7 (1.2) | 54.1 (0.9) |
| Project + Concat | - | 256 | 1M | 82.6 (0.1) | 86.9 (0.1) | 56.8 (1.5) | 54.4 (1.8) |
| Project + Concat | - | 512 | 2.1M | 82.8 (0.1) | 86.9 (0.3) | 57.0 (0.1) | 53.2 (1.1) |
| Project + Concat | - | 4096* | 16.9M | 83.1 (0.3) | 87.1 (0.2) | 57.5 (0.6) | 53.9 (0.7) |
Appendix figures & tables12 assets
Supplementary material from the paper’s appendix.
Appendix
| Greedy Responses | Sampled Responses | ||||||||
| Model | Dataset | # Prompts | % Hallucinations | # Samples | % Hallucinations | ||||
| Train | Test | Train | Test | Train | Test | Train | Test | ||
| Llama-7B | TQA | 5000 | 1800 | 45.9 | 42.7 | 10 | 10 | 79.1 | 76.9 |
| NQ | 5000 | 1800 | 75.3 | 77.4 | 10 | 10 | 93.5 | 93.6 | |
| STR | 1832 | 458 | 39.8 | 40.0 | 8 | 8 | 68.3 | 67.2 | |
| Alpaca-7B | TQA | 5000 | 1800 | 67.5 | 65.8 | 10 | 10 | 74.6 | 73.4 |
| Model | Dataset | % Responses with a refusal phrase | ||
| Train: Greedy + Sampled | Test: Greedy | Test: Sampled | ||
| Llama-7B | TQA | 3.6 | 0.1 | 3.4 |
| NQ | 4.5 | 0.0 | 5.2 | |
| STR | 4.4 | 5.0 | 3.9 | |
| Alpaca-7B | TQA | 0.8 | 0.3 | 0.9 |
| NQ | 1.2 | 0.9 | 1.2 | |
| Data | PE | AH-g | LP-g | NLP-g | CLAP-g | AH-s | LP-s | NLP-s | CLAP-s |
| Llama-7B | |||||||||
| TQA | 76.0 | 67.5 (0.1) | 82.0 (0.1) | 81.6 (0.4) | 82.0 (0.0) | 72.1 (0.0) | 80.1 (0.2) | 81.2 (0.4) | 81.6 (0.2) |
| NQ | 80.1 | 75.0 (0.1) | 85.9 (0.4) | 86.2 (0.2) | 86.6 (0.3) | 80.2 (0.7) | 85.0 (0.2) | 85.9 (0.1) | 86.1 (0.4) |
| STR | 50.9 | 49.5 (1.1) | 65.0 (1.3) | 63.9 (0.8) | 65.7 (1.0) | 55.4 (0.6) | 61.0 (1.1) | 59.9 (2.3) | 65.6 (0.6) |
| Avg | 69.0 | 64.0 | 77.7 | 77.2 | 78.1 | 69.2 | 75.3 | 75.6 | 77.8 |
| Alpaca-7B | |||||||||
| Data | PE | AH-g | LP-g | NLP-g | CLAP-g | AH-s | LP-s | NLP-s | CLAP-s |
| Llama-7B | |||||||||
| TQA | 88.0 | 81.0 (0.5) | 82.5 (0.5) | 87.0 (0.7) | 85.8 (1.8) | 86.9 (0.1) | 90.0 (0.7) | 90.5 (0.0) | 91.2 (0.1) |
| NQ | 90.3 | 82.0 (0.3) | 79.7 (2.9) | 88.1 (0.3) | 85.3 (0.6) | 90.3 (0.2) | 90.5 (0.8) | 91.2 (0.7) | 92.3 (0.2) |
| STR | 74.6 | 71.5 (3.4) | 65.2 (3.8) | 57.4 (8.2) | 51.6 (3.8) | 82.1 (0.1) | 85.8 (0.1) | 85.3 (0.1) | 86.4 (0.3) |
| Avg | 84.3 | 78.2 | 75.8 | 77.5 | 74.3 | 86.5 | 88.8 | 89.0 | 89.9 |
| Alpaca-7B | |||||||||
| Model | Data | LP-rs | NLP-rs | CLAP-rs | LP-pw | NLP-pw | CLAP-pw |
| Greedy Test Responses | |||||||
| L-7B | TQA | 79.9 (1.0) | 80.1 (0.2) | 80.8 (0.9) | 80.1 (0.2) | 81.2 (0.4) | 81.6 (0.2) |
| L-7B | NQ | 84.3 (0.7) | 85.0 (0.4) | 84.7 (0.8) | 85.0 (0.2) | 85.9 (0.1) | 86.1 (0.4) |
| L-7B | STR | 60.6 (1.2) | 59.9 (3.3) | 66.5 (1.8) | 61.0 (1.1) | 59.9 (2.3) | 65.6 (0.6) |
| Avg | 74.9 | 75.0 | 77.3 | 75.3 | 75.6 | 77.8 | |
| A-7B | TQA | 89.4 (0.1) | 88.9 (0.4) | 89.1 (0.4) | 89.3 (0.2) | 89.3 (0.3) | 89.3 (0.4) |
| % Non-Hallucinations | %Abs | %Abs but NH | |||||||
| Data | Def | Def+Abs * | Alt | +CLAP-I | +CLAP-II * | Def+Abs | +CLAP-II | Def+Abs | +CLAP-II |
| L-7B TQA | 57.3 | 75.6 | 22.8 | 51.8 | 71.8 | 36.0 | 29.7 | 9.1 | 6.9 |
| L-7B STR | 60.0 | 69.9 | 32.3 | 51.9 | 59.9 | 45.0 | 22.7 | 21.4 | 10.9 |
| A-7B TQA | 34.2 | 68.3 | 26.9 | 37.6 | 67.3 | 62.7 | 50.4 | 8.7 | 6.3 |
| A-7B STR | 43.4 | 67.0 | 39.7 | 48.2 | 61.4 | 44.3 | 31.6 | 6.1 | 3.0 |
| V-7B TQA | 14.6 | 59.2 | 6.6 | 15.6 | 53.7 | 80.7 | 72.6 | 3.2 | 2.8 |
| % Non-Hallucinations | H -¿ NH | NH -¿ H | |||||||
| LLM | +LP-I | +NLP-I | +CLAP-I | +LP-I | +NLP-I | +CLAP-I | +LP-I | +NLP-I | +CLAP-I |
| Llama 7B | 60.2 | 60.0 | 61.1 | 55.8 | 45.8 | 57.6 | 34.4 | 26.8 | 32.8 |
| Alpaca 7B | 51.6 | 52.7 | 53.4 | 77.2 | 78.1 | 80.1 | 26.4 | 21.6 | 21.8 |
| % Non-Hallucinations | %Abs | %Abs but NH | |||||||
| LLM | +LP-II * | +NLP-II * | +CLAP-II * | +LP-II | +NLP-II | +CLAP-II | +LP-II | +NLP-II | +CLAP-II |
| Llama 7B | 67.8 | 68.5 | 69.5 | 16.4 | 18.5 | 16.8 | 4.9 | 5.3 | 4.7 |
| Alpaca 7B | 66.6 | 64.9 | 66.7 | 33.1 | 29.2 | 30.2 | 5.6 | 4.2 | 4.5 |
| H -¿ NH | NH -¿ H | |||||
| LLM | +LP-II | +NLP-II | +CLAP-II | +LP-II | +NLP-II | +CLAP-II |
| Llama 7B | 41.0 | 27.5 | 42.6 | 19.8 | 11.7 | 19.0 |
| Alpaca 7B | 49.2 | 57.0 | 60.4 | 3.8 | 4.2 | 4.2 |
| Probe | In Distribution | Out Of Distribution |
| TQA-¿TQA | TQA-¿City | |
| Att-Pool (MA) | 77.7 (1.2) | 72.3 (4.4) |
| Att-Pool-Ens | 77.3(0.4) | 66.4 (4.9) |
| CLAP | 76.3 (0.3) | 79.0 (3.9) |
| TQA | NQ | STR | TQA | NQ | STR | ||
| Alpaca 7B | Vicuna 7B | ||||||
| 1 | 128 | 87.3 (0.4) | 89.0 (1.2) | 83.8 (0.2) | 93.0 (0.9) | 88.1 (0.1) | 85.1 (1.4) |
| 1 | 256 | 87.2 (0.5) | 89.0 (1.0) | 83.6 (0.2) | 92.8 (0.8) | 88.3 (0.3) | 84.7 (1.2) |
| 1 | 512 | 87.4 (0.5) | 88.6 (1.2) | 83.8 (0.6) | 92.8 (0.9) | 88.1 (0.3) | 85.3 (1.3) |
| 1 | 1024 | 87.3 (0.5) | 88.5 (1.0) | 83.7 (0.3) | 93.0 (0.8) | 88.1 (0.2) | 85.1 (1.4) |
| 1 | 2048 | 87.4 (0.5) | 88.3 (1.0) | 83.5 (0.3) | 92.8 (0.9) | 88.3 (0.2) | 85.4 (1.4) |
LLM Hallucination Detection
Large language model hallucination detection identifies unsupported, incorrect, or fabricated claims in model outputs and traces.
See all 208 papers