---
title: Source-level Counterfactual Attribution
url: https://www.emergentmind.com/topics/source-level-counterfactual-attribution-sca
type: topic
---

# Source-level Counterfactual Attribution

Source-level Counterfactual Attribution (SCA) is a family of attribution frameworks that localize causal responsibility to a specified “source” and evaluate that responsibility by comparing actual outcomes with counterfactual outcomes under source-specific interventions. Across recent work, the source can be a step in an LLM agent trace, an atomic source in a Reinforcement Learning from Verifiable Rewards (RLVR) dataset, a training example or source corpus in training-data attribution, or a retrieved document or evidence cluster in Retrieval-Augmented Generation (RAG). What unifies these formulations is the counterfactual question: what would change if this source were altered, removed, reweighted, or relabeled, with all other relevant conditions held fixed or re-executed according to the causal structure of the system [2605.25338].

## 1. Conceptual scope and defining intuition

In the agent setting, SCA is described as taking a *concrete execution trace* of an agent and asking, for each step, “If this step had been different in this way, would the overall outcome have changed from failure to success?” A failed trace is written as
\[
\tau = (s_1, s_2, \dots, s_T),
\]
with a task-specific verifier
\[
\mathcal{V}(y(\tau), x) \in \{0,1\},
\]
and source-level attribution identifies which step \(s_i\) is *causally responsible* for failure because replacing it appropriately and re-running the downstream computation flips the outcome to success [2605.25338].

In the RLVR data-lineage setting, SCA is defined at the granularity of **atomic sources** rather than individual samples. The counterfactual comparison is between a shared base model \(\theta_0\) and a checkpoint \(\theta_s\) obtained by training only on source \(s\). The resulting difference is used as a per-source *marginal utility* estimate and also to label each instance with a **learnability category** [2605.26971].

In influence-style training-data attribution, the same counterfactual intuition appears as the first-order effect of up- or down-weighting a training example or source on a test functional. The classical target is
\[
\tau_{\mathrm{IF}(b\mid q)} := -\,\frac{1}{N}\, g_q^\top\, H^{-1}\, g_b,
\]
and, for a source \(S\), the source-level effect is the sum over all examples in \(S\) [2511.19803].

In RAG systems, SCA is instantiated as **counterfactual deletion** of retrieved evidence. Given a question \(q\), evidences \(E\), and answer \(a\), the system removes one evidence cluster at a time, regenerates a counterfactual answer, and compares it with the original answer. The more the answer changes, the more causal influence is attributed to that source evidence or source URL [2412.10571].

A plausible implication is that SCA is better treated as a design pattern than as a single algorithm. The recurring structure is source identification, counterfactual intervention, outcome comparison, and aggregation into an attribution or credit signal.

## 2. Core formalizations of source-level counterfactuals

The most explicit formalizations in the literature differ by intervention target, but they all define attribution through a counterfactual change in behavior rather than through similarity alone.

