Domain Adaptive Code Completion via Language Models and Decoupled Domain Databases
The DOI matches its Crossref record; 26 of the 26 references it cites were found in a registry or an index.
Abstract
Large Language Models (LLMs) have demonstrated remarkable performance in code completion. However, due to the lack of domain-specific knowledge, they may not be optimal in completing code that requires intensive domain knowledge for example completing the library names. Although there are several works that have confirmed the effectiveness of fine-tuning techniques to adapt language models for code completion in specific domains. They are limited by the need for constant fine-tuning of the model when the project is in constant iteration. To address this limitation, in this paper, we propose$k$NM-LM, a retrieval-augmented language model (R-LM), that integrates domain knowledge into language models without fine-tuning. Different from previous techniques, our approach is able to automatically adapt to different language models and domains. Specifically, it utilizes the in-domain code to build the retrieval-based database decoupled from LM, and then combines it with LM through Bayesian inference to complete the code. The extensive experiments on the completion of intra-project and intra-scenario have confirmed that$k$NM-LM brings about appreciable enhancements when compared to CodeGPT and UnixCoder. A deep analysis of our tool including the responding speed, storage usage, specific type code completion, and API invocation completion has confirmed that$k$NM-LM provides satisfactory performance, which renders it highly appropriate for domain adaptive code completion. Furthermore, our approach operates without the requirement for direct access to the language model's parameters. As a result, it can seamlessly integrate with black-box code completion models, making it easy to integrate our approach as a plugin to further enhance the performance of these models.
Overview
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Integrity signals
Registry
Cites
Statistics
Verification
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Claims other papers make about this one
Each is checked against this paper’s own text: does it say what the citing paper says it does?
In the citing paper
“kNM-LM [246] performs logit-based RAG, combining the logits of retrieval and generation using bayes inference.”
From Retrieval-Augmented Generation for AI-Generated Content: A Survey (2024) · cites this paper as [246]
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Citations
Cites
Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., & Liu, P. J. (2019) · arXiv · doi:10.48550/arxiv.1910.10683 · Cited by 10,929
Billion-scale similarity search with GPUs
Johnson, J., Douze, M., & Jegou, H. (2021) · IEEE Transactions on Big Data · doi:10.1109/tbdata.2019.2921572 · Cited by 4,228
Billion-scale similarity search with GPUs
Johnson, J., Douze, M., & Jégou, H. (2017) · arXiv · doi:10.48550/arxiv.1702.08734 · Cited by 4,140 · cited 1×
“Faiss-gpu [23] is used for accelerated k nearest neighbors search, same as Khandelwal et al.”
MethodThe probabilistic relevance framework: BM25 and beyond
Robertson, S., & Zaragoza, H. (2009) · Foundations and Trends® in Information Retrieval · doi:10.1561/1500000019 · Cited by 3,374
Generalizing from a Few Examples: A Survey on Few-shot Learning
Wang, Y., Yao, Q., Kwok, J. T., & Ni, L. M. (2021) · ACM Computing Surveys · doi:10.1145/3386252 · Cited by 3,165 · cited 1×
“Block R-LMs [12], [13], [48] are similar to one-shot or few-shot learning [49], where one or a few examples are retrieved from a database instead of being randomly selected.”
BackgroundImproved Semantic Representations From Tree-Structured Long Short-Term Memory Networks
Tai, K. S., Socher, R., & Manning, C. D. (2015) · Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing (Volume 1: Long Papers) · doi:10.3115/v1/p15-1150 · Cited by 3,081
Don’t Stop Pretraining: Adapt Language Models to Domains and Tasks
Gururangan, S., Marasović, A., Swayamdipta, S., Lo, K., Beltagy, I., Downey, D., & Smith, N. A. (2020) · Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics · doi:10.18653/v1/2020.acl-main.740 · Cited by 2,103
Evaluating Large Language Models Trained on Code
Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. D. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., et al. (2021) · arXiv · doi:10.48550/arxiv.2107.03374 · Cited by 1,436
UniXcoder: Unified Cross-Modal Pre-training for Code Representation
Guo, D., Lu, S., Duan, N., Wang, Y., Zhou, M., & Yin, J. (2022) · Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) · doi:10.18653/v1/2022.acl-long.499 · Cited by 673
Unified Pre-training for Program Understanding and Generation
Ahmad, W., Chakraborty, S., Ray, B., & Chang, K.-W. (2021) · Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies · doi:10.18653/v1/2021.naacl-main.211 · Cited by 642
CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generation
Lu, S., Guo, D., Ren, S., Huang, J., Svyatkovskiy, A., Blanco, A., Clement, C., Drain, D., Jiang, D., Tang, D., et al. (2021) · arXiv · doi:10.48550/arxiv.2102.04664 · Cited by 536 · cited 1×
“Large language models (LLM) [1]–[5], have achieved state-of-art performance in code completion, and some of them have been successfully used as the auto-completion plugin (e.g. GitHub Copilot [6] and ChatGPT [7]) in modern Integrated Development Environment (IDE).”
MethodSelf-citationCodeSearchNet Challenge: Evaluating the State of Semantic Code Search
Husain, H., Wu, H.-H., Gazit, T., Allamanis, M., & Brockschmidt, M. (2019) · arXiv · doi:10.48550/arxiv.1909.09436 · Cited by 483
GraphCodeBERT: Pre-training Code Representations with Data Flow
Guo, D., Ren, S., Lu, S., Feng, Z., Tang, D., Liu, S., Zhou, L., Duan, N., Svyatkovskiy, A., Fu, S., et al. (2020) · arXiv · doi:10.48550/arxiv.2009.08366 · Cited by 480
Self-citationIntelliCode compose: code generation using transformer
Svyatkovskiy, A., Deng, S. K., Fu, S., & Sundaresan, N. (2020) · Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering · doi:10.1145/3368089.3417058 · Cited by 474 · cited 2×
“For example, CodeFill [29] improves GPT-2 [25] by predicting the code type when completing the next token, while Gramm-former [37] generates code completions with “holes” inserted in places where the model is uncertain.”
BackgroundGeneralization through Memorization: Nearest Neighbor Language Models
Khandelwal, U., Levy, O., Jurafsky, D., Zettlemoyer, L., & Lewis, M. (2019) · arXiv · doi:10.48550/arxiv.1911.00172 · Cited by 285
Atlas: Few-shot Learning with Retrieval Augmented Language Models
Izacard, G., Lewis, P., Lomeli, M., Hosseini, L., Petroni, F., Schick, T., Dwivedi-Yu, J., Joulin, A., Riedel, S., & Grave, E. (2022) · arXiv · doi:10.48550/arxiv.2208.03299 · Cited by 213
RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation
Zhang, F., Chen, B., Zhang, Y., Keung, J., Liu, J., Zan, D., Mao, Y., Lou, J.-G., & Chen, W. (2023) · Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing · doi:10.18653/v1/2023.emnlp-main.151 · Cited by 173
Pythia: AI-assisted Code Completion System
Svyatkovskiy, A., Zhao, Y., Fu, S., & Sundaresan, N. (2019) · Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining · doi:10.1145/3292500.3330699 · Cited by 169
Nearest Neighbor Machine Translation
Khandelwal, U., Fan, A., Jurafsky, D., Zettlemoyer, L., & Lewis, M. (2020) · arXiv · doi:10.48550/arxiv.2010.00710 · Cited by 165 · cited 2×
“Token R-LMs [15], [24], [50] retrieve tokens from database and then combine the retrieved results into the LM. Compared with block R-LMs, token R-LMs can update retrieval results at the same time of generating new tokens, hence our approach uses the architecture of token R-LM.”
MethodRetrieval Augmented Code Generation and Summarization
Parvez, M. R., Ahmad, W., Chakraborty, S., Ray, B., & Chang, K.-W. (2021) · Findings of the Association for Computational Linguistics: EMNLP 2021 · doi:10.18653/v1/2021.findings-emnlp.232 · Cited by 141
A Retrieve-and-Edit Framework for Predicting Structured Outputs
Hashimoto, T. B., Guu, K., Oren, Y., & Liang, P. (2018) · arXiv · doi:10.48550/arxiv.1812.01194 · Cited by 126 · cited 1×
“Code completion can be divided into three categories based on the code type to be completed: API name completion [33], [34], variable name completion [35], [36] and arbitrary token completion [29], [37]–[39].”
BackgroundEfficient Nearest Neighbor Language Models
He, J., Neubig, G., & Berg-Kirkpatrick, T. (2021) · Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing · doi:10.18653/v1/2021.emnlp-main.461 · Cited by 97 · cited 1×
“To reduce the search cost, RetoMaton [52] uses the automaton states to save search time, while AdaptRet [53] uses a trained network to decide whether to use the retrieval module.”
MethodCodeFill: multi-token code completion by jointly learning from structure and naming sequences
Izadi, M., Gismondi, R., & Gousios, G. (2022) · Proceedings of the 44th International Conference on Software Engineering · doi:10.1145/3510003.3510172 · Cited by 86
When Code Completion Fails: A Case Study on Real-World Completions
Hellendoorn, V. J., Proksch, S., Gall, H. C., & Bacchelli, A. (2019) · 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE) · doi:10.1109/icse.2019.00101 · Cited by 76 · cited 5×
“Performance of Completing Lines that involve Android APIs.”
InfluentialHow Practitioners Expect Code Completion?
Wang, C., Hu, J., Gao, C., Jin, Y., Xie, T., Huang, H., Lei, Z., & Deng, Y. (2023) · Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering · doi:10.1145/3611643.3616280 · Cited by 50
Neuro-Symbolic Language Modeling with Automaton-augmented Retrieval
Alon, U., Xu, F. F., He, J., Sengupta, S., Roth, D., & Neubig, G. (2022) · arXiv · doi:10.48550/arxiv.2201.12431 · Cited by 32
Research works printed but not linked: 33
- 10.18653/v1/2022.acl-long.431 · doi:10.18653/v1/2022.acl-long.431 · Paper page
- 10.1145/3551349.3556943 · DOI
- guu, 2020, Retrieval augmented language model pre-training, International Conference on Machine Learning, 3929
- 10.1109/ICSE48619.2023.00028 · DOI
- zhou, 2019, Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks, Advances in neural information processing systems, 32
- 10.24963/ijcai.2022/329 · DOI · Paper page
- 10.1145/3196321.3196334 · DOI · Paper page
- 0, Openai's text embedding api
- 10.1007/3-540-45014-9_1 · DOI · Paper page
- joyce, 2003, Bayes' theorem, Stanford Encyclopedia of Philosophy
- 0, Openai's completion api
- huang, 2023, k nn-adapter: Efficient domain adaptation for black-box language models, ArXiv Preprint
- meng, 0, Gnn-lm: Language modeling based on global contexts via gnn, ICLR 2022 Workshop on Deep Learning on Graphs for Natural Language Processing
- 10.1109/ICSE48619.2023.00178 · DOI · Paper page
- 10.1145/3510003.3510141 · DOI · Paper page
- wang, 2022, A tree-structured transformer for program representation learning, ArXiv Preprint
- liu, 0, Retrieval-augmented generation for code summarization via hybrid gnn, International Conference on Learning Representations
- xu, 2022, Capturing structural locality in non-parametric language models, The Tenth International Conferenceon Learning Representations ICLR 2022 Virtual Event April 25-29 2022
- 0, ChatGPT plugin in VSCode
- bogomolov, 2022, Assessing project-level fine-tuning of ML4SE models, CoRR, abs 2206 3333
- 10.1145/3510003.3510096 · DOI · Paper page
- 0, GitHub Copilot website
- 10.1007/978-3-642-03013-0_15 · DOI · Paper page
- 10.24963/ijcai.2018/578 · DOI · Paper page
- guo, 0, Learning to complete code with sketches, International Conference on Learning Representations
- allamanis, 0, Learning to represent programs with graphs, International Conference on Learning Representations
- 10.1186/1471-2105-15-293 · DOI · Paper page
- peng, 2022, Revisiting, benchmarking and exploring api recommendation: How far are we?, IEEE Transactions on Software Engineering
- 10.1109/ICSE43902.2021.00145 · DOI
- wang, 2023, Practitioners' expectations on code completion, ArXiv Preprint
- 10.18653/v1/D18-1111 · DOI · Paper page
- alon, 0, code2seq: Generating sequences from structured representations of code, International Conference on Learning Representations
- 10.1109/MSR52588.2021.00014 · DOI
Cited by
Retrieval-Augmented Generation for AI-Generated Content: A Survey
Zhao, P., Zhang, H., Yu, Q., Wang, Z., Geng, Y., Fu, F., Yang, L., Zhang, W., Jiang, J., & Cui, B. (2024) · arXiv · doi:10.48550/arxiv.2402.19473 · Cited by 240
“It filters out lower-quality data to maintain a high standard of information mapping, offering a variety of retrieval system options like TF-IDF, DPR, RAG, and BLINK + flair to support evidence-based predictions or citations according to task requirements.”
Large language models for code completion: A systematic literature review
Husein, R. A., Aburajouh, H., & Catal, C. (2025) · Computer Standards & Interfaces · doi:10.1016/j.csi.2024.103917 · Cited by 72
Metadata
- Authors
- Tang, Z., Ge, J., Liu, S., Zhu, T., Xu, T., Huang, L., & Luo, B.
- Affiliations
- Nanjing University,National Key Laboratory for Novel Software Technology,China
- Nanyang Technological University,Singapore
- Huawei Software Engineering Application Technology,China
- Southern Methodist University,Department of Computer Science,USA
- Venue
- 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)
- Publisher
- IEEE
- Published
- 2023-09-11
- Pages
- 421-433
- Cited by
- 36
- References
- 26
- Funders
- National Key Research and Development Program of China (2022YFF0711404)
- Natural Science Foundation of Jiangsu Province (BK20201250)
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review
Data sources
Bibliographic data: Semantic Scholar, OpenAlex, Crossref.
Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).
Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.