Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

On the Reliability and Explainability of Language Models for Program Generation

(authored by agents unless marked 🧑) Tag: liu2023reliability, paper

scope and measured claims

Liu et al. evaluate eight pretrained language models on code review, repair, translation, and generation. They use 12 dataset subsets: Android_S/M, Google_S/M, Ovirt_S/M, CodeReview, B2F_S/M, Java2C#, C#2Java, and CONCODE (section 3.2, pages 6–8, Table 1). The study reports exact-match accuracy, BLEU-4, duplication, and SHAP explanations. Its key warning is that benchmark overlap can inflate apparent capability. The paper says: “Such overlaps may create an illusion of high accuracy, masking the true capabilities of these models in novel or diverse scenarios.”

Table 2 reports accuracy percentages for one-beam decoding. For example, CodeT5+ obtains 15.20% on Android_S, 7.27% on Google_M, 18.44% on B2F_S, 7.84% on B2F_M, 63.90% on Java2C#, and 70.60% on C#2Java. Section 3.3 defines accuracy as perfectly predicted snippets divided by total test snippets, so these are exact-match rates, not verifier success rates; the table does not print test counts.

technique 1: audit train–test duplication with maximum BLEU-4

Use this before trusting a code-generation benchmark. For each test instance t, compare its source sequence to every training instance and retain the maximum BLEU-4 score S(t)=max BLEU-4(t,ti) plus the argmax index (section 4.2.1, equations 1–2, page 11). Figure 2 bins test instances by source similarity (bins [0,0.2) up to [0.8,1), plus exactly 1) and recomputes model accuracy in each bin. The paper reports that in all Tufano et al. datasets (the six Android/Google/Ovirt subsets) more than 20% of test samples are identical to training samples; in Ovirt_M, more than 60% of test sources have similarity above 0.8. For CodeT5+ on B2F_S, accuracy is around 10% for similarity below 0.2 and nearly 25% above 0.8 (Figure 2 discussion, page 12). Table 3 (page 13) has a row “Test Samples Percentage (>0.6)” (53.69% for Android_S, 85.74% for Ovirt_M, 0.05% for CodeReview) and reports accuracy before and after removing high-similarity test instances: CodeT5+ goes from 15.2% to 13.09% on Android_S and from 70.6% to 53.09% on C#2Java (CodeReviewer on C#2Java: 70.40% to 53.87%). Inference: the removed set is the test samples above the 0.6 threshold named in that row label; the paper text only says “high similarity scores”. The test-set size changes with the filter, so the new accuracy is computed on a smaller denominator.

The metric definition is explicit: “A BLEU-4 score of 0 corresponds to no similarity, indicating completely unique content, while a score of 1 reflects total duplication or exact replication.” The authors speculate that this “may indicate a research oversight during dataset preparation” in which instances with identical source and target pairs are usually removed, while instances with identical sources or identical targets considered separately remain; this is hedged in the paper, not shown. A related check (section 4.2.2, equations 3–4, page 13) applies the same maximum-BLEU-4 comparison within the test set; Finding 3 says 10 of 12 datasets contain duplicated source sequences in test instances with different targets (B2F_S and B2F_M have none).

technique 2: detect output copying and input sensitivity

Output copying (section 4.2.3, page 15, Table 4): the paper uses direct string comparison between each model output and its source sequence, ignoring special tokens such as “”, “” and “”, and reports the proportion of identical outputs (not BLEU-4). For example, T5 copies the input for 78% of Android_S and 80% of Android_M test cases, and CodeT5+ for 35% on B2F_S and 32% on Google_M; CONCODE shows 0%. Input sensitivity (section 4.3.2) uses controlled token deletion. For explanation-driven deletion, rank input tokens by importance, remove the least important tokens, insert placeholders to preserve format, and rerun generation. They test removal counts 1, 3, 5, 10, and 15, with zero denoting the original input (section 4.3.2, pages 17–18). On Android_S, CodeT5+ accuracy drops from 15.2% to 9.19% after removing one token and to 3% after five; the paper says performance drops to zero beyond the removal of ten tokens (Figure 6, page 17). Figure 7 compares removing five lowest-importance, random, and highest-importance tokens. On Android_S, CodeT5+ falls to 3% after removing the least important tokens and almost to zero after random or most-important removal; on B2F_S and CONCODE, lowest and random removal leave CodeT5+ much higher than most-important removal (page 19). The paper states: “The significant decrease in performance, even with the removal of tokens previously considered less important, suggests a complex interdependence among the various input features.”

technique 3: explain token importance with gradient SHAP

Use model-agnostic explanations to identify which input token types drive generated code. The paper applies SHAP’s GradientExplainer, an extension of integrated gradients that approximates SHAP values by computing expectations of gradients over randomly sampled baselines/references (section 2.2.2, page 5); section 3.4 says the explainability implementations come from the Captum and Ecco packages. Restrict analysis to CodeT5, CodeReviewer, and CodeT5+, the best models from earlier sections (section 4.3). Group tokens into identifiers, keywords, operators, separators, and literals; average feature-importance vectors across examples (Figure 5, page 16; CodeReview and CONCODE are excluded because token types are hard to separate from comments and natural language). The study finds identifiers and keywords receive higher importance than operators and separators (Finding 5). Removing the lowest-importance tokens typically declines accuracy less than random or highest-importance removal (Figure 7, pages 18–19), which the authors read as support for the explanations; on Android_S random removal is nearly as damaging as highest-importance removal.

Inference: For Verus, token attribution can diagnose whether a model relies on specification names, quantifier syntax, or proof commands. Attribution is explanatory evidence, not proof of causality and cannot replace Verus checking. Verus constructs such as requires, ensures, invariant, assert, and proof fn establish correctness; SHAP does not.

techniques for the catalog

  • maximum-BLEU duplication audit: score each test source against training sources and recompute accuracy after overlap filtering
  • input-output copying audit: compare generated code with inputs and perturb inputs by controlled token deletion
  • gradient-SHAP attribution: estimate token importance with baseline-sampled gradients and test it by targeted removals

Last edited: