atlas

Research map / Large language models / Language, safety and interpretability

Do Large Code Models Understand Programming Concepts? Counterfactual Analysis for Code Predicates

ICML 2024 · Large language models › Language, safety and interpretability · approach: Controlled text generation · 3 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes CACP, a black-box counterfactual testing framework that applies predicate-specific code mutations to evaluate whether ten large code models understand programming concepts (control flow, data flow, data types, identifier naming) on code completion.

Problem

It is unclear whether large code models understand the logical programming concepts (program predicates) underlying the programs they complete, and end-to-end benchmarks do not attribute failures to specific concepts.

Approach

Generate minimal counterfactual code pairs via semantics-preserving mutations (if-else flip, independent statement swap, def-use break, variable renaming/shuffling) and measure the Average Mutation Effect on unit-test pass/fail, requiring only hard-label black-box access.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Apply Variable-Names Random mutation (ablation)GPT-4 (gpt-4-1106) · HumanEval + MBPPAME: 06.43Hurt
Apply Variable-Names Shuffle mutation (ablation)GPT-4 (gpt-4-1106) · HumanEval + MBPPAME: 07.21Hurt
Apply If-Else Flip mutation (ablation)GPT-4 (gpt-4-1106) · HumanEval + MBPPAME: 05.95Hurt
Apply Independent Swap mutation (ablation)GPT-4 (gpt-4-1106) · HumanEval + MBPPAME: 01.57Hurt
Apply Def-Use Break mutation (ablation)GPT-4 (gpt-4-1106) · HumanEval + MBPPAME: 04.76Hurt
Apply If-Else Flip mutation (ablation)StarCoder · code completionunit-test correctness: 13.21Hurt
Use an earlier code prefix cutoff (0.4 - 0.6 rather than 0.8 - 1.0) (ablation)StarCoder · code completionoriginal accuracy: 60.1 % -> 32.8 %Hurt
Use an earlier code prefix cutoff (0.4 - 0.6 rather than 0.8 - 1.0) (ablation)StarCoder · code completionAME (Variable-Names Random): 12.4 -> 18.7Mixed
Use an earlier code prefix cutoff (0.4 - 0.6 rather than 0.8 - 1.0) (ablation)StarCoder · code completionAME (Variable-Names Shuffle): 17.7 -> 21.4Mixed
Use an earlier code prefix cutoff (0.4 - 0.6 rather than 0.8 - 1.0) (ablation)StarCoder · code completionAME (Def-Use Break): 04.0 -> 26.0Mixed
Use an earlier code prefix cutoff (0.4 - 0.6 rather than 0.8 - 1.0) (ablation)StarCoder · code completionAME (Independent Swap): 19.6 -> 08.0Mixed
Fine-tune on code-specific datacode language models · code completionAME for variable-name mutationsHelped

Surprising findings

Limitations

Experimental setup

Datasets: HumanEval MBPP CodeContests HumanEvalPack

Benchmarks: HumanEval MBPP CodeContests HumanEvalPack

Metrics: Average Mutation Effect (AME) unit-test correctness original accuracy

Baselines: Llama 2 Code Llama PaLM 2 PaLM 2-S* GPT-4

Builds on: HumanEval MBPP CodeContests HumanEvalPack

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy