caiovicentino1/FabricationGuard-linearprobe-qwen36-27b

Dataset

0

stars

10

commits

2

linked in READMEs

Apr 28, 2026

updated

hallucination-detection
linear-probe
llm-evaluation
mechanistic-interpretability
safety
sparse-autoencoder

README

πŸ›‘οΈ FabricationGuard β€” Linear Probe for Qwen3.6-27B

FabricationGuard headline

Activation-probe fabrication detection for Qwen3.6-27B. AUROC 0.88 cross-task on SimpleQA, -88% confident-wrong rate reduction in mitigation mode, ~1ms scoring latency.

This is the OpenInterp FabricationGuard production probe β€” derived from a multi-feature linear probe on the residual stream at layer 31, trained on a multi-benchmark hallucination corpus, validated cross-task on held-out splits.

Value
Base modelQwen/Qwen3.6-27B
Probe layerresidual stream L31 of 64
Probe typeL2 LogisticRegression on standardized residuals
Training data800 prompts Γ— residuals (TruthfulQA + HaluEval + SimpleQA + MMLU train splits)
C (regularization)0.001 (heavy reg β†’ sparse generalizable signal)
Scoring latency~1 ms / call (single matrix mul)
Reproducer notebook30_hallucinationguard_proof_qwen36_27b.ipynb + 31_hallucinationguard_v2_linear_probe.ipynb

Headline numbers

Detection AUROC (within-bench vs cross-bench held-out)

BenchmarkSingle SAE feat (v1)LR within-benchLR cross-bench
TruthfulQA-MC10.5560.5360.599
HaluEval-QA0.5000.9030.619
SimpleQA0.4940.7060.882
MMLU0.5440.6310.444

AUROC across the 4 hallucination benchmarks

The killer number: SimpleQA cross-bench AUROC 0.882 β€” probe trained on TruthfulQA + HaluEval + MMLU train splits transfers to held-out SimpleQA at 0.88. State-of-art for fabrication-style factual QA detection on a 27B base model with a linear probe.

Mitigation impact (abstain mode @ threshold 0.684)

BenchmarkConfidently wrong (baseline)+ FabricationGuardReduction
TruthfulQA65.0%32.5%βˆ’50%
HaluEval57.5%27.5%βˆ’52%
SimpleQA85.0%10.0%🎯 βˆ’88%
MMLU46.0%36.0%βˆ’22%

Mean confident-wrong reduction across hallucination benchmarks: 63.5%. MMLU correctness drops 4 pp (54% β†’ 50%) β€” see Honest scope below.


Honest scope

FabricationGuard works for fabrication-style hallucinations in factual QA tasks:

βœ… Works for❌ Out-of-scope
Generation-fabrication in open QA (HaluEval-style)Misconception resistance (TruthfulQA-style multiple choice)
Entity recall failures (SimpleQA-style obscure facts)Knowledge gaps in MC selection (MMLU-style)
Customer support fact lookupsSubjective / opinion questions
Medical / legal / internal-docs QAMulti-step reasoning failures

The probe linearly encodes a "fabrication-vs-grounded" signal in the residual stream. It does not encode "is this a popular misconception?" or "do I know the right MC option?" β€” those are different cognitive tasks. We tested all four explicitly and report honestly.


Methodology lineage

Methodology timeline

FabricationGuard is the Apache-2.0 production-grade implementation of methodology that frontier labs published in research form. We are explicit about prior art:

Prior workWhat they showedWhat we add
Anthropic β€” Persona Vectors (Aug 2025)Contrast-based activation extraction can isolate vectors for traits including hallucination, sycophancy, evil. Tested on Qwen2.5-7B-Instruct + Llama-3.1-8B-Instruct. Validated via causal steering.We extend the methodology to Qwen3.6-27B (3-4Γ— larger), evaluate via formal cross-task AUROC + bootstrap CIs + mitigation-rate, and ship as a deployable Apache-2.0 SDK.
Anthropic β€” Tracing the Thoughts (Mar 2025)Circuit tracing reveals reasoning faithfulness signal in residual stream.We use the linear-probe counterpart β€” much cheaper, deployable in production at ~1ms latency, captures the same faithfulness signal at the prompt level.
Anthropic β€” Signs of Introspection (Oct 2025)Models have limited but functional ability to introspect about uncertainty.The fact that fabrication can be linearly decoded from L31 is consistent with this β€” and our probe makes that decode externally usable.
Apollo β€” Deception Probes (Feb 2025)Linear probes on residual stream achieve AUROC 0.96-0.999 for strategic deception detection. Method established.FabricationGuard is the fabrication-detection sibling of Apollo's deception probes. Same probe class, different cognitive target (false generation vs strategic dishonesty). Both registered on ProbeBench.

