acceptodds
Published as a conference paper at NeurIPS 2026

Can LLMs explain themselves truthfully with code?

Nhi Nguyen, Shauli Ravfogel, Rajesh Ranganath

Abstract

Large language models (LLMs) are increasingly used in high-stakes settings where they are expected to justify their predictions, and a common approach to understanding LLM predictions is via self-generated free-text explanations. However, free-text explanations are instance-wise and non-executable, making it hard to evaluate their alignment with model behavior or explain dataset-level behavior in a compact, human-interpretability manner. We study code as an executable alternative to free-text, enabling automatic evaluation and dataset-level explanation, and ask whether LLMs can consistently explain their behaviors with code. This automatic verification enables a generation procedure that samples multiple candidate programs and selects the most consistent one. Using three open-source code-capable models and eight tasks with varying levels of linguistic difficulty, we study when LLMs produce consistent code explanations. We find that models can produce highly consistent code explanations in a subset of settings, but strong consistency is not the norm. Consistency is substantially lower for tasks involving more complex linguistic components, where performance is often near random guessing across models. In these harder settings, generated programs are longer but not more structurally complex, and increasingly rely on hard-coded linguistic patterns from the input. These findings suggest two possibilities: either LLMs are not good at producing compact explanations of their behavior, or some behaviors require dense, distributed computation that cannot be explained by compact, human-interpretable programs. Finally, we find that model-internal representations do not reliably predict when code explanations will be consistent, suggesting that LLMs do not know when they can or cannot explain their own behavior with code. Our work highlights code as a compact and verifiable alternative to free-text explanations, while also revealing limitations in using compact, human-understandable explanations to fully understand LLM behavior.

Keywords:
Sydney, Main Track

Reviews

Among:
Shape:
123456this paper, Bottom 17%
Figure 1. Mean review rating of the reviewed papers at NeurIPS 2026. This paper averages 4.00 over 3 reviews, above 17% of the others.
Reviewer_AGBFOpenReview ↗
Rating
3
Clarity
3
Confidence
3
Originality
2
Quality
2
Significance
2
Read review
Summary

This paper proposes using executable code (Python programs) as an alternative to free-text explanations for understanding LLM behavior. The key idea is that code explanations are executable and can be automatically verified against model outputs, unlike free-text explanations which require perturbation-based evaluation. The authors introduce a "code explanation consistency" metric (fraction of dataset examples where the program's output matches the model's output), a best-of-100 generation procedure, and study when three open-source LLMs (Gemma3-27B, Qwen2.5-Coder-32B, Llama3.1-70B) can produce consistent code explanations across eight BBH tasks of varying linguistic complexity. Main findings: (1) high consistency is achievable in 6/24 model-task settings but is not the norm; (2) tasks with complex linguistic components are harder; (3) hard-task programs degenerate into lookup tables rather than compact algorithms; (4) model-internal representations do not predict whether code explanations will be consistent.

Strengths and weaknesses

Strengths

  1. The formalization in Section 3 is precise. The consistency metric (Eq. 4) is simple, interpretable, and well-motivated. The normalized version (CONSISTENCY_OVER_RANDOM, Eq. 5) enables cross-task comparison. The generation procedure (Algorithm 1) is straightforward and reproducible.
  2. The four-category grouping (structured logic → logic + simple language → logic + complex language → linguistic reasoning) creates a natural difficulty gradient that produces interpretable results. The finding that consistency degrades along this axis is clean and informative.
  3. Probing whether models "know" when they can produce consistent explanations is exactly the kind of meta-cognitive question the explainability community needs to investigate. The negative result (R² < 0 for all models) is informative, suggesting self-generated explanations lack reliable confidence signals.
  4. The idea of using code as an explanation medium is genuinely insightful.

Weakness

  1. The paper's results are almost tautological: code works as an "explanation" for tasks that are already algorithmic (Navigate = followdirection instructions), and fails for tasks that require actual language understanding. This is not a novel insight. If the code uses hardcoded linguistic patterns (which is what they observe) — it's not an explanation, it's a lookup table. It doesn't generalize and tells you nothing about how the model processes language.
  2. The motivation of the paper is not clear. Why we need dataset level explanation, and what is the benefit of them if we cannot gurantee consistency?
  3. One of the three claimed advantages of code over free-text is "potential compactness" and the ability to provide "compact, human-understandable" explanations, However this is not evaluated properly.
  4. The generation procedure (Algorithm 1) samples 100 candidate programs and selects the one with the highest consistency on the full dataset D. This is best-of-100 selection evaluated on the same data used for selection—there is no held-out evaluation. The reported "max consistency" numbers are optimistically biased.
  5. The paper argues code is better than free-text, but never directly compares. For the same tasks, how faithful are free-text CoT explanations? If free-text is equally (un)faithful, the advantage of code reduces to ease-of-evaluation only.
  6. The paper studies self-explanation (model explains itself). What happens if Model A generates code to explain Model B's behavior? If a different model can explain the behavior equally well (or poorly), it suggests the code explanations are behavioral imitation rather than introspective self-knowledge.
