atlas

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

Emergent Representations of Program Semantics in Language Models Trained on Programs

ICML 2024 · Large language models › Language, safety and interpretability · approach: Reasoning mechanisms and failure modes · 9 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.

Trains a 350M CodeGen-style Transformer on synthetic Karel programs with input-output specifications and shows, via probes and a semantic-intervention control, that hidden states encode abstract program traces that emerge during training.

Problem

Whether language models of code trained only with next-token prediction on text learn the formal (operational) semantics of programs, or merely surface statistics, and how to control for what probes learn versus what the LM represents.

Approach

Probe LM hidden states for abstract program states (position, direction, obstacle) during training and introduce semantic probing interventions: reassign operation semantics (flip, adversarial) while keeping syntax fixed, and check whether a probe can still decode the alternative semantics as well as the original; a drop indicates the LM represents the true semantics rather than a syntactic record

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Train CodeGen 350M on input-output specifications followed by programsCodeGen 350M · Karel test specificationsgenerative accuracy: 10% to over 90%Helped
Train longer through the semantics-acquisition phaseCodeGen 350M · Karel test tracessemantic contentHelped
Probe future abstract states from LM hidden statesCodeGen 350M representations · Karel test traces, 2 states into the futureprobing accuracy: 77.3 vs. 75.6Helped
Replace original semantics with flip semanticsCodeGen 350M representations · Karel test traces, current statesemantic content: 79.1; 76.7; 2.3Hurt
Replace original semantics with adversarial semanticsCodeGen 350M representations · Karel test traces, current statesemantic content: 79.1; 66.7; 12.4Hurt
Hide specification outputs while probing program tracesCodeGen 350M representations · Karel input-only tracessemantic contentHurt

Surprising findings

Limitations

Experimental setup

Datasets: synthetic Karel program corpus (500,000 programs) test set of 10,000 specifications

Benchmarks: Karel synthetic test set (10,000 specifications)

Metrics: generative accuracy probing accuracy (semantic content, geometric mean over dire R^2 correlation with generative accuracy perplexity output diversity

Baselines: syntactic record hypothesis flip semantics adversarial semantics retrieval hypothesis

Builds on: CodeGen Karel Othello-GPT probing control tasks for probing

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