Canonik GitHub avatar

lat-defuse-rag-repair

Canonik

这个仓库在 Gemma-3-12B 上复现 Lat-Defuse 稀疏自编码器干预方法,并对该方法如何修复由误导性检索文档造成的 RAG 错误进行机制层面的评估。

Stars

3

7 天增长

暂无数据

Fork 数

0

开放 Issue

16

开源协议

MIT

最近更新

2026-07-30

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它以不复制代码的方式忠实复现了已发表方法,并通过“科学合同”、兼容性检查和提交运行报告,使干预的内部机制更可审计。

适合谁使用

  • 机制可解释性研究者
  • 研究 RAG 鲁棒性与干扰文档的研究者
  • 使用稀疏自编码器和激活引导的实践者
  • 关注可复现机器学习实验的开源贡献者

典型使用场景

  • 在 12B 模型上复现或改造 Lat-Defuse 干预方法
  • 研究哪些内部 SAE 特征与 RAG 干扰错误相关
  • 开发和验证基于 SAE 的激活修复方法
  • 在具有 CI 与科学合同约束的研究代码库中参与贡献

项目优势

  • 在不复制官方代码的情况下复现了 ACL Findings 方法
  • 用科学合同明确实验依赖的数字和规则
  • 提交运行报告,使真实模型实验输出可审计
  • 兼容性失败会按设计抛出异常,避免静默错误

使用前须知

  • 运行真实模型和 SAE 需要 GPU 资源
  • data 和 results 目录不提交,相关产物需在本地生成
  • 该仓库是忠实改编实现,并非官方上游实现

README 快速开始

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

项目描述

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

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

slvDev
精选
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 与机器学习大语言模型
1,960
gavamedia
精选
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 与机器学习大语言模型
304
jamesob
精选
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 与机器学习大语言模型
1,660