Skip to main content
QUICK REVIEW

[論文レビュー] Emergent Representations of Program Semantics in Language Models Trained on Programs

Charles Jin, Martin Rinard|arXiv (Cornell University)|May 18, 2023
Software Engineering ResearchComputer Science被引用数 9
ひとこと要約

要旨:本論文は、プログラム上の次 token 予測だけで訓練した言語モデルが、将来の状態を含むプログラム意味論の線形で意味のある表現を開発し、意味論がプローブではなくモデル状態に帰属されることを示す。

ABSTRACT

We present evidence that language models (LMs) of code can learn to represent the formal semantics of programs, despite being trained only to perform next-token prediction. Specifically, we train a Transformer model on a synthetic corpus of programs written in a domain-specific language for navigating 2D grid world environments. Each program in the corpus is preceded by a (partial) specification in the form of several input-output grid world states. Despite providing no further inductive biases, we find that a probing classifier is able to extract increasingly accurate representations of the unobserved, intermediate grid world states from the LM hidden states over the course of training, suggesting the LM acquires an emergent ability to interpret programs in the formal sense. We also develop a novel interventional baseline that enables us to disambiguate what is represented by the LM as opposed to learned by the probe. We anticipate that this technique may be generally applicable to a broad range of semantic probing experiments. In summary, this paper does not propose any new techniques for training LMs of code, but develops an experimental framework for and provides insights into the acquisition and representation of formal semantics in statistical models of code. Our code is available at https://github.com/charlesjin/emergent-semantics.

研究の動機と目的

  • 意味がプログラム合成設定で次 token 予測のみを訓練したLMにおいて出現し得るかを調査する。
  • LMの表現に意味的エンコーディングをテストするための厳密な意味フレームワーク(プログラムトレースと抽象解釈)を定義する。
  • LMの隠れ状態に、意味的状態と将来のプログラム状態の線形エンコーディングが含まれ、合成精度と相関があることを実証する。
  • 意味論がモデル状態に resides しているのか、プローブによって学習されたものなのかを、介入実験を通じて区別する。

提案手法

  • 350Mパラメータのトランスフォーマー(CodeGenアーキテクチャ)を、一百万個のKarelプログラムとテキスト仕様(入力出力例)を用いて訓練する。
  • 生成トークンごとに部分実行後のLM隠れ状態と対応するプログラム状態を記録してトレースデータセットを構築する。
  • 線形プローブを訓練して、モデル状態から意味的状態(例: facing 方向)を予測し、意味内容を評価する。
  • 意味論に介入して、モデル状態が意味内容をエンコードしているのか、それとも単なる構文的転写にとどまるのかを識別する。
  • 生成されたプログラムを訓練分布と比較して、プログラム長と困難度(perplexity)を分析する。
  • グリーディデコードを用いてプログラムを生成し、テスト仕様に対する生成精度を評価する。
Figure 1 : An overview of the Karel domain. We construct training examples by sampling a random reference program, then sampling 5 random inputs and executing the program to obtain the corresponding 5 outputs. The LM is trained to perform next token prediction on a corpus of examples. At test time,
Figure 1 : An overview of the Karel domain. We construct training examples by sampling a random reference program, then sampling 5 random inputs and executing the program to obtain the corresponding 5 outputs. The LM is trained to perform next token prediction on a corpus of examples. At test time,

実験結果

リサーチクエスチョン

  • RQ1次 token 予測のみを訓練したLMは、プログラム仕様で訓練された場合に意味論を学習できるか。
  • RQ2LMの隠れ状態には、将来状態を含む、線形で移動可能なプログラム意味論表現が含まれているか。
  • RQ3意味表現はモデル状態にあるのか、それともプローブによって学習されたものか。
  • RQ4高い精度を達成しても、LMの出力は訓練分布とは意味的に異なるのか。

主な発見

  • 意味内容は訓練過程で現れ、生成精度と相関する(R^2 = 0.968, p < 0.001)。
  • プローブはLM状態から抽象的な意味論と将来のプログラム状態を抽出でき、意味が学習されたことを示す。
  • 介入テストにより、意味論はプローブではなくモデル状態に帰属することが示され、構文的転写仮説が棄却される。
  • LMは訓練セットよりも短い正解プログラムを生成しやすい一方、訓練セットのプログラムの困惑度は高く、訓練分布との差異が示唆される。
  • 未来状態の意味内容は現在状態から予測可能で、生成進行と強い相関を持つ(未来1–2ステップでR^2は約0.9)。
  • 代替意味論はプローブの意味復元能力を劣化させ、モデル状態が元の意味をエンコードしていることを支持する。
Figure 2 : Plotting generative accuracy (blue line) and semantic content (green line) over time. The dotted line at 25% plots the baseline semantic content for random guessing.
Figure 2 : Plotting generative accuracy (blue line) and semantic content (green line) over time. The dotted line at 25% plots the baseline semantic content for random guessing.

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。