Questions
  1. Have you tried having Model A explain Model B's behaviour? If cross-model explanations are equally (in)consistent, it suggests the difficulty is in program synthesis from examples, not in self-knowledge.
  2. The generation procedure (Algorithm 1) samples 100 candidate programs and selects the one with the highest consistency on the full dataset D. This is best-of-100 selection evaluated on the same data used for selection—there is no held-out evaluation. Doesn't the "max consistency" numbers are optimistically biased?
  3. What happens if you explicitly instruct the model NOT to hardcode input patterns? Does consistency drop, or do models find more general solutions?
Limitations

Yes

Paper formatting concerns

No concern

1 comment

We thank the reviewer for the constructive feedback and positive assessment of our formalization, consistency metric, and motivation for studying code explanations. We agree that the paper should better clarify the scope of our claims and further evaluate the practical advantages and limitations of code explanations. We address each concern below.


Code consistency across tasks may appear expected

We agree that it may be intuitive for code explanations to succeed on algorithmic tasks while struggling on complex linguistic tasks. However, because LLMs themselves are programs that can perform complex linguistic tasks, it remains an open question whether they can also generate interpretable programs that consistently capture their behavior in the same tasks. Our empirical evaluation is therefore necessary to answer this question.

We also agree that hard-coded programs are not desirable explanations. However, our main contribution is not a superior explanation generation method, but the introduction of executable explanations as a new direction with two key advantages: compact dataset-level explanations and automatic verification. A single code explanation can explain an entire dataset, while automatic verification enables both the consistency evaluation proposed in this paper and future optimization of explanations, for example, by using consistency feedback and LLM agents to iteratively refine and improve code explanations.

We will clarify this motivation in the revised paper and better position our work as an initial step toward automatically verifiable and compact dataset-level explanations.


Motivation for dataset-level explanations

We agree that consistency, or whether an explanation accurately reflects the model’s internal computation, is the primary requirement for useful explanations, whether instance-level or dataset-level. However, prior work has shown that evaluating whether an explanation reflects a model’s computation necessarily requires assessing the model’s behavior over a distribution of inputs [1], typically through input perturbations [2,3]. This motivates us to study dataset-level explanations directly, as their goal is to capture model behavior over an input distribution, which is already required to assess the explanation’s alignment with the model’s internal computations. While our paper briefly discusses the role of input distributions in evaluating instance-wise explanations, we did not clearly articulate it as the motivation for studying dataset-level explanations. We will revise the paper to make this motivation more explicit.


Comparison with free-text explanations

New experiments: Following your suggestion, we directly compare the faithfulness of code and CoT explanations to the underlying computation in the model. To quantify CoT faithfulness, we use self-consistency sufficiency (SCSuff) [1], which measures whether an explanation sufficiently captures a model’s behavior by having the model generate alternative inputs consistent with the explanation and comparing the resulting output distribution with the original one. To enable direct comparison, we construct the code explanation’s output distribution by assigning 99% probability to its predicted answer and replace the fuzzy-matching score in Eq. (4) with the expected KL divergence used in SCSuff. This allows us to preserve automatic verification for code. Additionally, we quantify the compactness of each explanation type by comparing the token and character counts of the best code explanation with the corresponding aggregate token and character counts of the collection of chains of thought, similar to Section 5.2.

We evaluate four tasks spanning different complexity levels. Table 1 shows that, on average, code explanations are 70x more compact than free-text explanations when explaining dataset-level behaviors. However, neither code nor free-text explanations consistently outperform the other in sufficiency. As we discussed above, however, our goal is not to replace free-text explanations, but to introduce code explanations as a new explanation direction with unique advantages in compactness and automatic verification. These results suggest that there is substantial room for improving code explanation while preserving its compactness advantage.

We agree that this comparison is important and will include it as a main experiment in the revised paper.

Table 1: Code vs. Free-text explanations

ModelTaskCode # charCode # tokenCode SuffText # charText # tokenText Suff
GemmaNavigate32017090.767129480382120.815
Qwen25114980.695169233425970.322
Llama20044380.868200709507020.098
GemmaHyperbaton23457010.853178313505160.901
Qwen23646570.787200977526730.431
Llama25316100.621200017508660.664
GemmaDisambiguation QA12013500.8673862688310.527
Qwen458511660.646245296551480.460
Llama11943120.328193526428130.746
GemmaSnarks582414400.621134035288400.713
Qwen12122900.594144229295600.288
Llama24306100.472143702296680.811

