Benchmarking Language Models for Code Syntax Understanding

Da Shen, Xinyun Chen, Chenguang Wang, Koushik Sen, Dawn Song
10/26/2022
cs.CL
benchmark-dataset

Official code: dashends/CodeSyntax (16 stars, Jupyter Notebook, MIT, last commit 2022-10-24).

Abstract

Pre-trained language models have demonstrated impressive performance in both natural language processing and program understanding, which represent the input as a token sequence without explicitly modeling its structure. Some prior works show that pre-trained language models can capture the syntactic rules of natural languages without finetuning on syntax understanding tasks.

Show full abstract

However, there is limited understanding of how well pre-trained models understand the code structure so far. In this work, we perform the first thorough benchmarking of the state-of-the-art pre-trained models for identifying the syntactic structures of programs. Specifically, we introduce CodeSyntax, a large-scale dataset of programs annotated with the syntactic relationships in their corresponding abstract syntax trees. Our key observation is that existing language models pretrained on code still lack the understanding of code syntax. In fact, these pre-trained programming language models fail to match the performance of simple baselines based on positional offsets and keywords. We also present a natural language benchmark to highlight the differences between natural languages and programming languages in terms of syntactic structure understanding. Our findings point out key limitations of existing pre-training methods for programming languages, and suggest the importance of modeling code syntactic structures.

View on arXivView PDF

Code Implementations(1)

MIT

Code and dataset for EMNLP 2022 Findings paper "Benchmarking Language Models for Code Syntax Understanding"

162Jupyter Notebook, PythonJul 8, 20214 years agoMIT

Similar Papers

Cite this paper

@article{shen2022benchmarking,
  title  = {Benchmarking Language Models for Code Syntax Understanding},
  author = {Da Shen and Xinyun Chen and Chenguang Wang and Koushik Sen and Dawn Song},
  year   = {2022},
  eprint = {2210.14473},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2210.14473}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2210.14473.svg)](https://codeofpaper.com/paper/2210.14473)

Discussion