GraphCode2Vec: Generic Code Embedding via Lexical and Program Dependence Analyses
arXiv:2112.01218
Abstract
Code embedding is a keystone in the application of machine learning on several Software Engineering (SE) tasks. To effectively support a plethora of SE tasks, the embedding needs to capture program syntax and semantics in a way that is generic. To this end, we propose the first self-supervised pre-training approach (called GraphCode2Vec) which produces task-agnostic embedding of lexical and program dependence features. GraphCode2Vec achieves this via a synergistic combination of code analysis and Graph Neural Networks. GraphCode2Vec is generic, it allows pre-training, and it is applicable to several SE downstream tasks. We evaluate the effectiveness of GraphCode2Vec on four (4) tasks (method name prediction, solution classification, mutation testing and overfitted patch classification), and compare it with four (4) similarly generic code embedding baselines (Code2Seq, Code2Vec, CodeBERT, GraphCodeBERT) and 7 task-specific, learning-based methods. In particular, GraphCode2Vec is more effective than both generic and task-specific learning-based baselines. It is also complementary and comparable to GraphCodeBERT (a larger and more complex model). We also demonstrate through a probing and ablation study that GraphCode2Vec learns lexical and program dependence features and that self-supervised pre-training improves effectiveness.
References in corpus (12)
- Efficient Estimation of Word Representations in Vector Space
- Distributed Representations of Words and Phrases and their Compositionality
- Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation
- Variational Graph Auto-Encoders
- CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Graph Matching Networks for Learning the Similarity of Graph Structured Objects
- GraphCodeBERT: Pre-training Code Representations with Data Flow
- Learning and Evaluating Contextual Embedding of Source Code
- Improvements to context based self-supervised learning
- Exploring Software Naturalness through Neural Language Models
- Learning to Represent Programs with Heterogeneous Graphs
- Deep Data Flow Analysis