Evaluate consistency on held-out split

We agree with the reviewer that selecting the best code explanation and evaluating it on the same dataset could inflate the reported consistency. To verify whether this affects our conclusions, we repeat the program selection and evaluation using a held-out split. Specifically, we split each dataset in half, select the most consistent code explanation using the first half, and evaluate its consistency on the second half. Table 1 compares the held-out consistency compared with the originally reported consistency.

The held-out consistency results in only modest changes, ranging from -0.14 to 0.04. In addition, 15 of the 24 model-task settings select the same code explanation originally selected in the paper. Importantly, all of our main conclusions remain unchanged, including the overall level of code consistency, the relationship between task complexity and explanation consistency, and the decrease in the compactness of the selected program as task complexity increases.

Although the held-out evaluation does not change our conclusions, we agree that it provides a more accurate estimate of code consistency. We will update Algorithm 1 and recompute all experimental results using this held-out selection and evaluation procedure.

Table 2: Held-out consistency

ModelTaskOriginal consistencyHeld-out consistency
GemmaWeb of lies0.9960.992
Qwen0.9240.936
Llama0.4680.504
GemmaNavigate0.7440.776
Qwen0.6600.704
Llama0.8630.895
GemmaHyperbaton0.8440.800
Qwen0.7680.760
Llama0.5730.520
GemmaObject counting0.7480.768
Qwen0.2740.266
Llama0.7840.760
GemmaFormal fallacies0.5440.456
Qwen0.5560.552
Llama0.5400.552
GemmaDisambiguation QA0.8880.880
Qwen0.5850.581
Llama0.4070.342
GemmaSnarks0.5790.528
Qwen0.5390.543
Llama0.5480.407
GemmaTranslation error0.2020.122
Qwen0.3760.408
Llama0.3980.352

Cross-model explanations

Although our framework is motivated by LLM self-explanations, it also applies to post-hoc explanations generated by another model. Following the reviewer’s suggestion, we perform cross-model explanation experiments using Gemma and Qwen to explain each other (Table 3). Cross-model explanations achieve similar consistency to self-explanations, with the largest difference being 0.06. These results suggest that automatic consistency evaluation enables selecting post-hoc explanations that are most consistent with a model’s behavior without requiring privileged access to the model’s internal computation.

We will include this experiment in the revised paper and clarify that our framework is applicable to both self-explanations and post-hoc/cross-model explanations.

Table 3: Consistency with cross-model explanations

ModelTaskSelf-explanationCross-model explanation
GemmaWeb of lies0.9960.996
Qwen0.9240.924
GemmaNavigate0.7440.752
Qwen0.6600.720
GemmaHyperbaton0.8440.740
Qwen0.7680.820
GemmaObject counting0.7480.644
Qwen0.2740.274
GemmaFormal fallacies0.5440.580
Qwen0.5560.572
GemmaDisambiguation QA0.8880.868
Qwen0.5850.597
GemmaSnarks0.5790.562
Qwen0.5390.539
GemmaTranslation error0.2020.307
Qwen0.3760.396

Instruct model not to hard code

Following the reviewer’s suggestion, we add the instruction: "Infer the underlying algorithm rather than memorizing or hardcoding the examples. Your solution should generalize to unseen inputs." We evaluate this prompt across the four complex tasks (Table 4). The added instruction does not systematically improve consistency. The largest gain (+0.14 on Gemma-Translation Error) comes from additional phrase-level mappings rather than a more general algorithm, suggesting that prompt engineering alone is insufficient to reduce hard-coding. Further work is needed to optimize code consistency and reduce hard-coding in code explanations on complex tasks.

Table 4: Instruct model not to hard code

ModelTaskOriginal promptNo-hard-code prompt
GemmaFormal fallacies0.5440.552
Qwen0.5560.564
Llama0.5400.524
GemmaDisambiguation QA0.8880.872
Qwen0.5850.548
Llama0.4070.378
GemmaSnarks0.5790.573
Qwen0.5390.590
Llama0.5480.554
GemmaTranslation error0.2020.342
Qwen0.3760.376
Llama0.3980.281

References

[1] https://arxiv.org/abs/2606.28615

[2] https://dl.acm.org/doi/10.5555/3666122.3669397

[3] https://arxiv.org/abs/2505.05410


Once again, we thank the reviewer for their constructive feedback and believe these additional analyses clarify the strengths and limitations of code explanations and strengthen the paper as an initial step towards automatically verifiable and compact dataset-level explanations.

Reviewer_asX3OpenReview ↗
Rating
5
Clarity
2
Confidence
4
Originality
3
Quality
2
Significance
3
Read review
Summary

