atlas

Research map / Large language models / Agents, code and math

Exploiting Code Symmetries for Learning Program Semantics

ICML 2024 · Large language models › Agents, code and math · approach: Execution-based code verification

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 SymC, a self-attention variant provably equivariant to permutation symmetries (automorphisms of a program dependence graph), trained from scratch to give invariant predictions for five program analysis tasks.

Problem

Code LLMs are not robust to semantics-preserving code transformations such as statement permutations, so their predictions change under symmetry-preserving edits, and pre-training or augmentation give no invariance guarantee.

Approach

Define code symmetries as automorphisms of a program dependence graph (PDG) and bias multi-head self-attention with positive/negative longest-path distance matrices, making the representation provably equivariant and the pooled or token-level predictions invariant to these permutations.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use SymC instead of PalmTreeFunction signature prediction · Function signature prediction under semantics-preserving permutationsF1: 0.59 -> 0.88Helped
Use SymC instead of PalmTreeMemory region prediction · Memory region prediction under semantics-preserving permutationsF1: 0.57 -> 0.86Helped
Use SymC instead of PalmTree-OFunction similarity detection · Function similarity detection under semantics-preserving permutationsAUC: 0.8 -> 0.96Helped
Use SymC instead of PalmTree on unseen source transformationsFunction name prediction · Unseen source-code transformations beyond permutationsF1: 30.8%Helped
Use SymC instead of Code Llama on unseen source transformationsFunction name prediction · Unseen source-code transformations beyond permutationsF1: 10%Hurt
Use equivariant rather than invariant self-attention layers (ablation)SymC · Memory region predictionF1: 0.73; 60.7%Helped
Add one epoch of masked-language-model pre-training (ablation)SymC · Memory region predictionF1: 10.8%Helped
Increase pre-training from 1 epoch to 5 epochs (ablation)SymC · Memory region predictionF1: 3.2%Helped
Use PDG-equivariant attention rather than fully permutation-equivariant attention with identical distance values (ablation)SymC · Memory region predictionF1: 14.5%Helped
Use PDG-equivariant attention rather than non-equivariant relative positional embeddings (ablation)SymC · Memory region predictionF1: 36.4%Helped

Surprising findings

Limitations

Experimental setup

Datasets: Java method name dataset (11 projects, 707K methods) Defects4J 27 open-source binary projects compiled with GCC and Clang, O0-O3, Hikari obfuscations

Benchmarks: function name prediction (Java, Hadoop test set) defect prediction (Defects4J) function signature prediction (stripped binaries) memory region prediction (stripped binaries) function similarity detection (stripped binaries)

Metrics: F1 AUC violation rate

Baselines: code2seq code2vec CodeLlama CodeT5 DOBF GGNN GPT-4 GraphCodeBERT WizardCoder PalmTree

Builds on: Transformer self-attention Graphormer-style distance encoding SymLM

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