Large language models (LLMs) with retrieval-augmented generation (RAG) have demonstrated encouraging performance in repository-level code completion. These approaches often employ a retriever to search for code snippets based on unfinished code. However, an often-neglected observation is that similarity does not inherently guarantee assistance. Furthermore, similarity-based retrieval strategies can only provide partial, localized information within the repository, missing the big picture of the entire repository. In this paper, we propose StructuralCoder, a framework replacing retriever with an extractor which builds the repository structure to provide a comprehensive and more helpful context. It traverses the entire repository, generating a hybrid tree structure combined with directory tree and abstract syntax tree (AST). During the entire process, StructuralCoder does not require access or update to the weights of LLM. Our evaluations on CrossCodeEval show that StructuralCoder significantly outperforms existing techniques in repository-level code completion when compared to several baselines. Our source code is available at: https://github.com/Kagam11/StructuralCoder .

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

StructuralCoder: Repository Structure Based RAG for Repository-Level Code Completion

  • Tao Zou,
  • Kaicun Lin,
  • Huaqiang Yuan

摘要

Large language models (LLMs) with retrieval-augmented generation (RAG) have demonstrated encouraging performance in repository-level code completion. These approaches often employ a retriever to search for code snippets based on unfinished code. However, an often-neglected observation is that similarity does not inherently guarantee assistance. Furthermore, similarity-based retrieval strategies can only provide partial, localized information within the repository, missing the big picture of the entire repository. In this paper, we propose StructuralCoder, a framework replacing retriever with an extractor which builds the repository structure to provide a comprehensive and more helpful context. It traverses the entire repository, generating a hybrid tree structure combined with directory tree and abstract syntax tree (AST). During the entire process, StructuralCoder does not require access or update to the weights of LLM. Our evaluations on CrossCodeEval show that StructuralCoder significantly outperforms existing techniques in repository-level code completion when compared to several baselines. Our source code is available at: https://github.com/Kagam11/StructuralCoder .