This paper measure whether language models can explain their behavior by generating Python programs that reproduce their answers. Across three models and eight reasoning tasks, the authors find that these programs can closely match model behavior on some structured tasks, but often fall back on shortcuts, memorized examples, or weak heuristics for language-heavy tasks. Overall, executable code provides a concrete way to test explanations, while revealing that current models can produce reliable behavioral explanations only in limited settings.

Strengths and weaknesses

Strength:

One of the strength in this paper is turning explanations into executable programs, making behavioral agreement directly testable rather than subjective. Its evaluation covers three models, eight tasks, and many generated programs, while clearly separating task accuracy from fidelity to the model. The figures and complete appendix programs are especially valuable because they transparently reveal a meaningful spectrum, from reusable algorithms to shortcuts and memorization, highlighting some of the successes and failures as good contribution.

Weaknesses:

  • The metric does not establish truthful reasoning. Code consistency measures whether a program reproduces the model’s outputs, not whether it represents the internal process that produced them.
  • The reported scores are not clean estimates. Programs are generated from examples in the dataset, evaluated on the full dataset, and the best of 100 is selected using those same results. This can reward memorization and make the strongest results appear more reliable than they would be on new inputs.
  • The evaluation lacks sufficiently strong baselines. Because the current baseline assumes uniformly distributed model outputs, it does not determine whether the generated programs capture meaningful behavior beyond majority prediction or demonstration memorization. This makes the reported consistency improvements difficult to interpret.
Questions

What exactly is the experimental unit in the hidden-state analysis? Please clarify the number of unique prompts and hidden-state vectors, whether repeated versions of the same prompt can appear in different cross-validation folds, and how ridge regularization and feature scaling were selected.

What evidence shows that this is self-explanation rather than ordinary task induction? Using existing predictions, please report consistency separately when the target model is correct and incorrect.

Limitations

Not completely. The limitations should acknowledge evaluation overlap and selection bias, weak baselines, the absence of self vs external controls, and that behavioral agreement does not establish truthful internal reasoning. The authors should also mention the narrow task/probe scope and the risks of executing or overtrusting the generated code.

Paper formatting concerns

N/A

Final justification

The held-out selection/evaluation split, majority-class baseline, and correct-versus-incorrect consistency analysis directly address my main methodological concerns, while the additional hidden-state details resolve my reproducibility question. I have raised my score accordingly.

1 comment

We thank the reviewer for their feedback and positive assessment of our framework, experiments, and analysis. We address your concerns below, and will incorporate the suggested clarifications and additional experiments in the revised version.


Truthfulness vs. Consistency

The reviewer correctly points out that code consistency does not guarantee that a program truthfully reflects a model’s internal reasoning. This is not a claim we intended to make. Throughout the paper, we evaluate the behavioral consistency between code explanations and the original LLM, and do not claim that such consistency guarantees truthfulness to the model’s reasoning. However, behavioral consistency is an important prerequisite for truthful reasoning, especially in black-box settings where we cannot directly access model internals [1].

We agree that the title could be interpreted more broadly than intended, and will revise it to remove the word “truthfully” to better reflect the scope of our paper.


Evaluate consistency on held-out split

We agree with the reviewer that selecting the best code explanation and evaluating it on the same dataset could inflate the reported consistency. To verify whether this affects our conclusions, we repeat the program selection and evaluation using a held-out split. Specifically, we split each dataset in half, select the most consistent code explanation using the first half, and evaluate its consistency on the second half. Table 1 compares the held-out consistency compared with the originally reported consistency.

The held-out consistency results in only modest changes. The maximum decrease in consistency is 0.14, while most differences range between -0.09 and 0.04. In addition, 15 of the 24 model-task settings select the same code explanation originally selected in the paper. Most importantly, all of our main conclusions remain unchanged, including the overall level of code consistency, the relationship between task complexity and explanation consistency, and the decrease in the compactness of the selected program as task complexity increases.

Although the held-out evaluation does not change our conclusions, we agree that it provides a more accurate estimate of code consistency. Thus, in the revised version, we will update Algorithm 1 and recompute all experimental results using this held-out selection and evaluation procedure.

Table 1: Held-out consistency

ModelTaskOriginal consistencyHeld-out consistency
GemmaWeb of lies0.9960.992
Qwen0.9240.936
Llama0.4680.504
GemmaNavigate0.7440.776
Qwen0.6600.704
Llama0.8630.895
GemmaHyperbaton0.8440.800
Qwen0.7680.760
Llama0.5730.520
GemmaObject counting0.7480.768
Qwen0.2740.266
Llama0.7840.760
GemmaFormal fallacies0.5440.456
Qwen0.5560.552
Llama0.5400.552
GemmaDisambiguation QA0.8880.880
Qwen0.5850.581
Llama0.4070.342
GemmaSnarks0.5790.528
Qwen0.5390.543
Llama0.5480.407
GemmaTranslation error0.2020.122
Qwen0.3760.408
Llama0.3980.352

