Skip to main content
QUICK REVIEW

[Paper Review] CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completion

Yangruibo Ding, Zijian Wang|arXiv (Cornell University)|Oct 17, 2023
Software Engineering ResearchComputer Science10 citations
TL;DR

CrossCodeEval introduces a cross-file, multilingual code completion benchmark across Python, Java, TypeScript, and C#, using static-analysis to require cross-file context. It evaluates CodeGen, StarCoder, and GPT-3.5-Turbo with in-file, retrieval, and retrieval-with-reference prompts, highlighting the importance and challenge of cross-file context for code LMs.

ABSTRACT

Code completion models have made significant progress in recent years, yet current popular evaluation datasets, such as HumanEval and MBPP, predominantly focus on code completion tasks within a single file. This over-simplified setting falls short of representing the real-world software development scenario where repositories span multiple files with numerous cross-file dependencies, and accessing and understanding cross-file context is often required to complete the code correctly. To fill in this gap, we propose CrossCodeEval, a diverse and multilingual code completion benchmark that necessitates an in-depth cross-file contextual understanding to complete the code accurately. CrossCodeEval is built on a diverse set of real-world, open-sourced, permissively-licensed repositories in four popular programming languages: Python, Java, TypeScript, and C#. To create examples that strictly require cross-file context for accurate completion, we propose a straightforward yet efficient static-analysis-based approach to pinpoint the use of cross-file context within the current file. Extensive experiments on state-of-the-art code language models like CodeGen and StarCoder demonstrate that CrossCodeEval is extremely challenging when the relevant cross-file context is absent, and we see clear improvements when adding these context into the prompt. However, despite such improvements, the pinnacle of performance remains notably unattained even with the highest-performing model, indicating that CrossCodeEval is also capable of assessing model's capability in leveraging extensive context to make better code completion. Finally, we benchmarked various methods in retrieving cross-file context, and show that CrossCodeEval can also be used to measure the capability of code retrievers.

Motivation & Objective

  • Motivate the need to evaluate code completion with cross-file context in realistic software repositories.
  • Create CrossCodeEval from real open-source repositories with strict cross-file completion requirements.
  • Ensure minimal overlap with training data to avoid memorization confounds.
  • Provide a benchmark that can also evaluate cross-file context retrieval capabilities.

Proposed method

  • Construct a cross-file code completion dataset from permissively licensed GitHub repositories in four languages.
  • Automatically identify cross-file contextual dependencies using static analysis to generate prompts requiring cross-file context.
  • Post-process and filter data for quality and to reduce leakage, including a retrieval-based verification step.
  • Evaluate multiple code LMs (CodeGen at multiple sizes, StarCoder, GPT-3.5-Turbo) in zero-shot settings with in-file, retrieved, and retrieved-with-reference prompts.
  • Use two metrics: code match (exact match and edit similarity) and identifier match (EM and F1) to assess performance.

Experimental results

Research questions

  • RQ1Does cross-file context improve code completion performance across major programming languages?
  • RQ2How do retrieval-based methods compare to in-file contexts for cross-file code completion?
  • RQ3What is the upper bound of performance when using reference-derived cross-file context for retrieval?
  • RQ4How do different retrievers (BM25, neural retrievers) fare on cross-file code retrieval tasks within this benchmark?
  • RQ5Can CrossCodeEval serve as a benchmark for code retrieval quality and strategy?

Key findings

  • Models perform poorly with in-file context alone, showing the need for cross-file context.
  • Adding cross-file context yields significant performance gains across languages and models.
  • Retrieval with cross-file context improves exact code match by up to about 3x for some models and languages, with further gains when using retrieval with reference, illustrating upper-bound effects.
  • Performance remains far from perfect even with retrieved cross-file context, indicating room for improvement in leveraging extensive repository-level context.
  • The retrieval method quality substantially impacts results, and OpenAI ada embeddings often outperform sparse BM25 in certain languages; however, even the best retriever underperforms the ideal upper bound, signaling a need for better cross-file retrieval techniques.

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.