Pop Quiz! Do Pre-trained Code Models Possess Knowledge of Correct API Names?
Not on the map. Why?
Abstract (arXiv)
Recent breakthroughs in pre-trained code models, such as CodeBERT and Codex, have shown their superior performance in various downstream tasks. The correctness and unambiguity of API usage among these code models are crucial for achieving desirable program functionalities, requiring them to learn various API fully qualified names structurally and semantically. Recent studies reveal that even state-of-the-art pre-trained code models struggle with suggesting the correct APIs during code generation. However, the reasons for such poor API usage performance are barely investigated. To address this challenge, we propose using knowledge probing as a means of interpreting code models, which uses cloze-style tests to measure the knowledge stored in models. Our comprehensive study examines a code model's capability of understanding API fully qualified names from two different perspectives: API call and API import. Specifically, we reveal that current code models struggle with understanding API names, with pre-training strategies significantly affecting the quality of API name learning. We demonstrate that natural language context can assist code models in locating Python API names and generalize Python API name knowledge to unseen data. Our findings provide insights into the limitations and capabilities of current pre-trained code models, and suggest that incorporating API structure into the pre-training process can improve automated API usage and code representations. This work provides significance for advancing code intelligence practices and direction for future studies. All experiment results, data and source code used in this work are available at urlhttps://doi.org/10.5281/zenodo.7902072.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 37 of its 46 references that are in the map. First posted on arXiv 14 Sep 2023.
Builds on
37 of 46 references.
References · 37
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2023GPT-4 Technical Reportcited by 18,132
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2019BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehensioncited by 5,874
- 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,222
- 2019Language Models as Knowledge Bases?cited by 1,922
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2019How Can We Know What Language Models Know?cited by 953
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023StarCoder: may the source be with you!cited by 790
- 2022Quantifying Memorization Across Neural Language Modelscited by 755
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
25 more
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2020Pre-trained Models for Natural Language Processing: A Surveycited by 504
- 2022DS-1000: A Natural and Reliable Benchmark for Data Science Code Generationcited by 442
- 2021Learning How to Ask: Querying LMs with Mixtures of Soft Promptscited by 376
- 2021Unified Pre-training for Program Understanding and Generationcited by 361
- 2021True Few-Shot Learning with Language Modelscited by 343
- 2017A Survey of Machine Learning for Big Code and Naturalnesscited by 220
- 2017Explainable Artificial Intelligence: Understanding, Visualizing and Interpreting Deep Learning Modelscited by 202
- 2020How Context Affects Language Models' Factual Predictionscited by 181
- 2023SantaCoder: don't reach for the stars!cited by 169
- 2023Scaling Laws for Generative Mixed-Modal Language Modelscited by 131
- 2020X-FACTR: Multilingual Factual Knowledge Retrieval from Pretrained Language Modelscited by 117
- 2022What Do They Capture? -- A Structural Analysis of Pre-Trained Language Models for Source Codecited by 50
- 2016Deep API Learningcited by 41
- 2021In-IDE Code Generation from Natural Language: Promise and Challengescited by 41
- 2021Memorisation versus Generalisation in Pre-trained Language Modelscited by 32
- 2023CoderEval: A Benchmark of Pragmatic Code Generation with Generative Pre-trained Modelscited by 28
- 2022Probing Pretrained Models of Source Codecited by 26
- 2022Deep Learning Meets Software Engineering: A Survey on Pre-Trained Models of Source Codecited by 20
- 2022AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language modelscited by 16
- 2018RACK: Automatic API Recommendation using Crowdsourced Knowledgecited by 12
- 2022On the Effectiveness of Pretrained Models for API Learningcited by 9
- 2022Prompt-tuned Code Language Model as a Neural Knowledge Base for Type Inference in Statically-Typed Partial Codecited by 6
- 2021Restoring Execution Environments of Jupyter Notebookscited by 5
- 2022Deep API Learning Revisitedcited by 1
Built on by
Citing papers per year: 2024: 1; 2025: 1; 2026: 1.
3 papers.