Self-explanation vs. Task induction

The reviewer raises an important point that generated programs might simply solve the task instead of explaining the LLM. In Figure 2, we report task accuracy alongside code consistency to show that consistency is not determined solely by accuracy; for example, Llama on Web of lies achieves high accuracy but low consistency, whereas Gemma on Disambiguation QA shows the opposite phenomenon.

Following the reviewer’s suggestion, we also report consistency separately on examples where the LLM is correct and incorrect (Table 2). We observe no systematic tendency for the selected code explanations to only explain the model's correct predictions. About half of the settings have higher consistency on incorrect examples, while the other half have higher consistency on correct examples.

There are four settings where consistency on incorrect examples is zero. However, only one of these cases also achieves perfect consistency on correct examples. Furthermore, all four cases are settings with high task accuracy (> 0.92), which suggests a possible alternative interpretation: the generated program captures the model’s behavior on the vast majority of the examples where the model performs the task correctly, but fails to capture the rare cases when the model makes mistakes.

Nevertheless, these cases represent 16% of the experimental settings, suggesting that stratified consistency is a useful diagnostic measure for whether the selected program is simply solving the task instead of explaining the target model. Thus, we plan to report these metrics in the paper, and discuss incorporating them as a penalty in the program selection procedure to discourage explanations that only explain the model’s correct predictions.

Table 2: Consistency on examples where the LLM is correct/incorrect

ModelTaskConsistency on correct examplesConsistency on incorrect examples
GemmaWeb of lies1.0000.983
Qwen1.0000.000
Llama0.4900.000
GemmaNavigate0.7510.556
Qwen0.6350.857
Llama0.8840.813
GemmaHyperbaton0.8450.800
Qwen0.7800.444
Llama0.5710.578
GemmaObject counting0.7730.000
Qwen0.2620.279
Llama0.8170.000
GemmaFormal fallacies0.5350.595
Qwen0.5510.583
Llama0.5360.581
GemmaDisambiguation QA0.8960.884
Qwen0.5920.582
Llama0.3330.444
GemmaSnarks0.5560.720
Qwen0.5560.488
Llama0.5760.481
GemmaTranslation error0.2090.200
Qwen0.3140.506
Llama0.3730.408

Uniform random vs Majority-class baseline

We thank the reviewer for suggesting the majority-class baseline and agree that it is a stronger baseline than uniform random. We computed the majority-class baseline for every model-task setting and reevaluated our analyses using consistency over majority baseline (Table 3).

The majority baseline is noticeably stronger than the uniform random baseline for some tasks, particularly Navigate (+0.10) and Translation error (+0.14). One exception reported in the paper (lines 223-226) also changes: Gemma on Disambiguation QA is no longer highly consistent under this stronger baseline. Importantly, however, our main conclusions remain unchanged: For the first four (simpler) tasks, at least one model still achieves more than 25% improvement over the baseline, whereas for all four more complex tasks, all models remain below 25% improvement. Thus, the overall consistency trends reported in the paper are unchanged.

Since the majority-class baseline is stronger and tailored to each model’s output distribution, we will replace the uniform random baseline with the majority-class baseline throughout the revised paper.

Table 3: Majority-class baseline

ModelTask# OutputMajority answer proportionConsistency over majority baseline
GemmaWeb of lies20.5080.488
Qwen0.5240.400
Llama0.532-0.064
GemmaNavigate20.6160.128
Qwen0.6600.000
Llama0.6050.258
GemmaHyperbaton20.5360.308
Qwen0.5120.256
Llama0.5730.000
GemmaObject counting170.1040.644
Qwen0.1010.173
Llama0.1040.680
GemmaFormal fallacies20.5280.016
Qwen0.5560.000
Llama0.5200.020
GemmaDisambiguation QA30.8680.020
Qwen0.5360.048
Llama0.4070.000
GemmaSnarks20.5110.067
Qwen0.5340.006
Llama0.5420.006
GemmaTranslation error60.307-0.105
Qwen0.3760.000
Llama0.2370.161

Hidden-state analysis experimental details

In Figure 4, each data point corresponds to a last-token hidden state of a prompt used to generate code explanations (step 3 of Algorithm 1). We construct P=10P = 10 prompts for each of the eight datasets, resulting in 80 hidden-state vectors for each model. For each prompt, we sample M=10M = 10 programs and assign the best consistency score to the data point corresponding to that prompt. The first and second rows of Figure 4 visualize the same hidden-state vectors, only differing in whether the targets/colors are Consistency or Consistency over baseline. Each column corresponds to a different model, so no prompt appears across multiple columns. The ridge regression experiments use standard 5-fold cross-validation with random fold assignment, default StandardScaler from the scikit-learn library, and Ridge(alpha=1.0).

