arXiv:2610.21149cs.CLOct 2026

Manuscript Offprint

arXiv:2610.21149

From Observation to Intervention: Distilling Self-Generated In-Context Demonstrations via Executable Causal Intervention

Minming Ye, Min Liu, Haoang Chi, Ciheng Wu, Naiyang Guan

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Self-generated In-Context Learning (ICL) enables LLMs to synthesize their own few-shot demonstrations, often outperforming manual prompts. However, existing methods filter demonstrations by observation, assuming a rationale is high-quality if it leads to the correct output. We show such filtering suffers from observational equivalence, whereby both faithful causal rationales and spurious post-hoc rationales can yield same outputs and are statistically indistinguishable from observation alone. Inspired by independent causal mechanisms, we argue that faithful rationales imply transfer invariance, in which causal rationales should remain effective across logically similar samples. We instantiate this criterion as Executable Causal Intervention for Demonstrations Distillation (ECI2D), which abstracts language rationales into executable programs and applies the causal interventions (do-operator) on logically similar samples, retaining only those demonstrations that imply transfer invariance. Experiments on math, logical and commonsense reasoning benchmarks demonstrate that ECI2D consistently outperforms observation-based ICL while retaining far fewer demonstrations, with gains exceeding 7 points as the test distribution shifts.

1 Introduction

Few-shot in-context learning (ICL) with chain-of-thought (rationale) has become a cornerstone for eliciting reasoning in large language models (LLMs) (Dong et al., 2024; Brown et al., 2020; Wei et al., 2022; Min et al., 2022; Liu et al., 2022). To reduce manual annotation, recent works focus on self-generated ICL, which leverages the generative capacity of LLMs to synthesize in-context demonstrations (Wan et al., 2025; Agarwal et al., 2024; Yang et al., 2024; Li et al., 2024b; Chen et al., 2023; Kim et al., 2022; Zhang et al., 2023). Among them, reinforced ICL (Agarwal et al., 2024; Singh

Figure

Figure 1: Illustration of post-hoc rationalization using Llama3-8B on the GSM8K (Cobbe et al., 2021). Early Answering denotes the original CoT is truncated (denoted by gray) to test if the answer is predetermined, and Adding Mistakes denotes a logical error is injected (highlighted in red) before answering the question.

et al., 2024) samples multiple rationales per training query and retains only those yielding the correct output, reporting gains over human annotation (Li et al., 2024b; Kim et al., 2022). We categorize them as Self-Generated Reinforced ICL.

However, the demonstration distillation criterion of self-generated reinforced ICL simply relies on observation, which is a outcome-oriented criterion that equates answer correctness with rationale quality. Rationales are not always faithful, as shown in Figure 1, LLMs often engage in post-hoc rationalization (Holzinger et al., 2017), generating plausible explanations after answering (Turpin et al., 2023). The faithfulness of post-hoc rationales cannot be guaranteed. We argue that observational distillation suffers from observational equivalence. As shown in Figure 2, based on outcome correctness, the true inference process (comprising both faithful X→Rc→YX \rightarrow R_c \rightarrow Y and spurious Y⇢RsY \dashrightarrow R_s) is statistically indistinguishable from the observed

(a)

Figure

(b)

Observational equivalence: P(Y∣X,R)P(Y \mid X, R) identical (Section 3)

Figure 2: Structural Causal Models (SCMs) in LLM inference. (a) Observed SCM: It treats the observed rationale as the direct causal mediator, forming a linear chain X→Ro→YX \to R_o \to Y. (b) True SCM: The actual mechanism comprises a faithful causal path X→Rc→YX \to R_c \to Y and a spurious post-hoc path where RsR_s is dependent on both X and Y ( X⇢Rs←−YX \dashrightarrow R_s \leftarrow - Y). The two SCMs are observational equivalence as discussed in Section 3.

causal chain X→Ro→YX \to R_o \to Y. Self-generated reinforced ICL fails to disentangle RcR_c from RsR_s, treating them as a single observed variable RoR_o, which leads to the problem of observational equivalence. Critically, our experiments confirm that these unreliable rationales actively misguide the model (Table 1), degrading ICL performance. This naturally raises a question that needs attention:

How can we reliably distinguish faithful causal rationales from spurious post-hoc justifications?

Inspired by the causal invariance (Peters et al., 2016), transportability (Pearl and Bareinboim, 2011), and independent causal mechanisms (Schölkopf et al., 2012), we adopt a practical notion that faithful rationales should exhibit transfer invariance, remaining effective across similar samples. To this end, we propose Executable Causal Intervention for Demonstration Distillation (ECI2D), a novel framework to distill RcR_{c} from RoR_{o} via executable intervention. ECI2D first abstracts language rationales into executable programs. It then generates rationales and intervenes on logically similar samples by replacing the original rationale with these alternatives. We define an intervention-invariant scoring function to quantify transfer invariance, and only those rationales that consistently yield correct results across interventions are identified as the faithful causal path RcR_{c}, while those that fail are discarded as spurious RsR_{s}. Our contributions are fourfold:

• We provide a formal causal analysis of self-generated reinforced ICL, identifying the prevalence of observational equivalence and showing that faithful causal rationales imply transfer invariance (Section 3).

• We propose ECI2D, a framework that utilizes executable programs to perform causal interventions, effectively distilling faithful rationales (Section 4).

• We implement two abstraction forms, showing ECI2D can generalize from deterministic to non-deterministic tasks (Section 4).

• Extensive experiments demonstrate that ECI2D significantly improves performance and OOD generalization compared to both manual and self-generated reinforced ICL baselines (Section 5 and 6).