Canonik GitHub avatar

lat-defuse-rag-repair

Canonik

A research repository that reproduces the Lat-Defuse sparse-autoencoder intervention method on Gemma-3-12B and mechanistically evaluates how it corrects RAG errors caused by misleading retrieved documents.

Stars

3

7-day growth

No data

Forks

0

Open issues

16

License

MIT

Last updated

2026-07-30

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It provides a faithful, code-independent adaptation of a peer-reviewed method, made auditable through a science contract, compatibility checks, and committed run reports.

Who it is for

  • Mechanistic interpretability researchers
  • Researchers studying RAG robustness and distractor effects
  • Practitioners working with sparse autoencoders and activation steering
  • Open-source contributors interested in reproducible ML research

Use cases

  • Reproducing or adapting Lat-Defuse-style interventions on a modern 12B model
  • Investigating which internal SAE features matter for distractor-induced RAG failures
  • Developing and validating SAE-based activation repair methods
  • Contributing to a research codebase with clear CI and experiment-tracking conventions

Strengths

  • Reproduces a published ACL Findings method without copying its code
  • Defines a science contract that pins down the numbers and rules for experiments
  • Committed run reports make real-model experiment outputs auditable
  • Compatibility failures raise exceptions by design, preventing silent correctness issues

Considerations

  • Running the real model and SAE requires GPU access
  • Data and results directories are not committed, so some artifacts must be generated locally
  • The repository is a faithful adaptation, not the official upstream implementation

README quick start

lat-defuse-rag-repair

Mechanistic evaluation of SAE-based activation interventions for correcting distractor-induced errors in RAG.

Retrieval-augmented generation (RAG) feeds a language model retrieved documents next to a question. When one of those documents is misleading (a distractor), the model often abandons the correct answer it would otherwise give. Lat-Defuse is a published method that repairs this failure by adjusting the model's internal sparse-autoencoder features until the correct answer wins again. This repository builds a faithful adaptation of that method for Gemma-3-12B and then studies what the repair actually does inside the model.

The reference implementation is the official code of the ACL 2026 Findings paper "The Mechanics of Interference: Defusing Distractors in RAG via Sparse Autoencoder Interventions" by Christian Giannetti and coauthors: at commit eff2cdfe664bc38d9de9ec3fb047b25d471826df (MIT). We do not copy its code; we reproduce its behavior. See docs/upstream-notes.md.

Directory map

docs/               the science contract, upstream notes, dataset survey
configs/            experiment configuration files
scripts/            runnable entry points
data/               datasets and curated examples, never committed
results/            experiment outputs, never committed
reports/            tracked run reports, one per real run
src/latdefuse/      the package
  data/             example schema, prompts, curated-example loader
  model/            model loading, activation capture, activation replacement
  sae/              SAE loading and compatibility checks
  steering/         the Lat-Defuse optimizer and stopping rules
tests/              unit tests, runnable without a GPU

Quickstart

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest -q

How we work

  • Pick an open issue by label. Issues labeled "good first issue" need no GPU and no downloads.
  • One issue, one focused pull request. CI (ruff, mypy, pytest) must be green before review.
  • Issues labeled "needs-gpu" require a machine with the real model; everything else runs locally on a tiny test model.
  • Read docs/science-contract.md before touching anything under src/latdefuse/. It defines the numbers and rules the sci

Description

Mechanistic evaluation of SAE-based activation interventions for correcting distractor-induced errors in RAG.

Related repositories

Similar projects matched by category, topics, and programming language.

slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960
gavamedia
Featured
gavamedia GitHub avatar

deltafin

Deltafin is a research project that runs the 2.8-trillion-parameter Mixture-of-Experts model Kimi K3 on a single Apple Silicon Mac (e.g., M1 Max with 64 GB) at about 16 seconds per token, using exact, reproducible inference with local or streaming expert loading.

AI & Machine LearningLarge Language Models
304
jamesob
Featured
jamesob GitHub avatar

local-llm

A comprehensive guide for building and configuring a high-end local machine to run state-of-the-art LLMs, with detailed hardware choices, BIOS tuning, and Docker-based model serving.

AI & Machine LearningLarge Language Models
1,660