The OSS gap we close: Anthropic's persona-vectors stack is closed-source and tested on 7-8B models. Apollo's deception probes are open but Llama-3-only. Goodfire pivoted to enterprise-only in Feb 2026. FabricationGuard is open-weights, large-model, production-tested.


How to use

Quickstart

import joblib
from huggingface_hub import hf_hub_download
from transformers import AutoModelForImageTextToText, AutoTokenizer
import torch
import torch.nn.functional as F

# 1) Download probe artifacts
probe_path = hf_hub_download(
    repo_id='caiovicentino1/FabricationGuard-linearprobe-qwen36-27b',
    repo_type='dataset',
    filename='probe.joblib',
)
artifacts = joblib.load(probe_path)
probe, scaler, layer = artifacts['probe'], artifacts['scaler'], artifacts['layer']

# 2) Load Qwen3.6-27B + register hook at L31
tok = AutoTokenizer.from_pretrained('Qwen/Qwen3.6-27B', trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
    'Qwen/Qwen3.6-27B', dtype=torch.bfloat16,
    attn_implementation='sdpa', device_map='cuda', trust_remote_code=True,
).eval()

blocks = model.model.language_model.layers if hasattr(model.model, 'language_model') else model.model.layers
L = 31  # probe layer
buf = {}
hook = blocks[L].register_forward_hook(
    lambda _m, _i, out: buf.update(h=(out[0] if isinstance(out, tuple) else out).detach())
)

# 3) Score a prompt
@torch.no_grad()
def fabrication_score(prompt: str) -> float:
    enc = tok(prompt, return_tensors='pt', truncation=True, max_length=512).to('cuda')
    n_valid = enc['attention_mask'].sum().item()
    model(**enc)
    h_last = buf['h'][0, n_valid - 1].float().cpu().numpy()
    return float(probe.predict_proba(scaler.transform([h_last]))[0, 1])

score = fabrication_score("Who is Bambale Osby?")
print(f"Fabrication probability: {score:.3f}")  # high score β†’ likely fabrication

# 4) Abstain mode (production pattern)
THRESHOLD = 0.684  # tuned on validation; see notebook 31
def safe_generate(prompt, max_new_tokens=128):
    if fabrication_score(prompt) > THRESHOLD:
        return "I'm not confident about this. Please verify with an authoritative source."
    enc = tok(prompt, return_tensors='pt').to('cuda')
    out = model.generate(**enc, max_new_tokens=max_new_tokens, do_sample=False)
    return tok.decode(out[0, enc['input_ids'].shape[1]:], skip_special_tokens=True)

One-line SDK install

pip install openinterp
from openinterp import FabricationGuard
guard = FabricationGuard.from_pretrained("Qwen/Qwen3.6-27B")
output = guard.generate("Who won the 2003 Nobel Prize in Aerodynamics?", mode="abstain")

Files in this dataset

FileDescription
probe.joblibscikit-learn LogisticRegressionCV + StandardScaler (1.2 MB)
meta.jsonlayer (L31), best C (0.001), best threshold (0.684), training config
verdict.jsonper-benchmark AUROC + mitigation table + raw numbers
headline.pngconfident-wrong reduction chart (TruthfulQA / HaluEval / SimpleQA)
auroc_comparison.pngSAE-single vs LR within-bench vs LR cross-bench bar chart

Comparison to alternatives

ToolHallucination AUROCLatencyOpen weightsMulti-model
Patronus Lynx-70B0.87 (HaluBench)LLM-judge ~100ms+βœ…βŒ Llama only
Vectara HHEM-2.1~0.85600 ms RTX 3090βœ…βœ… generic
Galileo Luna-2(proprietary)152 msβŒβœ…
Cleanlab TLM(proprietary)LLM-judgeβŒβœ…
Goodfire Ember(proprietary, enterprise-only since Feb 2026)unknown❌❌ Llama only
OpenInterp FabricationGuard0.88 cross / 0.90 within~1 msβœ… Apache-2.0βœ… via Pearson_CE transfer

