Skip to main content
QUICK REVIEW

[논문 리뷰] Emergent Representations of Program Semantics in Language Models Trained on Programs

Charles Jin, Martin Rinard|arXiv (Cornell University)|2023. 05. 18.
Software Engineering ResearchComputer Science인용 수 9
한 줄 요약

이 논문은 프로그램에 대해 다음 토큰 예측만으로 학습된 언어 모델이 선형적이고 의미 있는 프로그램 의미 표현을 개발하며, 미래 상태를 포함하고, 의미가 프로브가 아닌 모델 상태에 귀속된다는 것을 보여준다.

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.

연구 동기 및 목표

  • 프로그램 합성 설정을 사용하여 단순히 다음 토큰 예측만으로 학습된 LM에서 의미가 등장할 수 있는지 탐구한다.
  • LM 표현에서 의미 인코딩을 테스트하기 위한 정밀한 의미 프레임워크를 정의한다(프로그램 추적과 추상 해석).
  • LM 은닉 상태에 의미 상태와 미래 프로그램 상태의 선형 인코딩이 포함되어 있으며 합성 정확도와 상관관계가 있음을 보여준다.
  • 개입 실험을 통해 의미가 모델 상태에 존재하는지, 아니면 프로브에 의해 학습되는지 구분한다.

제안 방법

  • CodeGen 아키텍처의 350M 파라미터 트랜스포머를 텍스트 명세(입력-출력 예제)가 있는 백만 개의 Karel 프로그램 말뭉치에서 학습한다.
  • 생성된 각 토큰에 대해 부분 실행 후 LM 은닉 상태와 해당하는 프로그램 상태를 기록하여 추적 데이터셋을 구성한다.
  • 모델 상태에서 의미 상태를 예측하도록 선형 프로브를 학습하고(예: 방향 facing) 의미 내용을 평가한다.
  • 대체 의미를 사용하여 의미에 개입(intervene)하여 모델 상태가 의미 내용을 인코딩하는지 아니면 단지 구문(transcript)만을 나타내는지 구별한다.
  • 프로그램 길이와 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프로그램 명세를 학습할 때 다음 토큰 예측만으로 학습된 LM이 의미를 학습할 수 있는가?
  • RQ2LM 은닉 상태에 미래 상태를 포함한 선형적이고 전이 가능한 프로그램 의미 표현이 포함되어 있는가?
  • RQ3의미 표현이 모델 상태에 있는가, 아니면 프로브에 의해 학습되는가?
  • RQ4높은 정확도에도 불구하고 LM 출력이 학습 분포와 의미상 다른가?

주요 결과

  • 의미 내용이 학습 중에 나타나며 생성 정확도와 상관관계가 있다(R^2 = 0.968, p < 0.001).
  • 프로브는 LM 상태에서 추상적 의미와 미래의 프로그램 상태를 추출할 수 있어 학습된 의미를 시사한다.
  • 개입 테스트는 의미가 프로브가 아니라 모델 상태에 기인함을 보여주며 구문적 전사 가설을 기각한다.
  • LM은 학습 세트보다 더 짧은 올바른 프로그램을 생성하는 경향이 있으며 학습 세트 프로그램에 대한 perplexity는 여전히 높아 학습 분포와 의미적 차이를 시사한다.
  • 미래 상태의 의미 내용은 현재 상태에서 예측할 수 있으며 생성 진행과 강한 상관관계가 있다(R^2 약 0.9, 앞으로 1–2 단계).
  • 대체 의미 체계는 프로브의 의미 회복 능력을 저하시켜 모델 상태가 원래 의미를 인코딩함을 뒷받침한다.
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.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.