HackerPapers

arXiv:2305.11169cs.LG

Emergent Representations of Program Semantics in Language Models Trained on Programs

Charles Jin, Martin Rinard

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.

arXiv comments
ICML 2024
Journal reference
PMLR 235:22160-22184, 2024
DOI
Subjects
cs.LGMachine Learning cs.AIArtificial Intelligence cs.CLComputation and Language cs.PLProgramming Languages

On Hacker News

Linked by 4 identifiable commenters in 7 comments across 7 threads, from May 2023 to Nov 2026. Found in 3 HN submissions from May 2023 to Jun 2023. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments7 threads

    • Yes you are right about random initilization of course. Long day here. For the second: No, not fine tuning at all. For one thing in-context learning is enough for learning novel tasks[1]. Secondly, it can do new things outside that data. LLMs build models of the world[2]. That…

      nlView on HNParent context

    • https://www.youtube.com/watch?v=uRDBco-cSK4 https://www.technologyreview.com/2024/11/27/1107377/a-minecr... sadly paid-walled (and decently coded) article. The point is, there appears to be emergent behavior happening: the forming of religion, governance, and social interaction…

      altruiosView on HNParent context

    • You are making a lot of assumptions that are mostly wrong. Case in point: https://arxiv.org/abs/2305.11169 I'm asking for something testable, not some post-hoc rationalization you believe to be true. I'm not asking you to tell me how you think LLMs work. I'm asking you to define…

      famouswafflesView on HNParent context

    • >But to know that, one has to understand what the data means semantically. And our current AIs ... well, don't. Another wrong statement, you're on a roll today. https://arxiv.org/abs/2305.11169 https://arxiv.org/abs/2306.12672 There's a word we would use to describe your…

      famouswafflesView on HNParent context

    • >Actual reasoning, or reconstruction of existing texts containing similar reasoning? The papers were linked in another comment. 3 of them don't even have anything to do with a existing dataset testing. so yeah, actual. for the world model papers https://arxiv.org/abs/2210.13382…

      famouswafflesView on HNParent context

  1. Rodney Brooks on GPT-4 1 comment
    • No world model ? A world model is so obvious papers like these are more confirmation than surprise https://arxiv.org/abs/2305.11169 https://arxiv.org/abs/2210.13382 There a certain sentiment that AGI however you wish to define it won't infact be a "We'll know it when we see it"…

      famouswafflesView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.