Latency vs AUROC

The activation-probe approach is structurally cheaper than LLM-judge methods and avoids a separately-trained judge model. The 1 ms scoring latency is achieved via a single matrix multiplication on the captured residual.


Reproduce

Both notebooks are open-source on GitHub:

  • 30_hallucinationguard_proof_qwen36_27b.ipynb: original single-SAE-feature attempt (failed cross-bench, motivated v2)
  • 31_hallucinationguard_v2_linear_probe.ipynb: this repo. Multi-feature LR probe + cross-bench validation + mitigation analysis

Hardware: RTX PRO 6000 Blackwell 96 GB on Colab Pro+ (~R$10 in credits). Total runtime: ~50 min including model load.

git clone https://github.com/OpenInterpretability/notebooks.git
# open 31_hallucinationguard_v2_linear_probe.ipynb in Colab

Background β€” why this exists

Built by Caio Vicentino at OpenInterpretability, April 2026. The OSS productization layer above frontier-lab interpretability methodology β€” Apache-2.0, open-weights, production-tested on 27B+ models. Targets the empty quadrant left by Goodfire's Feb-2026 pivot to enterprise-only. Sister artifacts:

Citation

@misc{vicentino2026fabricationguard,
  title  = {FabricationGuard: Activation-Probe Hallucination Detection for Qwen3.6-27B},
  author = {Vicentino, Caio},
  year   = {2026},
  publisher = {Hugging Face},
  url    = {https://huggingface.co/datasets/caiovicentino1/FabricationGuard-linearprobe-qwen36-27b},
  note   = {OpenInterpretability β€” open-weights mechanistic interpretability platform. Methodology extends Anthropic's persona-vectors approach (arXiv:2507.21509) to 27B models with formal AUROC + mitigation evaluation.}
}

License

Apache 2.0 β€” including patent grant. Free for commercial use. Attribution appreciated.


Last updated: 2026-04-28. Built solo from Brazil with R$500/mo of Colab credits. Star and fork at github.com/OpenInterpretability.

Contributors

caiovicentino1

10 commits

caiovicentino1/FabricationGuard-linearprobe-qwen36-27b

Dataset

0

stars

10

commits

2

linked in READMEs

Apr 28, 2026

updated

hallucination-detection
linear-probe
llm-evaluation
mechanistic-interpretability
safety
sparse-autoencoder

README

πŸ›‘οΈ FabricationGuard β€” Linear Probe for Qwen3.6-27B

FabricationGuard headline

Activation-probe fabrication detection for Qwen3.6-27B. AUROC 0.88 cross-task on SimpleQA, -88% confident-wrong rate reduction in mitigation mode, ~1ms scoring latency.

This is the OpenInterp FabricationGuard production probe β€” derived from a multi-feature linear probe on the residual stream at layer 31, trained on a multi-benchmark hallucination corpus, validated cross-task on held-out splits.

Value
Base modelQwen/Qwen3.6-27B
Probe layerresidual stream L31 of 64
Probe typeL2 LogisticRegression on standardized residuals
Training data800 prompts Γ— residuals (TruthfulQA + HaluEval + SimpleQA + MMLU train splits)
C (regularization)0.001 (heavy reg β†’ sparse generalizable signal)
Scoring latency~1 ms / call (single matrix mul)
Reproducer notebook30_hallucinationguard_proof_qwen36_27b.ipynb + 31_hallucinationguard_v2_linear_probe.ipynb

Headline numbers

Detection AUROC (within-bench vs cross-bench held-out)

BenchmarkSingle SAE feat (v1)LR within-benchLR cross-bench
TruthfulQA-MC10.5560.5360.599
HaluEval-QA0.5000.9030.619
SimpleQA0.4940.7060.882
MMLU0.5440.6310.444

AUROC across the 4 hallucination benchmarks

The killer number: SimpleQA cross-bench AUROC 0.882 β€” probe trained on TruthfulQA + HaluEval + MMLU train splits transfers to held-out SimpleQA at 0.88. State-of-art for fabrication-style factual QA detection on a 27B base model with a linear probe.

Mitigation impact (abstain mode @ threshold 0.684)

BenchmarkConfidently wrong (baseline)+ FabricationGuardReduction
TruthfulQA65.0%32.5%βˆ’50%
HaluEval57.5%27.5%βˆ’52%
SimpleQA85.0%10.0%🎯 βˆ’88%
MMLU46.0%36.0%βˆ’22%

Mean confident-wrong reduction across hallucination benchmarks: 63.5%. MMLU correctness drops 4 pp (54% β†’ 50%) β€” see Honest scope below.


Honest scope

FabricationGuard works for fabrication-style hallucinations in factual QA tasks:

βœ… Works for❌ Out-of-scope
Generation-fabrication in open QA (HaluEval-style)Misconception resistance (TruthfulQA-style multiple choice)
Entity recall failures (SimpleQA-style obscure facts)Knowledge gaps in MC selection (MMLU-style)
Customer support fact lookupsSubjective / opinion questions
Medical / legal / internal-docs QAMulti-step reasoning failures

The probe linearly encodes a "fabrication-vs-grounded" signal in the residual stream. It does not encode "is this a popular misconception?" or "do I know the right MC option?" β€” those are different cognitive tasks. We tested all four explicitly and report honestly.


Methodology lineage

Methodology timeline

FabricationGuard is the Apache-2.0 production-grade implementation of methodology that frontier labs published in research form. We are explicit about prior art:

Prior workWhat they showedWhat we add
Anthropic β€” Persona Vectors (Aug 2025)Contrast-based activation extraction can isolate vectors for traits including hallucination, sycophancy, evil. Tested on Qwen2.5-7B-Instruct + Llama-3.1-8B-Instruct. Validated via causal steering.We extend the methodology to Qwen3.6-27B (3-4Γ— larger), evaluate via formal cross-task AUROC + bootstrap CIs + mitigation-rate, and ship as a deployable Apache-2.0 SDK.
Anthropic β€” Tracing the Thoughts (Mar 2025)Circuit tracing reveals reasoning faithfulness signal in residual stream.We use the linear-probe counterpart β€” much cheaper, deployable in production at ~1ms latency, captures the same faithfulness signal at the prompt level.
Anthropic β€” Signs of Introspection (Oct 2025)Models have limited but functional ability to introspect about uncertainty.The fact that fabrication can be linearly decoded from L31 is consistent with this β€” and our probe makes that decode externally usable.
Apollo β€” Deception Probes (Feb 2025)Linear probes on residual stream achieve AUROC 0.96-0.999 for strategic deception detection. Method established.FabricationGuard is the fabrication-detection sibling of Apollo's deception probes. Same probe class, different cognitive target (false generation vs strategic dishonesty). Both registered on ProbeBench.

The OSS gap we close: Anthropic's persona-vectors stack is closed-source and tested on 7-8B models. Apollo's deception probes are open but Llama-3-only. Goodfire pivoted to enterprise-only in Feb 2026. FabricationGuard is open-weights, large-model, production-tested.


How to use

Quickstart

import joblib
from huggingface_hub import hf_hub_download
from transformers import AutoModelForImageTextToText, AutoTokenizer
import torch
import torch.nn.functional as F

# 1) Download probe artifacts
probe_path = hf_hub_download(
    repo_id='caiovicentino1/FabricationGuard-linearprobe-qwen36-27b',
    repo_type='dataset',
    filename='probe.joblib',
)
artifacts = joblib.load(probe_path)
probe, scaler, layer = artifacts['probe'], artifacts['scaler'], artifacts['layer']

# 2) Load Qwen3.6-27B + register hook at L31
tok = AutoTokenizer.from_pretrained('Qwen/Qwen3.6-27B', trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
    'Qwen/Qwen3.6-27B', dtype=torch.bfloat16,
    attn_implementation='sdpa', device_map='cuda', trust_remote_code=True,
).eval()

blocks = model.model.language_model.layers if hasattr(model.model, 'language_model') else model.model.layers
L = 31  # probe layer
buf = {}
hook = blocks[L].register_forward_hook(
    lambda _m, _i, out: buf.update(h=(out[0] if isinstance(out, tuple) else out).detach())
)

# 3) Score a prompt
@torch.no_grad()
def fabrication_score(prompt: str) -> float:
    enc = tok(prompt, return_tensors='pt', truncation=True, max_length=512).to('cuda')
    n_valid = enc['attention_mask'].sum().item()
    model(**enc)
    h_last = buf['h'][0, n_valid - 1].float().cpu().numpy()
    return float(probe.predict_proba(scaler.transform([h_last]))[0, 1])

score = fabrication_score("Who is Bambale Osby?")
print(f"Fabrication probability: {score:.3f}")  # high score β†’ likely fabrication

# 4) Abstain mode (production pattern)
THRESHOLD = 0.684  # tuned on validation; see notebook 31
def safe_generate(prompt, max_new_tokens=128):
    if fabrication_score(prompt) > THRESHOLD:
        return "I'm not confident about this. Please verify with an authoritative source."
    enc = tok(prompt, return_tensors='pt').to('cuda')
    out = model.generate(**enc, max_new_tokens=max_new_tokens, do_sample=False)
    return tok.decode(out[0, enc['input_ids'].shape[1]:], skip_special_tokens=True)

One-line SDK install

pip install openinterp
from openinterp import FabricationGuard
guard = FabricationGuard.from_pretrained("Qwen/Qwen3.6-27B")
output = guard.generate("Who won the 2003 Nobel Prize in Aerodynamics?", mode="abstain")

Files in this dataset

FileDescription
probe.joblibscikit-learn LogisticRegressionCV + StandardScaler (1.2 MB)
meta.jsonlayer (L31), best C (0.001), best threshold (0.684), training config
verdict.jsonper-benchmark AUROC + mitigation table + raw numbers
headline.pngconfident-wrong reduction chart (TruthfulQA / HaluEval / SimpleQA)
auroc_comparison.pngSAE-single vs LR within-bench vs LR cross-bench bar chart

Comparison to alternatives

ToolHallucination AUROCLatencyOpen weightsMulti-model
Patronus Lynx-70B0.87 (HaluBench)LLM-judge ~100ms+βœ…βŒ Llama only
Vectara HHEM-2.1~0.85600 ms RTX 3090βœ…βœ… generic
Galileo Luna-2(proprietary)152 msβŒβœ…
Cleanlab TLM(proprietary)LLM-judgeβŒβœ…
Goodfire Ember(proprietary, enterprise-only since Feb 2026)unknown❌❌ Llama only
OpenInterp FabricationGuard0.88 cross / 0.90 within~1 msβœ… Apache-2.0βœ… via Pearson_CE transfer

Latency vs AUROC

The activation-probe approach is structurally cheaper than LLM-judge methods and avoids a separately-trained judge model. The 1 ms scoring latency is achieved via a single matrix multiplication on the captured residual.


Reproduce

Both notebooks are open-source on GitHub:

  • 30_hallucinationguard_proof_qwen36_27b.ipynb: original single-SAE-feature attempt (failed cross-bench, motivated v2)
  • 31_hallucinationguard_v2_linear_probe.ipynb: this repo. Multi-feature LR probe + cross-bench validation + mitigation analysis

Hardware: RTX PRO 6000 Blackwell 96 GB on Colab Pro+ (~R$10 in credits). Total runtime: ~50 min including model load.

git clone https://github.com/OpenInterpretability/notebooks.git
# open 31_hallucinationguard_v2_linear_probe.ipynb in Colab

Background β€” why this exists

Built by Caio Vicentino at OpenInterpretability, April 2026. The OSS productization layer above frontier-lab interpretability methodology β€” Apache-2.0, open-weights, production-tested on 27B+ models. Targets the empty quadrant left by Goodfire's Feb-2026 pivot to enterprise-only. Sister artifacts:

Citation

@misc{vicentino2026fabricationguard,
  title  = {FabricationGuard: Activation-Probe Hallucination Detection for Qwen3.6-27B},
  author = {Vicentino, Caio},
  year   = {2026},
  publisher = {Hugging Face},
  url    = {https://huggingface.co/datasets/caiovicentino1/FabricationGuard-linearprobe-qwen36-27b},
  note   = {OpenInterpretability β€” open-weights mechanistic interpretability platform. Methodology extends Anthropic's persona-vectors approach (arXiv:2507.21509) to 27B models with formal AUROC + mitigation evaluation.}
}

License

Apache 2.0 β€” including patent grant. Free for commercial use. Attribution appreciated.


Last updated: 2026-04-28. Built solo from Brazil with R$500/mo of Colab credits. Star and fork at github.com/OpenInterpretability.

Contributors

caiovicentino1

10 commits