NeurIPS 2026
Haobo Zhang1,3,* Β· Zhenhua Xu2,3,* Β· Junxian Li4
Shangfeng Sheng5 Β· Dezhang Kong2,3,β Β· Meng Han2,3,β
1 Renmin University of China
2 Zhejiang University Β· 3 Binjiang Institute of Zhejiang University
4 Shanghai Jiao Tong University Β· 5 University of Science and Technology of China
* Equal contribution Β β Corresponding authors
haobo0119@gmail.com Β· xuzhenhua0326@zju.edu.cn Β· mhan@zju.edu.cn
Trace model provenance through differential attention.
Model families, fingerprint patterns, and the highlighted match are illustrative.
Overview Β· Video Β· Method Β· Quick Start Β· Results Β· Model Zoo Β· Citation
AttnDiff is a data-efficient, white-box framework for verifying whether a suspect LLM derives from a reference model. It probes minimally edited prompt pairs that induce semantic conflicts, captures the resulting attention differences, summarizes them with spectral descriptors, and compares fingerprints using centered linear CKA.
- Intrinsic fingerprints: no watermark embedding, model training, or parameter modification.
- Compact probes: the paper defaults to 60 prompt pairs across six domains, with the top 3 singular values per layer/head.
- Flexible comparison: models can have different layer/head counts. CKA compares their geometry over the same ordered probes.
- Broad evaluation: fine-tuning, PPO/DPO, merging, pruning, distillation, quantization, cross-family comparisons, and a fixed-budget adaptive suppression pilot.
βΆ Watch the 60-second video Β· Download MP4
English narration and embedded captions Β· Optional Chinese subtitles on the project page
- Construct paired probes. A single-word pivot creates a controlled semantic conflict: βparallel lines never intersectβ β βparallel lines always intersect.β
- Extract attention. Collect post-softmax causal self-attention maps across all layers and heads.
- Compute differences. In the paper, adaptive average pooling aligns each pair to the smaller token length, then
ΞA = Pool(A_corrupted) β Pool(A_original). - Build spectral fingerprints. Keep the top
K = 3singular values per layer/head and stackMprobe descriptors intoF β β^(M Γ LHK). - Compare models. Independently extract both fingerprints using the same probe identities and ordering, then compare their centered
M Γ MGram matrices with linear CKA.
The method requires internal attention activations. Text-only APIs are outside the evaluated setting. Similarity provides evidence of shared lineage; decision thresholds should be calibrated for the model pool and verification setting.
Install uv, then run:
git clone https://github.com/zhb0119/AttnDiff.git
cd AttnDiff
uv syncAlternatively, use python -m pip install -e .. Run commands from the repository root. Multiline examples use Bash syntax; in PowerShell, use a single line or replace \ with a backtick.
uv run attndiff-compare \
--base output/comput_W/fingerprint_Llama-2-7B.json \
--dir output/comput_W \
--cka linearThis compares stored fingerprints without loading model weights or extracting new attentions. These are example artifacts, not a complete reproduction of the paper experiments.
Use a Hugging Face model identifier or local checkpoint path:
uv run attndiff-compute \
--model_name /path/to/your/model \
--attn_device cuda:0 \
--mode diff \
--svd_k 3 \
--out output/spectral/fingerprint_your_model.jsonThe extractor reads dataset/dataset.json and can reuse attention JSONs under output/attention/. Use separate attention paths when changing probes so that old cached attentions are not reused.
To start from pre-extracted attention maps:
uv run attndiff-compute \
--original output/attention/model_att_origin.json \
--corrupted output/attention/model_att_perturb.json \
--mode diff \
--svd_k 3 \
--out output/spectral/fingerprint_model.jsonAfter extracting reference and suspect fingerprints into the same directory:
uv run attndiff-compare \
--base output/spectral/fingerprint_reference.json \
--dir output/spectral \
--cka linearKeep the same representation and ordered probe set across compared files. Use --layer 1 for an optional layer-specific comparison (1-based).
| Extraction option | Purpose |
|---|---|
--model_name |
Model identifier or local checkpoint path |
--original, --corrupted |
Pre-extracted attention JSON files |
--mode diff |
Corrupted-minus-original attention |
--svd_k 3 |
Enable top-3 singular-value descriptors |
--attn_device |
Extraction device, e.g. cuda:0 |
--out |
Fingerprint output path |
For batch runs, configure model paths and device in scripts/batch_compute.sh, and add --svd_k 3 to its extraction command to use spectral descriptors.
The input is a JSON list:
[
{
"id": 1,
"topic": "Mathematics",
"original": "In Euclidean geometry, two distinct parallel lines never intersect, no matter how far they are extended.",
"corrupted": "In Euclidean geometry, two distinct parallel lines always intersect, no matter how far they are extended."
}
]- The checked-in
dataset/dataset.jsoncontains 30 pairs across five domains. The paper defaults to 60 pairs across six domains: Code, Math, Economics, Medicine, Daily QA, and Safe Alignment (10 pairs each). - Set
--svd_k 3explicitly: the current CLI does not enable spectral descriptors by default. Do not mix these outputs with legacy scalar fingerprints. - For unequal token lengths, the current CLI's SVD path crops maps to the common minimum size; the paper method specifies adaptive average pooling. Exact reproduction requires resolving this implementation difference. Equal-length pairs do not need spatial alignment.
See the paper's implementation appendix for the protocol and dataset/README.md for the schema.
The following are paper-reported results, not measurements produced by the quick-start example.
| Evaluation | Reported result |
|---|---|
| Fine-tuning | CKA 0.9856β0.9989 across six Llama-2-7B derivatives |
| Pruning | CKA β₯ 0.9879 across nine structured/unstructured pruned suspects |
| Weight-space merging | CKA 0.9561β0.9996 to the evaluated parents |
| Discriminability | 0.9883 AUROC / 0.9881 AUPR, on 36 related + 33 unrelated suspects |
| Adaptive suppression | Refreshed-probe CKA 0.988β0.991, under 20β80% exposure and a fixed 96-step LoRA budget |
The adaptive study covers one related Gemma-2 model pair. Its findings support private, refreshed probes within that setting; they do not establish robustness to unrestricted adaptive attacks. AUROC/AUPR are ranking metrics, not accuracy percentages.
Explore interactive results and ablations β
Browse model families and checkpoints β
56 catalog entries Β· 9 experiment categories
Explore the model families and transformations evaluated in the paper. Each experiment uses its own subset; this directory is separate from the 36-related / 33-unrelated discriminability benchmark.
|
6 entries |
4 entries |
2 entries |
|
9 entries |
12 entries |
4 entries |
|
3 entries |
6 entries |
10 entries |
π§ Fine-tuning Β· 6 entries
| Model | Reference / source |
|---|---|
| Llama-2-finance-7b | Llama-2-7B |
| Vicuna-1.5-7b | Llama-2-7B |
| WizardMath-7b | Llama-2-7B |
| Chinese-LLaMA-2-7b | Llama-2-7B |
| CodeLLaMA-7b | Llama-2-7B |
| Llemma-7b | Llama-2-7B |
π― Preference optimization Β· 4 entries
| Model | Reference / source |
|---|---|
| llama-2-7b-ppo-v0.1-reward | Llama-2-7B |
| llama-2-7b-ppo-lora-v0.1 | Llama-2-7B |
| tulu-2-dpo-7b | Llama-2-7B |
| llama2-7b-dpo | Llama-2-7B |
π Model merging Β· 2 entries
| Model | Reference / source |
|---|---|
| Evollm-jp-7b | Shisa-gamma-7b-v1 WizardMath-7b-1.1 Abel-7b-002 |
| Fusellm-7b | Llama-2-7B OpenLLaMA-2-7b mpt-7b |
βοΈ Model pruning Β· 9 entries
| Model | Reference / source |
|---|---|
| Sheared-LLaMA-1.3B | Llama-2-7B |
| Sheared-LLaMA-1.3B-pruned | Llama-2-7B |
| Sheared-LLaMA-1.3B-sharegpt | Llama-2-7B |
| Sheared-LLaMA-2.7B | Llama-2-7B |
| Sheared-LLaMA-2.7B-pruned | Llama-2-7B |
| Sheared-LLaMA-2.7B-sharegpt | Llama-2-7B |
| Sparse-llama-2-7b | Llama-2-7B |
| Wanda-llama-2-7b | Llama-2-7B |
| GBLM-llama-2-7b | Llama-2-7B |
π Cross-family & scale Β· 12 entries
| Model | Reference / source |
|---|---|
| Qwen2.5-Coder-1.5B | Qwen2.5-1.5B |
| Qwen2.5-Math-1.5B | Qwen2.5-1.5B |
| Qwen2.5-1.5B-Instruct | Qwen2.5-1.5B |
| Qwen2.5-14B-Instruct | Qwen2.5-14B |
| oxy-1-small | Qwen2.5-14B |
| Qwen2.5-14B-Gutenberg-Instruct-Slerpeno | Qwen2.5-14B |
| gemma-2-2b-neogenesis-ita | gemma-2-2b |
| gemma-2-baku-2b | gemma-2-2b |
| gemma2-2b-merged | gemma-2-2b |
| AQUA-7B | Mistral-7B-v0.3 |
| spellcheck-mistral-7b | Mistral-7B-v0.3 |
| Mistral-7B-Instruct-demi-merge-v0.3-7B | Mistral-7B-v0.3 |
π§ͺ Distillation Β· 4 entries
| Model | Reference / source |
|---|---|
| Llama-3.1-8B-Instruct-Open-R1-Distill | Llama-3.1-8B |
| Qwen2.5-7B-Open-R1-Distill | Qwen2.5-7B |
| DeepSeek-R1-Distill-Qwen-14B | Qwen2.5-14B |
| llama-2-7b-logit-watermark-distill-kgw-k1-gamma0.25-delta2 | Llama-2-7B |
π§© Mixture of experts Β· 3 entries
| Model | Reference / source |
|---|---|
| Instruct_Mixtral-8x7B-v0.1_Dolly15K | Mixtral-8x7B |
| Nous-Hermes-2-Mixtral-8x7B-DPO | Mixtral-8x7B |
| openbuddy-mixtral-8x7b-v15.4 | Mixtral-8x7B |
β‘ Quantization Β· 6 entries
| Model | Reference / source |
|---|---|
| Qwen2.5-7B-Instruct-GPTQ-Int8 | Qwen2.5-7B |
| Qwen2.5-7B-Instruct-GPTQ-Int4 | Qwen2.5-7B |
| Llama-2-7B-Chat-GPTQ | Llama-2-7B |
| Meta-Llama-3.1-8B-Instruct-GPTQ-Q_8 | Llama-3.1-8B |
| LLaMA-3.1-8B-Instruct-INT4-GPTQ | Llama-3.1-8B |
| Mistral-7B-Instruct-v0.3-GPTQ-4bit | Mistral-7B-v0.3 |
π¬ Unrelated controls Β· 10 entries
| Model | Compared against |
|---|---|
| Llama3-8B | Llama-2-7B |
| mpt-7b | Llama-2-7B |
| Qwen2.5-1.5B | Llama-2-7B |
| Qwen2.5-3B | Llama-2-7B |
| Qwen2.5-7B | Llama-2-7B |
| Qwen2.5-14B | Llama-2-7B |
| Qwen2.5-Math-7B | Llama-2-7B |
| gemma-2-2b | Llama-2-7B |
| Gemma-7B-it | Llama-2-7B |
| Yi-6B | Llama-2-7B |
π Search all models on the project page Β· Full taxonomy & checkpoint directory
AttnDiff/
βββ src/attndiff/ # Fingerprint extraction, similarity, and CLI
βββ dataset/ # Example paired probes
βββ output/comput_W/ # Included example fingerprints
βββ scripts/ # Batch processing
βββ tools/ # Model merging and pruning utilities
βββ examples/ # Usage examples
βββ tests/ # Algorithm tests
βββ docs/ # GitHub Pages source and paper media
βββ CITATION.cff # GitHub citation metadata
βββ pyproject.toml # Package configuration
Project-page maintenance and local preview: docs/README.md.
@misc{zhang2026attndiffattentionbaseddifferentialfingerprinting,
title={AttnDiff: Attention-based Differential Fingerprinting for Large Language Models},
author={Haobo Zhang and Zhenhua Xu and Junxian Li and Shangfeng Sheng and Dezhang Kong and Meng Han},
year={2026},
eprint={2604.05502},
archivePrefix={arXiv},
primaryClass={cs.CR},
url={https://arxiv.org/abs/2604.05502}
}Code is released under the MIT License. Built with PyTorch, Hugging Face Transformers, and uv.