CausalFlow models LLM-agent execution as a *sequential causal chain* and defines a counterfactual trace
\[
\tau[t \leftarrow \tilde{s}_t]
\]
by replacing step \(s_t\) with \(\tilde{s}_t\) and recomputing all subsequent steps \(s_{t+1}, \dots, s_T\). The outcome variable is the verifier \(\mathcal{V}(y(\tau), x)\), and the central attribution statistic is the **Causal Responsibility Score (CRS)**:
\[
\mathrm{CRS}(s_i) = \max_{k \in \{1,\dots,K\}} \mathbb{I}\!\left[ \mathcal{V}\!\big(y(\tau[i \leftarrow s_i'^{(k)}]), x\big)=1 \right].
\]
Thus \(\mathrm{CRS}(s_i)=1\) exactly when at least one local intervention at step \(i\) flips the final verifier from failure to success [2605.25338].

ATLAS-based SCA for RLVR defines correctness indicators \(c_0(i)\) for the base model and \(c_s(i)\) for the source-specific RL checkpoint, then partitions instances into four categories: **00**, **01**, **10**, and **11**. For a source \(s\), the category proportions are
\[
p_{ab}(s) \;=\; \frac{1}{|\mathcal{D}_s|} \sum_{i \in \mathcal{D}_s} \mathbf{1}\{(c_0(i), c_s(i)) = (a,b)\},
\]
and the SCA-based learnability score is
\[
L_\mathrm{SCA}(s) \;=\; \alpha_{01}\,p_{01}(s) + \alpha_{11}\,p_{11}(s) + \alpha_{10}\,p_{10}(s) + \alpha_{00}\,p_{00}(s).
\]
This treats the source as the intervention unit and the change from \(\theta_0\) to \(\theta_s\) as the counterfactual treatment [2605.26971].

Forward-only influence-style attribution preserves the same first-order counterfactual target as classical influence functions, but estimates it by short-horizon gradient propagation and test-time forward evaluation:
\[
s(b, q)
\;:=\;
\frac{F\!\big(q;\theta^*+\Delta\theta^+_T(b;\varepsilon)\big)
      - F\!\big(q;\theta^*+\Delta\theta^-_T(b;\varepsilon)\big)}{2\,(\varepsilon/N)}.
\]
As \(T\to\infty\), this converges to
\[
-\,g_q^\top H_\lambda^{-1} g_b,
\]
and source-level attribution is obtained by summing over all examples in the source [2511.19803].

Approximate unrolled differentiation in **Source** defines attribution through the change in final parameters after reweighting a training source during training, then projects that parameter change onto a query functional. Its segment-based formula approximates finite-time counterfactual retraining effects and is explicitly designed for non-converged models and multi-stage pipelines [2405.12186].

In RAG, the formal intervention is evidence removal. After clustering redundant evidences, the counterfactual context is
\[
E^{cl,cf}_i = E^{cl} \setminus e^{cl}_i,
\]
the model generates \(a^{cf}_{i,j}\), computes a similarity \(s_{i,j} \leftarrow sim(a, a^{cf}_{i,j})\), averages over Monte Carlo samples, and converts the resulting scores into an attribution distribution by softmax [2412.10571].

## 3. Operational paradigms and source granularities

The recent literature uses SCA at several distinct granularities. The following summary stays close to the terminology used in the papers.

| Paradigm | Source unit | Counterfactual operation |
|---|---|---|
| LLM agents | Step \(s_i\) in a trace | Replace step and sequentially re-execute descendants |
| RLVR dataset curation | Atomic source \(s\) | Train \(\theta_s\) from \(\theta_0\) using only \(\mathcal{D}_s\) |
| Training-data attribution | Example \(b\) or source \(S\) | Up/down-weight in training objective |
| Enterprise RAG | Evidence cluster or source URL | Remove cluster from retrieved context |
| Autoregressive credit attribution | Document \(s_i\) in deployment-time dataset | Compare factual output with output under source removal, conditioned on non-credit |

In CausalFlow, step types are explicitly logged, including `REASONING`, `TOOL_CALL`, `TOOL_RESPONSE`, `LLM_RESPONSE`, `MEMORY_ACCESS`, and `FINAL_ANSWER`. This typed trace structure provides precise intervention points and explicit dependencies for re-execution [2605.25338].

In ATLAS, the source unit is an **atomic source** such as `olympiads`, `stack_exchange`, `gsm8k`, or `synthetic_math`. The purpose is to avoid provenance collapse and to make per-source RL interventions meaningful and comparable because all \(\theta_s\) checkpoints start from the same base model and use the same RL algorithm and hyperparameters [2605.26971].

In RAGONITE, the source unit is an **evidence** derived from a heterogeneous corpus: passages, lists, entire tables, and verbalized table rows. Contextualization augments each evidence with **page title, previous heading, the evidence before, and the evidence after**. This makes the evidence self-contained and source-aware, so attribution can be reported at the level of page URL, section, or table row [2412.10571].

In the autoregressive credit-attribution literature, the source is a record \(s_i\) in a deployment-time dataset \(S\), and a credit-attributing algorithm returns both an output \(y\) and a credit set \(C \subseteq S\). Counterfactual Credit Attribution (CCA) requires that if \(s_i\) is not credited, then the output distribution conditioned on non-crediting \(s_i\) must be indistinguishable from the output distribution when \(s_i\) is removed from the dataset [2605.01425].

This suggests that “source level” is not tied to one canonical unit. It is instead the lowest granularity at which an intervention is judged meaningful, computationally feasible, and semantically interpretable within the application.

## 4. Attribution scores, repairs, and derived supervision

Several SCA systems do not stop at attribution; they use counterfactuals to produce repairs, labels, or quality scores.

CausalFlow uses CRS only as the first stage. Once a step is judged causally responsible, it selects a **minimal counterfactual repair** by maximizing the token-level minimality score
\[
\text{Minimality}(s_i, s_i') = \frac{m}{L}\left(1 - \tfrac{1}{2}\cdot\frac{\left|\;|x|-|y|\;\right|}{L}\right),
\]
subject to successful verification of the repaired trace. The selected repair
\[
s_i^\star = \arg\max_{s_i'} \ \text{Minimality}(s_i, s_i')
\quad
\text{s.t.}
\quad
\mathcal{V}\!\big(y(\tau[i \leftarrow s_i']), x\big)=1
\]
yields a validated contrastive pair \((s_i, s_i^\star)\), which the paper proposes for offline preference optimization, reward modeling, or domain-specific fine-tuning [2605.25338].

ATLAS converts source-level counterfactual outcomes into dataset curation signals. The four categories 00, 01, 10, and 11 are interpreted as unsolved, genuinely learnable, degrade, and overly-easy cases respectively. Aggregating these with scale-dependent weights produces \(L_\mathrm{SCA}\), and this is then used inside the composite dataset quality score
\[
Q(\mathcal{D}; M) \;=\; w_1(M)\,S_1(\mathcal{D}) + w_2(M)\,S_2(\mathcal{D}; M) + w_3(M)\,S_3(\mathcal{D}; M),
\]
where the static learnability term \(S_{1b}\) is derived directly from SCA [2605.26971].

In RAGONITE, attribution over evidence clusters is mapped to source URLs. Evaluation uses the source URL of the highest-scoring cluster, and the system can expose the full attribution distribution in a user interface. Because cluster members retain metadata such as URL and table or row identity, the attribution remains source-grounded rather than merely text-similarity-based [2412.10571].

In the faithfulness-evaluation literature for autoregressive language models, counterfactual editing is used to assess whether an attribution method correctly identifies source tokens whose modification flips the model’s label while keeping inputs fluent and in-distribution. The protocol is contrastive, using
\[
S^C = S^t - S^f,
\]
and it ranks attribution methods by the mean percentage of tokens that must be edited to flip the prediction [2408.11252].

A plausible implication is that SCA often functions as a supervision generator. In agents it produces corrected trace fragments; in RLVR it produces learnability labels for instances and sources; in RAG it produces source-level explanation distributions; and in training-data attribution it produces marginal utility scores for examples or corpora.

## 5. Empirical evaluation and observed behavior

The empirical literature evaluates SCA with markedly different metrics, but a common pattern is comparison against heuristic or non-causal alternatives.

CausalFlow evaluates on **GSM8K**, **MBPP**, **SealQA Hard**, and **MedBrowseComp**. Its reported metrics include **Repair Rate**, **Post-Repair Accuracy**, **Minimality Score**, **CRS Precision**, and an optional **Consensus** score based on multi-agent validation. The paper reports that test-time repair converts **42.7% of failed executions into successes on average**, improves accuracy by **+30.8 percentage points on MedBrowseComp** and **+12.6 on SealQA Hard**, and achieves average minimality scores **0.79–0.87 in most benchmarks**. Reported CRS Precision ranges from **0.68 to 0.84 across tasks** [2605.25338].

ATLAS reports that its lineage analysis attributes **over 99.7% of 1.45M instances to 20 atomic sources**. For the composite quality score \(Q\), the reported correlations with downstream RLVR performance are **Pearson \(r = 0.85\)** and **Spearman \(\rho = 0.60\)** for Qwen3-1.7B, and **Pearson \(r = 0.96\)** and **Spearman \(\rho = 0.94\)** for Qwen3-8B. In benchmark results, **DAPO++** reaches approximately **15.7** Average* at 1.7B and approximately **29.6** at 8B, while on GPQA the reported Qwen3-8B + DAPO++ overall Mean@N is **55.4** [2605.26971].

RAGONITE evaluates on **ConfQuestions**, which contains **300 hand-created conversational questions**, each in **English and German**, for **600 total questions**, grounded in **215 public Confluence pages**. With full contextualization (**+ALL**), retrieval **Precision@1** rises from **0.440** to **0.523** and answer relevance from **0.435** to **0.585**. Attribution accuracy at URL level is reported as **78.9%** over **360 questions where gold URL is in top-10**, with **80.6%** on simple questions, **77.4%** on complex questions, **77.7%** on passage answers, **82.6%** on list answers, **76.6%** on table answers, **77.9%** in English, and **80.0%** in German [2412.10571].

Forward-only attribution is evaluated on the Dattri MNIST–MLP benchmark with **0.11M parameters**, using **LOO** and **LDS**. The reported performance is **LOO ≈ 0.022** and **LDS ≈ 0.49**, and the paper states that these scores match or exceed TRAK while offering forward-only inference [2511.19803].

**Source** is evaluated with **LDS** and subset-removal counterfactual evaluation across regression, image classification, text classification, and language modeling. The paper reports that Source outperforms existing TDA techniques in counterfactual prediction, especially for non-converged models and multi-stage training pipelines [2405.12186].

These results support a narrow but consistent empirical claim: when the intervention is aligned with the causal structure of the source unit, SCA tends to produce more localized or more predictive signals than methods that score sources without explicit counterfactual testing.

## 6. Robustness, bias, and theoretical barriers

The literature also emphasizes that source-level counterfactual reasoning is fragile when the intervention or crediting rule is poorly aligned with the generative process.

In RAG, authorship metadata can alter document attribution even when content is fixed. The attribution-bias study defines **Counterfactually-estimated Attribution Sensitivity (CAS)** as
\[
\operatorname{CAS}(Q) = \frac{1}{|Q|} \sum_{q\in Q} \bigl| M_{\text{Informed}^q} - M_{\text{Vanilla}^q} \bigr|
\]
and **Counterfactually-estimated Attribution Bias (CAB)** as
\[
\operatorname{CAB}(Q) = \frac{\omega}{|Q|} \sum_{q\in Q} \Bigl( M_{\text{Informed}^q} - M_{\text{CF-informed}^q} \Bigr).
\]
The reported results show that adding authorship information can change attribution quality by **3% to 18%**, and the measured CAB values are consistently positive, indicating a bias toward explicit human authorship [2410.12380].

For autoregressive language models, counterfactual interventions must remain in-distribution. The faithfulness-evaluation paper argues that token removal or corruption produces out-of-distribution inputs for autoregressive models, and proposes counterfactual generation instead. Using NLL-based OOD detection, it reports that editor-generated counterfactuals are approximately **1–5% OOD** for the instruct-tuned predictor in one setting, while naive replacements such as `<unk>` or `<mask>` can be far more OOD [2408.11252].

The strongest negative result comes from the study of Counterfactual Credit Attribution for autoregressive models. It proves that CCA does **not** compose autoregressively: there exists a credit-attributing next-token predictor satisfying **\((0,0)\)-CCA** whose credit-attributing rollout is **not \((\varepsilon,\delta)\)-CCA** for any \(\varepsilon \ge 0\) and \(0 \le \delta < 1\). It also proves that black-box **CCA-Retrofit** can require query complexity
\[
\widetilde{\Omega}\bigl(2^\ell\bigr) = \Omega(2^\ell / (\ell\log\ell))
\]
for outputs of length \(\ell+1\) [2605.01425].

These results rule out two natural simplifications. First, token-level credit guarantees do not automatically yield sequence-level credit guarantees. Second, strong sequence-level crediting cannot in general be retrofitted efficiently onto an arbitrary autoregressive model using only black-box access.

A plausible implication is that practical SCA systems for autoregressive generation will need relaxations such as \(\delta>0\), approximate augmentation, non-black-box access, or architectural designs in which source influence is explicit at the sequence level rather than inferred post hoc.

## 7. Open methodological tensions and research directions

Recent work identifies several recurring tensions in SCA.

One tension is **granularity versus tractability**. CausalFlow focuses on single-step interventions because combinatorial multi-step interventions are expensive, even though some failures may involve interacting steps [2605.25338]. ATLAS avoids per-instance RL attribution by operating at the source level because full RL attribution is “global and highly entangled” [2605.26971]. Training-data attribution similarly moves from exact leave-one-out retraining to first-order reweighting or approximate unrolling because exact counterfactuals are too costly [2405.12186].

A second tension is **causal fidelity versus computational budget**. CausalFlow requires \(K\) intervention proposals per step plus downstream re-execution, and ATLAS requires one RL run per atomic source; in the reported setup, this means **20 atomic sources** and multi-day runs per source [2605.26971]. Forward-only influence-style attribution shifts computation from inference to simulation, explicitly targeting deployment regimes where attribution must be served for many queries over a fixed set of sources [2511.19803].

A third tension is **locality versus completeness**. CausalFlow emphasizes minimal repairs and localized edits; RAGONITE removes one cluster at a time rather than exploring all subsets; and the faithfulness-evaluation work measures how small a token-level intervention can still flip the prediction [2605.25338]. This suggests that many SCA methods are optimized for identifying compact, actionable counterfactual sources rather than for exhaustively decomposing all interacting causes.

A fourth tension is **formal credit guarantees versus usable systems**. The CCA results for autoregressive models show that worst-case guarantees can be non-compositional and black-box retrofitting can be exponentially hard [2605.01425]. At the same time, empirical systems such as RAGONITE and CausalFlow demonstrate that restricted, operational counterfactual procedures can still deliver useful source-level explanations or repairs in practice [2412.10571].

Taken together, the current literature presents SCA as a technically heterogeneous but conceptually coherent field. Its central commitment is interventionist: attribution should be assigned to a source only when an explicit counterfactual change to that source produces a meaningful change in outcome. The remaining research problem is not whether this principle is useful, but how to realize it at scale, at the appropriate granularity, and with guarantees that survive the sequential and stochastic structure of modern generative systems.

Source: https://www.emergentmind.com/topics/source-level-counterfactual-attribution-sca