We will add these implementation details to the paper to improve reproducibility and clarify the interpretation of the analysis.


References

[1] https://aclanthology.org/2024.acl-long.329/


We thank the reviewer again for the constructive feedback and believe these additional analyses strengthen the paper’s methodology and empirical evaluation.

Reviewer_YMY7OpenReview ↗
Rating
4
Clarity
3
Confidence
3
Originality
3
Quality
2
Significance
3
Read review
Summary

Motivated by the limitations of LLM-generated free-text explanations to be instance-wise and non-executable, this work proposes using LLM-generated code as explanations, which are executable and can be applied at the dataset level. The authors introduce a consistency metric that measures how often a program reproduces the model's outputs, along with a framework that samples multiple candidate programs and selects the most consistent one. Results show that LLMs can produce highly consistent code explanations only for certain tasks, with performance degrading on linguistically more complex tasks. The authors further explore whether model-internal representations encode when a consistent code explanation will be produced, but find that they do not.

Strengths and weaknesses

Strengths

This work proposes using LLM-generated code as explanations instead of free-text, motivated by the fact that code is executable and can be directly verified against model outputs at both the instance and dataset level. The proposed idea is well motivated and addresses current research gaps. They introduce CONSISTENCY, a metric measuring how often a generated program reproduces the model's outputs over a dataset, they also run comprehensive experiments across three model families and eight tasks of varying linguistic complexity, evaluates code explanation consistency systematically.

Weaknesses

The proposed angle is novel and well-motivated, but most experiments demonstrate when code explanations fail rather than demonstrate their usefulness. Two of four research questions get negative or weak answers: "strong consistency is not the norm", "only a partial positive answer to Q1" (L214–215), and hidden states give a "negative answer to Q4" (L273–274). So the framing promises more than the evidence supports. Negative results are valuable, and more specifically:

  1. No free-text baseline. The paper repeatedly claims code is "at least as capable as free-text explanations" (L122; Section 3.1), yet never compares the two empirically. How do free-text explanations perform on the tasks where code fails? Even a comparison on a task subset, or using another faithfulness metric, would substantiate this central claim, which is currently asserted but not tested.

  2. Limited practical value. For Q1, code explanations are consistent mainly on simpler tasks, but likely free-text (e.g., CoT) is already sufficient. Meanwhile, compactness is claimed as a advantage, yet Section 5.2 shows programs become less compact and rely on hard-coding on complex tasks. This weakens the usefulness of the code explanations.

  3. Shallow analysis of the failures. The two proposed causes (L256–260) for Q3 are stated but not investigated. A case study correlating code generations with task characteristics would turn diagnostic observations into actionable insight, like identifying recurring failure patterns such as missing hierarchical/abstracted structures.

  4. The abstract, intro, and conclusion repeatedly state the findings, these could be shortened for some sections.

Questions

Q1. Regarding the two possible explanations for low consistency on complex tasks (L61–63, L286–288, L297-301): do the authors have any arguments supporting each, or preference about which is more likely? Is there any preliminary evidence pointing toward one over the other?

Q2. Why is the generated code framed as a "sparse program" (L91–93)? The rest of the paper makes no further claims about sparse vs. dense computation, and this part of the related work seems only weakly connected to the main text. Could the authors clarify why are the codes "sparse" and how the sparse-program framing relates to the main text?

Q3. There is no analysis or justification for the chosen hyperparameters (P = 10 example sets, N = 20 in-context examples, M = 10 explanations per set; L196–197). N in particular seems important, since the number of in-context examples could directly affect both generalization and the tendency to hard-code. Was N = 20 chosen for a specific reason, and could the authors provide an ablation showing how consistency varies with N and maybe other hyperparameters?

Q4. Tasks are grouped by linguistic complexity (L192), but how is this complexity actually measured? If the grouping is assigned subjectively rather than via a systematic metric, the answer to (Q2) becomes unstable: the observed drop in consistency may not stem from linguistic complexity, but from other characteristics of the specific tasks or datasets. Could the authors clarify the criteria used, or provide an objective complexity measure to support this?

Limitations

Yes

Paper formatting concerns

No

Final justification

The rebuttal addressed my main concerns. The new comparison against free-text explanations tests the paper's central claim, and the other clarifications resolve my remaining questions. I raise my score from 3 to 4.

1 comment

We thank the reviewer for the positive assessment of our motivation and evaluation. We agree that the paper should better establish the advantages of code explanations empirically and clarify the scope of our conclusions. We address each concern below.


