arrow
返回

Unveiling Code Pre-Trained Models: Investigating Syntax and Semantics Capacities

delete2024-08-26
delete3
delete
OA
AI
W
Wei Ma
S
Shangqing Liu *
M
Mengjie Zhao
X
Xiaofei Xie
W
Wenhan Wang
Q
Qiang Hu
Z
Zhang, Jie
刘
刘洋 (Yang Liu)
DOI:10.1145/3664606delete
delete原文链接
delete原文求助
delete分享
delete收藏
摘要

摘要

En 中文
Code models have made significant advancements in code intelligence by encoding knowledge about programming languages. While previous studies have explored the capabilities of these models in learning code syntax, there has been limited investigation on their ability to understand code semantics. Additionally, existing analyses assume that the number of edges between nodes at the abstract syntax tree (AST) is related to syntax distance, and also often require transforming the high-dimensional space of deep learning models to a low-dimensional one, which may introduce inaccuracies. To study how code models represent code syntax and semantics, we conduct a comprehensive analysis of seven code models, including four representative code pre-trained models (CodeBERT, GraphCodeBERT, CodeT5, and UnixCoder) and three large language models (LLMs) (StarCoder, CodeLlama and CodeT5+). We design four probing tasks to assess the models' capacities in learning both code syntax and semantics. These probing tasks reconstruct code syntax and semantics structures (AST, control dependence graph (CDG), data dependence graph (DDG), and control flow graph (CFG)) in the representation space. These structures are core concepts for code understanding. We also investigate the syntax token role in each token representation and the long dependency between the code tokens. Additionally, we analyze the distribution of attention weights related to code semantic structures. Through extensive analysis, our findings highlight the strengths and limitations of different code models in learning code syntax and semantics. The results demonstrate that these models excel in learning code syntax, successfully capturing the syntax relationships between tokens and the syntax roles of individual tokens. However, their performance in encoding code semantics varies. CodeT5 and CodeBERT demonstrate proficiency in capturing control and data dependencies, whereas UnixCoder shows weaker performance in this aspect. We do not observe LLMs generally performing much better than pre-trained models. The shallow layers of LLMs perform better than their deep layers. The investigation of attention weights reveals that different attention heads play distinct roles in encoding code semantics. Our research findings emphasize the need for further enhancements in code models to better learn code semantics. This study contributes to the understanding of code models' abilities in syntax and semantics analysis. Our findings provide guidance for future improvements in code models, facilitating their effective application in various code-related tasks. CCS Concepts: center dot Software and its engineering- Automatic programming center dot Computing methodologies- Natural language processing ; Neural networks ;
Keyword:
Code model analysis
syntax and semantic encoding

期刊

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
论文数:
1.2K
被引数:
3.4K

机构

U
University of Tokyo
学者数:
7.1W
论文数: 6.5W
被引数: 2.2K
H
huawei technologies
学者数:
3.3K
论文数: 2.9K
被引数: 1
S
Singapore Management University
学者数:
1.5K
论文数: 2.5K
被引数: 3.5K
U
University of Munich
学者数:
5.7W
论文数: 4.2W
被引数: 68
U
university of alberta
学者数:
5.1W
论文数: 4.9W
被引数: 65
N
Nanyang Technological University
学者数:
4.9W
论文数: 4.8W
被引数: 8.1W
学者 查看更多机构
引用论文

引用论文

Long noncoding RNA hypoxia-inducible factor 1 alpha-antisense RNA 1 promotes tumor necrosis factor-α-induced apoptosis through caspase 3 in Kupffer cells
err2018-01-01
err0
errOAAI
errYanghe Wu; Jiguang Ding; Qingfeng Sun; Ke Zhou; Weiwei Zhang; Qingwei Du; Tingyan Xu; Wangwang Xu
err分享
err收藏
The spectrum of epilepsy in children with 15q13.3 microdeletion syndrome
err2021-11-01
err0
PREAI
errRobyn Whitney; Arjun Nair; Elizabeth McCready; Anne E. Keller; Ishita Siddiq Adil; Aly Shah Aziz; Oksana Borys; Kaitlyn Siu; Chintan Shah; Brandon F. Meaney; Kevin Jones; Rajesh RamachandranNair
err分享
err收藏
High-definition trans cranial direct current stimulation and its effects on cognitive function: a systematic review
err2022-12-17
err0
PREAI
errJaya Shanker Tedla; Devika Rani Sangadala; Ravi Shankar Reddy; Kumar Gular; Snehil Dixit
err分享
err收藏
Intercortical Systems of the Human Cerebrum
err
IF0
err2019-04-09
err0
errOAAI
errJoshua Rosett
err分享
err收藏
Estimation of Fracture Geometry Parameters and Characterization of Rock Mass Structure for the Beishan Area, China
err2020-10-29
err0
PREAI
errXiang WEI; Ying GUO; Hanlie CHENG; Jianfei WEI; Linlin ZHANG; Liang HUO; Zhenkun HOU
err分享
err收藏
Teaching Clinical Judgment in Taiwan
err2003-09-01
err0
PREAI
errPay-Fan Lin; Man-Ying Hsu; Shiow-Luan Tasy
err分享
err收藏
err分享
err收藏
学者 查看更多内容