Skip to main content
QUICK REVIEW

[Paper Review] STALL+: Boosting LLM-based Repository-level Code Completion with Static Analysis

Junwei Liu, Yixuan Chen|arXiv (Cornell University)|Jun 14, 2024
Natural Language Processing TechniquesComputer Science3 citations
TL;DR

This paper proposes STALL+, a framework that integrates static analysis into multiple phases of LLM-based repository-level code completion to improve accuracy and reduce hallucination. It finds that prompting-phase integration of file-level dependencies yields the best performance, especially for static languages like Java, while combining static analysis with RAG offers complementary, cost-effective gains.

ABSTRACT

Repository-level code completion is challenging as it involves complicated contexts from multiple files in the repository. To date, researchers have proposed two technical categories to enhance LLM-based repository-level code completion, i.e., retrieval-augmented generation (RAG) and static analysis integration. This work performs the first study on the static analysis integration in LLM-based repository-level code completion by investigating both the effectiveness and efficiency of static analysis integration strategies across different phases of code completion. We first implement a framework STALL+, which supports an extendable and customizable integration of multiple static analysis strategies into the complete pipeline of LLM-based repository-level code completion; and based on STALL+, we perform extensive experiments by including different code LLMs on the latest repository-level code completion benchmark CrossCodeEval. Our findings show that integrating file-level dependencies in prompting phase performs the best while the integration in post-processing phase performs the worse. Additionally, we observe different improvements from static analysis between dynamic languages and static languages, i.e., the best combination is prompting-phase with decoding-phase integration for Java while the best combination is prompting-phase with post-processing-phase integration for Python given the limitations of statically analyzing dynamic languages. Additionally, we find the complementarity between RAG and static analysis integration as well as their cost-effectiveness after combination.

Motivation & Objective

  • Address the challenge of hallucination in LLM-based repository-level code completion due to limited knowledge of local repository context.
  • Investigate the effectiveness and efficiency of integrating static analysis across different phases of the code completion pipeline.
  • Evaluate the complementarity between static analysis and retrieval-augmented generation (RAG) in improving code completion accuracy.
  • Provide a customizable, extendable framework to support diverse static analysis strategies and their integration with LLMs.

Proposed method

  • Design STALL+, a modular framework that enables integration of multiple static analysis strategies at three pipeline stages: prompting, decoding, and post-processing.
  • Support extendable and customizable integration of static analysis tools (e.g., dependency extractors, type checkers) into the LLM inference pipeline.
  • Integrate static analysis in the prompting phase by extracting and injecting relevant code dependencies from other files into the input prompt.
  • Apply static analysis during decoding by modifying token probabilities based on analysis results to guide more accurate generation.
  • Apply static analysis in post-processing to validate or refine generated code using type checks or control flow analysis.
  • Ensure compatibility with RAG techniques by allowing simultaneous use of retrieved code snippets and static analysis results in the input.
Figure 1. Overview of the STALL + static analysis integration framework
Figure 1. Overview of the STALL + static analysis integration framework

Experimental results

Research questions

  • RQ1How effective is static analysis integration when applied at different phases (prompting, decoding, post-processing) of the LLM-based code completion pipeline?
  • RQ2How does the performance of static analysis integration vary between dynamic languages (e.g., Python) and static languages (e.g., Java)?
  • RQ3What is the relative effectiveness and efficiency of combining static analysis with retrieval-augmented generation (RAG) in repository-level code completion?
  • RQ4Which combination of static analysis strategies across phases yields the highest improvement in code completion accuracy?

Key findings

  • Integrating file-level dependencies via static analysis in the prompting phase yields the highest performance improvement, outperforming integration in decoding or post-processing phases.
  • Post-processing phase integration of static analysis performs the worst, indicating limited utility for final code refinement.
  • For Java (a statically-typed language), the best performance is achieved by combining prompting-phase and decoding-phase static analysis integration.
  • For Python (a dynamically-typed language), the best performance comes from combining prompting-phase and post-processing-phase integration, due to limitations in static analysis accuracy for dynamic features.
  • Static analysis and RAG techniques are complementary: combining them yields higher accuracy than either alone, with improved cost-effectiveness.
  • The framework STALL+ enables effective, customizable integration of static analysis across the code completion pipeline, supporting future research and tool development.
Figure 2. Comparison case of three strategies
Figure 2. Comparison case of three strategies

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.