Comparison with free-text explanations

We agree with the reviewer that an empirical comparison between code and free-text explanations would strengthen the paper.

New experiments: Following your suggestion, we directly compare the faithfulness of code and CoT explanations to the underlying computation in the model. To quantify CoT faithfulness, we use self-consistency sufficiency (SCSuff) [1], which measures whether an explanation sufficiently captures a model’s behavior by having the model generate alternative inputs consistent with the explanation and comparing the resulting output distribution with the original one. To enable direct comparison, we adapt our code consistency metric by constructing the code explanation’s output distribution by assigning 99% probability to its predicted answer, and replacing the fuzzy-matching score in Equation (4) with an expected KL divergence used in SCSuff. This allows direct comparison between code and free-text explanations while preserving automatic verification for code. Additionally, we quantify the compactness of each explanation type by comparing the token and character counts of the best code explanation with the corresponding aggregate token and character counts of the collection of chains of thought, similar to Section 5.2.

We evaluate four tasks spanning different complexity levels (Navigate, Hyperbaton, Disambiguation QA, and Snarks). Table 1 shows that, on average, code explanations are 70x more compact than free-text explanations when explaining dataset-level behaviors. However, neither code nor free-text explanations consistently outperform the other in sufficiency: code explanations achieve higher sufficiency in exactly half of the settings. As we will discuss next, however, our goal is not to replace free-text explanations, but to introduce code explanations as a new explanation direction with unique advantages in compactness and automatic verification. These results suggest that there is substantial room for improving code explanation generation while preserving its compactness advantage.

We agree that this comparison is important and will include it as a main experiment in the revised paper. We will include results on all tasks, a description of SCSuff and the corresponding adaptation of code consistency, and a broader discussion of the practical strengths and limitations of code explanations.

Table 1: Code vs. Free-text explanations

ModelTaskCode # charCode # tokenCode SuffText # charText # tokenText Suff
GemmaNavigate32017090.767129480382120.815
Qwen25114980.695169233425970.322
Llama20044380.868200709507020.098
GemmaHyperbaton23457010.853178313505160.901
Qwen23646570.787200977526730.431
Llama25316100.621200017508660.664
GemmaDisambiguation QA12013500.8673862688310.527
Qwen458511660.646245296551480.460
Llama11943120.328193526428130.746
GemmaSnarks582414400.621134035288400.713
Qwen12122900.594144229295600.288
Llama24306100.472143702296680.811

Practical values of code explanations

The reviewer notes that code explanations succeed mainly on simpler tasks, where free-text explanations may already suffice. Our new comparison above shows that while chain-of-thought explanations do not dominate code explanations over all simpler tasks, they can be more sufficient than our code explanations in several settings.

Our main contribution, however, is not to propose a drop-in replacement for free-text explanations. Rather, we introduce executable explanations as a new direction with two key advantages: compact dataset-level explanations and automatic verification. A single code explanation can explain an entire dataset, making it significantly more compact than sample-level free-text explanations, as shown in Table 1. Moreover, automatic verification enables both the consistency evaluation proposed in this paper and future optimization of explanations, for example, by using consistency feedback and LLM agents to iteratively refine and improve code explanations. Such optimization approaches are difficult for free-text explanations as they are not easily verifiable.

We will clarify this motivation for introducing code explanations in the revised paper and better position our negative findings as identifying opportunities for improving LLM explanations in future research.


Low consistency analysis and task complexity

We agree with the reviewer that a deeper taxonomy of when code explanations succeed or fail would improve the practical value of the paper. Our grouping by linguistic complexity is intended as a preliminary exploration, and the tasks were grouped before any consistency analysis using subjective intuitions about which steps are involved in solving each task. We agree that a more systematic complexity measure would provide stronger evidence for the relationship between code consistency and task complexity. However, a comprehensive taxonomy of failure modes and case studies across a broader range of tasks would require substantially more analysis than fits within the scope of this paper. In the revised paper, we will discuss this limitation of our task grouping criteria and highlight more systematic studies of task complexity and failure modes as important directions for future work.

Regarding the two possible explanations for the observed low consistency, we believe the first is more likely in our setting: LLMs are not trained to directly produce executable self-explanations from a single-turn few-shot prompt. One piece of supporting evidence is that code consistency is imperfect even on the simplest tasks, suggesting that the challenge is not solely due to task complexity. Since code explanations are automatically verifiable, it is possible to optimize them, for example, by iteratively asking an LLM agent to refine the generated program based on its consistency score. Therefore, the observed relationship between low consistency and task complexity may be alleviated with better optimization.

We will include this discussion in the revised paper and highlight optimization of executable explanations as an important direction for future work.


