[Proposal] Contextual Decomposition: Nonlinear Source Attribution and Dataset-Wide Ranking on GPT-2
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- ai, machine-learning
调研方向
Read the current local single-source implementation and its 218 focused CD tests, then investigate per-example reconstruction budgets and independently test the allocation policy. The remaining work includes maintainer agreement, resolving integration validation, and implementing reference-mean fitting, supported joint-source attribution, and held-out dataset-wide ranking; the issue is done only when both outcomes are delivered and validated.
由索引模型根据 Issue 内容生成。
描述
Proposal
Add maintained, Bridge-native contextual decomposition for GPT-2, with explicit
nonlinear allocation semantics and independently tested constituent shares.
This issue has two usable outcomes:
- Single-source attribution from a head/head-position or residual anchor to
downstream internal activations and logits/logit differences. - Reference-mean fitting, supported joint-source attribution, and dataset-wide
independent source ranking with held-out characterization.
The first outcome is implemented locally but is not pushed or merged. The second
is not implemented. Keep this issue open until both outcomes are delivered; do
not close it after preparatory refactors or single-source delivery alone.
Motivation
TL has activation access, patching, gradient attribution, and vocabulary/weight
readouts, but no first-class nonlinear contextual decomposition workflow. CD-T
assigns beta/gamma constituents through attention, normalization, MLPs, and
readout without differentiating a task metric.
This complements intervention tools; it does not replace causal validation.
Reconstruction, policy-correct allocation, and causal usefulness are separate
claims. Independent constituent tests are necessary because defining gamma as
total minus beta can reconstruct a wrong allocation perfectly.
Current implementation and mathematical conventions
The local single-source API provides ContextualDecomposition, CDSource,
CDTarget, CDBaseline, CDTensor, CDResult, and reconstruction diagnostics.
- Raw fp32/eval GPT-2 TransformerBridge with local transformers driver and eager
full-sequence attention, on one device. - A selected head's residual write excludes shared output bias. Reference-centered
beta is injected at the attention merge; gamma retains all other native terms. - Residual pre/mid/post anchors and validated absolute source positions.
- Downstream internal targets and per-example logit/logit-difference selectors.
- Owned detached references/results and explicit intermediate retention.
- Affine bias allocation by projected magnitude; undefined jointly zero ratio
completed by assigning bias to gamma. - Ordered GELU differences, combined-input LayerNorm denominator, and printed
nonlinear QK/softmax/value allocation. This is not a Shapley or LRP method. - No silent cancellation redistribution, gamma correction, or frozen-pattern
substitution.
The implementation policy is named magnitude-affine-ordered-gelu-v1. Printed
paper equations and inspected reference scripts differ in places; complete
reference compatibility is not claimed. No authors' kernels are vendored or
required at runtime. Repository-wide licensing of those kernels was not established.
Outstanding blockers identified by review
- Batch-dependent error budget: native reconstruction currently uses a maximum
scale over the whole batch. A large example can hide an incorrect smaller
example that would fail alone. Fix validation per example and propagate
appropriate target budgets before requesting merge. Do not enlarge the global
tolerance or correct constituents to hide the problem. - Repository integration: full tests fail at Granite's MPS eager-scan parity
assertion. Investigation locates the discrepancy in HF grouped MoE experts,
not GPT-2 CD. Track the runtime issue separately; full validation remains blocked. - Maintainer agreement: no CD-T policy/API/scope approval has been found.
This proposal requests it; implementation existence is not approval.
Validation observed
On the local feature head:
- 218 focused CD tests passed with 97% statement coverage.
- All five sanitized notebook code cells passed.
- Mypy, format/diff checks, docs build, source distribution, and wheel build passed.
- Standard unit: 7,452 passed; docstrings: 13 passed; acceptance: 163 passed.
- Standard integration: 1,541 passed and one Granite MPS failure.
These results include existing skips/xfails and docs warnings; they are not a
claim of warning-free or fully green validation. Trained GPT-2 characterization
pins revision 607a30d783dfa663caf39e06633721c8d4cfcd7e and uses explicit token IDs,
references, and CPU/fp32/eager settings. It is numerical characterization, not
IOI circuit-recovery evidence.
Second outcome and exclusions
The second PR should fit masked/aligned reference means from separate reference
data, implement explicitly supported disjoint joint-source sets, score sources
independently across examples, retain signed/ratiometric diagnostics, and provide
a held-out IOI ranking workflow. It must not synthesize joint attribution by
summing marginal scores or leak test examples into reference fitting.
Automatic circuit discovery/pruning, mixed head/MLP circuits, direct-edge CD,
modern decoder/encoder/seq2seq architectures, cached generation, and resumable
experiments are separate proposals. No SAE training or artifact dependency is needed.
Maintainer decisions requested
- Is a single-source GPT-2 CD tool plus a separate ranking/joint-source PR the right scope?
- Are the explicit allocation policy and zero-ratio completion acceptable?
- Is the current source/target/reference API appropriate for
tools.analysis? - Which per-example numerical acceptance contract should be required?
- Is independent equation/oracle validation sufficient without an externally
licensed reference package, with reference comparisons deferred until permission?
References
- Hsu et al., Efficient Automated Circuit Discovery in Transformers using
Contextual Decomposition: https://arxiv.org/abs/2407.00886. - Murdoch et al., Beyond Word Importance: Contextual Decomposition to Extract
Interactions from LSTMs: https://arxiv.org/abs/1801.05453. - Authors' research scripts: https://github.com/adelaidehsu/CD_Circuit.
Checklist
- Fresh repository issue/PR searches found no matching contextual-decomposition proposal.
- Maintainers approve policy/API/scope.
- Batch-dependent reconstruction acceptance fixed and independently tested.
- Single-source PR merged with required validation resolved.
- Reference/joint-source/dataset-ranking outcome implemented and validated.
- Both outcomes complete before issue closure
- 主要语言
- Python
- 星标
- 3.9k
- 派生
- 708
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 82
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TransformerLensOrg/TransformerLens 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
TransformerLensOrg/TransformerLens#1980 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
TransformerLensOrg/TransformerLens#1979 ·
维护者通常 1 天内回复
-
[Proposal] Demo: auditing a published LLM-written weight edit (Weight-Space Programming, Qwen3.5-0.8B loop fix) with TransformerBridge可能已有人在做 @emerardd 于 1 天前认领。 未关闭complexity-moderate demo TransformerBridge
TransformerLensOrg/TransformerLens#1978 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug Report] `blocks.N.hook_out` never fires on OpenAI GPT because the HF block returns a list可能已有人在做 @ska2704 于 2 天前认领。 未关闭bug complexity-simple TransformerBridge
难度 3/5 半天 新手友好度 72/100
TransformerLensOrg/TransformerLens#1969 · 2 条评论 ·
维护者通常 1 天内回复
-
enhancement seen_by_maintainers TransformerBridge
难度 4/5 3-5 天 新手友好度 30/100
TransformerLensOrg/TransformerLens#1957 · 3 条评论 ·
维护者通常 1 天内回复
查看 TransformerLensOrg/TransformerLens 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
FinanceFlash/unvibecode#509 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
FAIRmat-NFDI/nomad-distro-dev#161 ·
-
bug v2
难度 2/5 1-3 小时 新手友好度 76/100
modelcontextprotocol/python-sdk#3821 · 1 条评论 ·
维护者通常 1 天内回复
-
bug severity:low
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复
-
Log-odds calibration uses upper middle score instead of median for even candidate sets可能已有人在做 @flysheep-ai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复