Connection between sparse programs and code explanations

The reviewer points out that we did not discuss sparse programs past the related work. We agree that the connection between sparse programs and code explanations can be better clarified in the main text. By sparse programs, we mean a human-understandable symbolic program composed of a small number of basic operations, in contrast to the dense matrix computations performed by LLMs (after all, an LLM implemented in PyTorch is also a program). Our motivation is that explaining an LLM can be viewed as approximating the behavior of a dense computation with a compact, symbolic program. We will clarify this connection and consistently use the term human-understandable program throughout the paper to avoid confusion.


Hyperparameter choices

The reviewer asks about our choices of hyperparameters. As mentioned above, our goal is not to optimize the code explanation generation procedure, but to evaluate a simple generation strategy as a starting point for studying executable explanations. For the number of in-context examples, we choose N=20N = 20 as a representative number of few-shot settings that can provide sufficient context about the model's behavior for the LLM to generate general code explanations.

Following the reviewer’s suggestion, we evaluate Qwen with varying N∈{5,20,30}N \in \\\{5, 20, 30\\\}. Consistency changes on several tasks: for example, consistency on Object counting improves substantially with fewer in-context examples (+0.496), whereas consistency on Hyperbaton decreases for both smaller and larger NN values (-0.224). These results confirm that the choice of NN can affect code consistency, but neither increasing nor decreasing NN consistently improves it across tasks. Importantly, the paper’s main conclusions, including the low consistency on the four more complex tasks, stay unchanged. We will include this ablation in the revised paper and leave a more comprehensive study of hyperparameter optimization to future work.

Table 2: Consistency with different numbers of in-content examples

ModelTaskN = 20 (original)N = 5N = 30
QwenWeb of lies0.9240.9240.924
Navigate0.6600.7480.748
Hyperbaton0.7680.5640.544
Object counting0.2740.7740.331
Formal fallacies0.5560.5640.556
Disambiguation QA0.5850.5520.540
Snarks0.5390.5620.551
Translation error0.3760.3760.376

References

[1] https://arxiv.org/abs/2606.28615


Once again, we appreciate the reviewer’s constructive feedback. We believe these additional experiments better establish the strengths and current limitations of code explanations, and strengthen the paper as an initial step towards automatically verifiable and compact dataset-level explanations.

Comments on the paper

1 comment
Meta-review

The paper proposes using LLM-generated code as a compact, automatically verifiable explanation of LLM behavior, evaluated across 3 model families and 8 tasks. I have read the authors' rebuttal in full.

The rebuttal directly addressed the concerns raised in the initial review. Held-out evaluation showed the original selection procedure was not materially inflating consistency scores, and a majority-class baseline preserved the paper's main trends. The correct/incorrect consistency breakdown found no systematic tendency for programs to only explain correct predictions. The cross-model experiment showed cross-model consistency close to, and in most settings at least as high as, self-explanation consistency; while this leaves the paper's specific self-explanation framing not fully established, the authors' broader claim - that consistency evaluation is useful regardless of whether the explanation is self-generated or post-hoc - is supported by this result. The free-text comparison showed code explanations are substantially more compact (roughly 70x by character count) without consistently sacrificing sufficiency relative to free-text, directly testing the paper's central comparative claim.

Reviewer YMY7 reviewed the free-text comparison and raised their score from 3 to 4, confirming it tests the paper's central claim. Reviewer asX3 reviewed the held-out split, majority baseline, and correct/incorrect breakdown in detail and raised their score from 4 to 5, confirming these resolved their methodological concerns, including reproducibility of the hidden-state analysis. Reviewer AGBF did not respond to a direct, targeted invitation to assess the rebuttal during the discussion period; their original rating (3, Borderline reject) does not reflect the new evidence, particularly the cross-model and no-hard-code experiments that were direct responses to their questions. I am disclosing this explicitly: I have factored the substance of AGBF's original concerns into my own assessment above, but do not have their confirmation on whether the new evidence resolves them.

I recommend Accept (poster). Two of three reviewers independently reviewed the rebuttal evidence in detail and moved to accept; the rebuttal's methodological fixes (held-out evaluation, stronger baseline) are sound and corroborated, and the remaining open question - whether the paper's framing around self-explanation specifically, versus explanation more generally, is fully earned by the cross-model result - is a scoping/framing issue for the authors to address in camera-ready (e.g., tempering the self-explanation framing given the cross-model finding) rather than a basis for rejection. I encourage the authors to incorporate all rebuttal experiments (held-out evaluation, majority baseline, free-text comparison, cross-model results, correct/incorrect breakdown) into the camera-ready version, and to explicitly discuss the cross-model finding as evidence that the framework applies to post-hoc explanation broadly, not only self-explanation.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.