EvoCodeBench: A Real-World Code Benchmark
EvoCodeBench: A Real-World Code Benchmark
Benchmark Real Repo. Real Code Distribution Comprehensive Annota. Robust Metric Avoiding Data Leak.
CoNaLA (Yin et al., 2018) é é é é é
Concode (Iyer et al., 2018) Ë é é é é
HumanEval (Chen et al., 2021) é é é é é
MBPP (Austin et al., 2021) é é é é é
APPS (Hendrycks et al., 2021) é é é é é
PandasEval (Zan et al., 2022) é é é é é
NumpyEval (Zan et al., 2022) é é é é é
AixBench (Li et al., 2023b) Ë é é é é
ClassEval (Du et al., 2023) é é é é é
CoderEval (Yu et al., 2023) Ë é é Ë é
EvoCodeBench (Ours) Ë Ë Ë Ë Ë
and ensure their ratios are realistic. The number and report Pass@k. It also proposes Recall@k
of dependencies should also be consistent with to evaluate the dependencies in predictions. ❺
real-world repositories. EvoCodeBench is an evolving benchmark and
will be dynamically updated every period (e.g.,
• Comprehensive Annotations. The benchmark 6 months) to avoid data leakage. In this paper,
can offer comprehensive annotations, including we release the first version - EvoCodeBench-2403,
natural language requirements, original reposito- which consists of 275 samples from 25 real-world
ries, and ground truths (code and dependencies). repositories. Details of the collection process can
be found in Section 3.
• Robust Evaluation Metrics. The benchmark
should contain test cases to evaluate models’ pre- Based on EvoCodeBench, we propose
dictions and report Pass@k. Metrics are also repository-level code generation, which simu-
required to assess the abilities of LLMs to gener- lates the developers’ coding process in a working
ate dependencies. repository. The task asks models to write the code
based on requirements and a complete repository.
• Avoidng Data Leaking. With more LLMs We evaluate 10 popular LLMs (i.e., gpt-4 (Ope-
emerging, the benchmark should avoid potential nAI, 2023b), gpt-3.5 (OpenAI, 2023a), DeepSeek
data leakage (Huang et al., 2023). Coder (Guo et al., 2024), StarCoder 2 (Lozhkov
et al., 2024), CodeLLaMa (Rozière et al., 2023),
However, as shown in Table 1, none of the existing Gemma (GemmaTeam, 2024), and Qwen 1.5 (Bai
benchmarks satisfies all aforementioned features. et al., 2023)). These LLMs exhibit low perfor-
The problem hinders the evaluation and develop- mance on EvoCodeBench, especially compared to
ment of LLMs in the real development process. their performance on previous benchmarks. For
To address the above problem, we pro- example, gpt-4-turbo-1106 achieves a Pass@1
pose a new code generation benchmark named score of 80% on HumanEval, while its highest
EvoCodeBench, which aligns with real-world Pass@1 on EvoCodeBench is only 20.73%. Our
code repositories. As shown in Table 1, results reveal the coding abilities of these LLMs in
EvoCodeBench satisfies the above features. ❶ real-world repositories. We further analyze failed
EvoCodeBench is collected from high-quality cases and summarize the shortcomings of existing
open-source repositories in the real world. ❷ LLMs in EvoCodeBench.
EvoCodeBench is constructed through a rigorous In summary, our contributions are as follows:
pipeline and aligns with real-world repositories.
Specifically, the distributions of code and depen- • We summarize five features (see Table 1) that a
dencies in EvoCodeBench are consistent with the code generation benchmark for real-world repos-
ones in 500 real-world repositories. Detailed statis- itories should satisfy.
tics are in Section 2.4. ❸ EvoCodeBench of-
fers comprehensive annotations, e.g., detailed re- • We propose a new code generation benchmark
quirements, original repositories, reference code, - EvoCodeBench, satisfying the above features.
and reference dependencies. ❹ EvoCodeBench We released the first version and will continually
leverages test cases to check models’ predictions update it.
EvoCodeBench
Stats: A evolutionary code generation benchmark
Evaluation Task: Repository-level code generation: ① ② ③ → ④
Evaluation Metrics: Pass@k (functional correctness, label: ⑥), Recall@k (recall of reference dependencies, label: ⑤)
① Signature ③ Repository
def create(self, model: str,
path: Optional[Union[str, PathLike]] = None, import httpx
modelfile: Optional[str] = None, import platform
stream: bool = False, ...
) -> Union[Mapping[str, Any],Iterator[Mapping[str, Any]]]: class BaseClient:
...
② Requirement class Client(BaseClient):
Initiate a request to create a model based on the provided ...
path. Handle the request either as a single response or as class AsyncClient(…):
a stream of responses, depending on the `stream` parameter. ...
def _encode_image(…):
:param self: Client. An instance of Client class. ...
:param model: str, The model to be created. def _as_path(…):
:param path: Optional[…], . . . ...
:param modelfile: Optional[str], . . . (more 700 lines . . .)
:param steam, bool, . . .
:return Union[…], . . .
Intra-class Dependency:
④ Reference Code ollama._client.Client._parse_modelfile
ollama._client.Client._request_stream
if (realpath := _as_path(path)) and [Link]():
modelfile = self._parse_modelfile(realpath.read_text())
elif modelfile: Intra-file Dependency:
modelfile = self._parse_modelfile(modelfile) ollama._client._as_path
else: ⑤ Reference
raise RequestError('must provide path or modelfile‘) Cross-file Dependency: Dependency
return self._request_stream(…) ollama._types.RequestError
• We propose repository-level code generation, code. ❸ Repository: The current repository con-
which provides a challenging and realistic evalu- tains hundreds of code files. ❹ Reference Code:
ation scenario. A developer-written implementation of the target
code. This code may invoke dependencies defined
• We evaluate 10 popular LLMs on in the current repository. ❺ Reference Depen-
EvoCodeBench, analyzing their strengths dency: The dependencies invoked in the reference
and shortcomings in repository-level code code include intra-class, intra-file, and cross-file
generation. dependencies. ❻ Test Cases: Test cases are used
We hope EvoCodeBench can align with the ac- to check the functional correctness of the code.
tual experiences of developers during the practical
development process. By EvoCodeBench, practi- 2.2 Task Definition
tioners can pick up superior LLMs and facilitate Traditional benchmarks fall into a sim-
the application of code generation techniques in ple requirement-to-code task. In contrast,
real-world repositories. EvoCodeBench proposes a more realistic task
- repository-level code generation. This task
2 EvoCodeBench simulates the developers’ coding process in a
In this section, we first show an overview of working repository. Given a requirement and a
EvoCodeBench and then describe its tasks and repository, LLMs are tasked to generate the code
metrics. Finally, we present the first version - for the repository.
EvoCodeBench-2403 and its statistics.
2.3 Evaluation Metrics
2.1 Overview Pass@k (Functional Correctness). Following pre-
Figure 2 shows a sample in EvoCodeBench. Each vious studies (Chen et al., 2021; Austin et al., 2021;
sample consists of six components. Yu et al., 2023), we assess the functional correct-
❶ Function Signature: The signature of the ness of programs by executing test cases and com-
target code. ❷ Requirement: An English de- pute the unbiased Pass@k. Specifically, we gen-
scription detailing the functionality of the target erate n ≥ k programs per requirement, count the
Table 2: The comparison between existing code generation benchmarks and EvoCodeBench-2403. SA and Depend
are the abbreviations of “standalone” and “dependency”, respectively.
number of correct programs c ≤ n that pass test EvoCodeBench-2403 is consistent with that of 500
cases, and calculate the Pass@k: real-world repositories. The average number of
dependencies per program in EvoCodeBench-2403
n−c
is also close to that of 500 real-world repositories.
k ❷ Comprehensive Annotations. We provide
Pass@k := 1 −
E
Requirements n
(1) requirements, reference code, reference depen-
k dency and the complete repository for each sam-
ple. Previous works (i.e., CoderEval, ClassEval)
Recall@k (Recall of Reference Dependency). only provide dependencies’ names (e.g., close).
Besides the functional correctness, we expect Because many functions have the same name
LLMs to invoke relevant dependencies defined in in practice, it is hard to identify whether gen-
contexts. Hence, we propose Recall@k, which erated dependencies are correct by relying on
gauges the recall of reference dependencies in gen- names. EvoCodeBench annotates dependencies
erated programs. with paths (e.g., [Link]::ClassB::close), ad-
Specifically, LLMs generate k programs per re- dressing ambiguity and biases. These annotations
quirement. For the i-th program, we employ a offer a broad arena to explore repository-level code
parser2 to extract its dependencies as Pi . Subse- generation and evaluation.
quently, we compare Pi with reference dependen- ❸ Latest repositories to avoid data leak-
cies R and compute the Recall@k: age. Considering the latest LLM’s (Lozhkov
et al., 2024) training data is up to 2023-9,
|R ∩ Pi |
Recall@k := E max (2) EvoCodeBench-2403 is collected from real-world
Requirements i∈[1,k] |R|
repositories that were created from 2023-10 to
where | · | means the number of elements of a set. 2024-2. In future versions, we will continually
update EvoCodeBench using the latest repositories.
2.4 EvoCodeBench-2403
3 Benchmark Collection Pipeline
This paper releases the first version of
EvoCodeBench named EvoCodeBench-2403. The We build an automatic pipeline for collecting
statistics of EvoCodeBench-2403 are shown in EvoCodeBench from the latest repositories. The
Table 2. We discuss its features as follows. pipeline consists of four stages as follows.
❶ Alignment with real-world code reposito- ❶ Repository Selection. We crawl high-quality
ries. EvoCodeBench-2403 consists of 275 sam- repositories from GitHub satisfying the following
ples collected from 25 real-world repositories. criteria: open-source Python projects; created in re-
As shown in Table 2, the code distribution of cent months; non-fork and non-malicious projects;
2
We develop the parser based on an open-source static more than 50 stars; and having explicit unit tests.
analysis tool - Pyan (Pyan, 2023). ❷ Function Parse. We extract functions from
repositories and exclude trivial functions (e.g., Table 3: Studied LLMs in this paper. Context L.: Con-
empty or initialization functions). We extract each text Window.
function’s signature and function body (i.e., refer- Type Name Version Context W.
ence code). We developed a static analysis-based gpt-4 gpt-4-turbo-1106 128,000
Closed-source
parser to extract reference dependencies with the gpt-3.5 gpt-3.5-turbo-1106 16,385
reference code. StarCoder 2 15B 16,384
StarCoder 2 7B 16,384
❸ Tests Construction. For each function, we ex- DeepSeek Coder 33B 16,384
tract test cases invoking it from current repositories. Open-source
DeepSeek Coder 6.7B 16,384
We use pip3 to automatically install required pack- CodeLLaMa 13B 16,384
CodeLLaMa 7B 16,384
ages for each repository and leverage Pytest4 to Gemma 7B 8,192
run test cases. Functions without executable test Qwen 1.5 7B 32,768
LLMs Size Pass@1 Pass@3 Pass@5 Pass@10 Recall@1 Recall@3 Recall@5 Recall@10
Local File (Infilling)
gpt-4 N/A 20.73 23.03 24.11 25.34 68.24 70.63 72.05 73.52
gpt-3.5 N/A 17.82 21.78 23.06 24.46 61.94 68.13 69.69 70.85
DeepSeek Coder 33B 19.64 22.78 24.29 26.01 71.46 79.93 82.11 86.25
DeepSeek Coder 6.7B 17.82 21.02 22.40 23.97 69.58 74.04 78.00 83.22
StarCoder 2 15B 14.91 17.54 18.63 19.86 50.90 53.29 55.89 61.76
StarCoder 2 7B 15.27 17.29 18.63 20.09 56.35 60.59 63.74 74.20
Local File (Completion)
gpt-4 N/A 17.45 19.65 20.80 22.41 63.49 68.67 70.00 72.07
gpt-3.5 N/A 15.64 17.29 18.21 19.36 61.44 66.25 66.82 69.89
DeepSeek Coder 33B 14.18 17.57 18.66 19.95 66.90 72.83 74.40 80.02
DeepSeek Coder 6.7B 13.45 17.10 18.81 21.07 65.76 72.32 75.61 78.45
StarCoder 2 15B 13.45 15.44 17.84 19.59 68.55 71.37 74.76 77.70
StarCoder 2 7B 13.82 15.15 16.18 17.65 62.93 69.85 73.54 78.40
CodeLLaMa 13B 12.73 15.78 16.86 18.19 63.34 71.26 76.43 80.11
CodeLLaMa 7B 12.73 15.33 16.00 16.93 63.33 69.79 71.91 76.50
Gemma 7B 10.55 13.25 14.31 15.48 58.02 70.57 74.44 80.76
Qwen 1.5 7B 5.45 7.04 7.91 9.07 39.21 44.02 50.17 58.42
Without Contexts
gpt-4 N/A 7.27 10.05 10.70 11.49 21.58 23.93 25.69 26.23
gpt-3.5 N/A 6.55 7.85 8.28 8.73 21.66 24.31 24.77 25.40
DeepSeek Coder 33B 6.91 8.92 9.79 11.03 27.67 32.73 34.92 37.76
DeepSeek Coder 6.7B 5.82 8.56 9.67 11.26 25.89 32.06 35.59 38.33
StarCoder 2 15B 6.18 8.77 9.95 11.53 24.03 29.86 33.62 36.91
StarCoder 2 7B 5.82 6.72 7.43 8.62 27.39 32.60 34.88 36.81
CodeLLaMa 13B 5.45 7.38 8.37 9.95 25.52 31.28 33.66 36.36
CodeLLaMa 7B 5.45 6.94 7.75 9.03 26.97 31.17 34.08 36.82
Gemma 7B 6.18 6.86 7.64 8.66 21.84 29.98 33.61 35.23
Qwen 1.5 7B 4.00 4.72 5.38 6.18 16.33 13.56 16.34 21.06
[1, 3, 5, 10]. When k = 1, we use the greedy search HumanEval, while it scores 7.27 on Pass@1 upon
and generate a single program per requirement. EvoCodeBench-2403. On the one hand, the de-
When k > 1, we use the nucleus sampling with creases validate our motivation that existing bench-
a temperature 0.4 and sample 20 programs per re- marks can not comprehensively assess the coding
quirement. We set the top-p to 0.95 and the max abilities of LLMs in practical projects. On the other
generation length to 500. hand, the results emphasize the importance of con-
Because EvoCodeBench is an evolving texts in repositories. Without the necessary context,
benchmark, this paper evaluates LLMs upon LLMs lack the domain knowledge of current repos-
EvoCodeBench-2403. Note that the Pass@k itories and generate the wrong programs.
and Recall@k between different versions of Local File (Completion) and (Infilling). After
EvoCodeBench are not comparable. introducing the contexts within local files, the
Pass@k and Recall@k of all LLMs obviously in-
4.4 Main Results crease. For example, the Pass@1 of gpt-4 is im-
The Pass@k and Recall@k in three experimental proved by 104% and 152% in two settings, respec-
settings are shown in Table 7. tively. We attribute the improvements to the do-
Without Context. gpt-4 achieves the highest main knowledge contained in contexts. Figure 3
Pass@k among all LLMs. However, compared shows a uniquely successful case in the Local File
to previous benchmarks, these LLMs’ performance (Completion) setting. The key to writing this func-
in EvoCodeBench-2403 drops dramatically. For tion is to know cache directories. Without context,
example, gpt-4 achieves a Pass@1 score of 88.4 on gpt-4 fabricated a non-existent field as cache direc-
Contexts (above):
import concurrent
import json
. . .
def _get_num_nodes() -> int:
. . .
def _get_cache_dir(name: Optional[str] = None):
. . .
def _get_cache_data_dir(name: Optional[str] = None):
. . .
Input Code:
def _cleanup_cache(self) -> None:
""" Clean up cache directories by removing them if
they exist to prevent issues from corrupted files
from previous runs, and then recreates these Figure 4: Pass@1 of gpt-4 on different program types.
directories to ensure they are available for use.
:param self: DataProcessor. ...
:return: No return values.
"""
gpt-4-turbo-1106 (without context):
find that LLMs can generate some dependencies
for cache_dir in self.cache_directories:
without context. We manually inspect successful
# Check if the cache directory exists cases and summarize two reasons. First, LLMs
if [Link](cache_dir):
. . . can reason about some easy dependencies from re-
gpt-4-turbo-1106 (local completion): quirements, e.g., initialization functions of returned
# Define the cache directories objects. Second, LLMs can “guess” dependencies
cache_data_dir = _get_cache_data_dir()
cache_chunks_dir = _get_cache_dir() from their functionalities. In practice, dependen-
# Remove the cache data directory if it exists
cies’ names are relevant to their functional descrip-
if [Link](cache_data_dir): tions, e.g., send_request() means send a re-
. . .
quest to the server. LLMs are trained with a large
code corpus and can learn the naming conventions.
Figure 3: A uniquely successful case in Local File (Com- Thus, LLMs may successfully guess some depen-
pletion) setting.
dencies from their functionalities.
❷ More contexts benefit code generation.
Based on Table 7, we compare the performance
tories, generating the incorrect code. In fact, two
of an LLM (e.g., gpt-4) under different settings.
functions for returning the cache directories are
Obviously, the more input contexts, the better the
available in the local file. After introducing the lo-
performance of the LLM. It inspires practitioners
cal file, gpt-4 successfully gets cache directories by
to extend the context windows of LLMs and input
invoking these functions and generates the correct
more contexts.
code.
❸ The gpt family models have higher Pass@k
Error Analyses. Although promising, the Pass@k and lower Recall@k, while other models are the
of existing LLMs is still low and far from practical opposite. We speculate the reason is that gpt fam-
applications. To determine LLMs’ shortcomings, ily models are instruction-tuned models and focus
we manually analyze 50 error cases of gpt-4 in the on performing tasks based on given instructions.
Local File (Infilling) setting. We found that most of With limited contexts, gpt family models are con-
the cases (29 cases) failed due to implementation servative and tend to generate code independently.
logic errors. 20 cases failed since the necessary con- Other LLMs are standard language models trained
texts were missing, e.g., APIs defined in other files. with real code files containing dependencies. They
Besides, one case failed because of the vague re- are aggressive and generate dependencies that may
quirement. It shows that existing LLMs’ reasoning exist. The comparisons show the importance of
and coding abilities need to be improved. Mean- instruction tuning in practical applications.
while, how to utilize more contexts is necessary to
explore. 4.5 Empirical Leassons
We also obtain some interesting findings from Based on the above experiments, we summarize
Table 7. the empirical lessons we learned as
❶ LLMs successfully generate some depen- ❶ EvoCodeBench pose new challenges, i.e.,
dencies without context. Theoretically, LLMs do repository-level code generation. The performance
not see the contexts and cannot generate dependen- of existing LLMs on EvoCodeBench-2403 drops
cies. According to Table 7, we are surprised to dramatically compared to their performance on pre-
Table 5: The comparison between auto-generated re- Table 6: Pass@1 and Recall@1 with retrieval-
quirements and human-written requirements. augmented generation.
Annotator Win / Tie / Lose Cost (Time) Cost (Money) LLMs Setting Pass@1 Recall@1
gpt-4 5 / 41 / 4 12m30s $0.54 Without Context 8.31 21.08
Human 4 / 41 / 5 4h10m $31.25 gpt-4
Similar Functions 12.29 45.14
Without Context 6.64 21.16
gpt-3.5
vious benchmarks. Similar Functions 11.62 41.93
❷ LLMs benefit from code contexts in current
repositories. With limited context windows, the
for us to use gpt-4 to annotate requirements for
contexts from local files can improve gpt-4 by
EvoCodeBench.
152% in Pass@1.
❸ The main reasons why programs generated by Retrieval-Augmented Generation (RAG). RAG
LLMs fail are logic errors and incomplete contexts. is to enhance generative models with retrieved in-
How to enhance reasoning abilities and context formation and has achieved promising results in
windows of LLMs is important. code generation (Li et al., 2023b,c). We try to
apply RAG to repository-level code generation
5 Discussion and consider the repository to be a retrieval cor-
pus. Because most programs in repositories are not
Evaluation of auto-generated requirements. We equipped with documentation, we retrieve top-k
leverage an LLM (gpt-4 in this paper) to generate (i.e., k = 5 in this paper) functions with similar
natural language requirements for functions auto- names to the target function. Specifically, we split
matically. To assess the quality of auto-generated names into tokens based on underscore or camel-
requirements, we randomly select 50 functions case formatting and then match the tokens of names.
from EvoCodeBench-2403 and compare require- Finally, we use similar functions as contexts in
ments from gpt-4 and human developers. We prompts and further generate code. The experimen-
hire two developers to write the requirements tal results are shown in Table 6. The performance
and two others to evaluate auto-generated and of both LLMs is improved after introducing similar
human-written requirements. The evaluation met- functions. LLMs can know relevant algorithms and
rics include completeness (whether the require- dependencies from similar functions, which benefit
ments cover the intent of code), clarity (whether writing new programs. In the future, we will ex-
the requirements are clear and user-friendly). All plore more advanced RAG techniques to improve
developers are paid according to the relevant poli- repository-level code generation.
cies5 ($7.5 per hour). Results on different program types. Figure 4
The evaluation results are shown in Table 5. The shows Pass@1 of gpt-4 on different program types
Cohen’s Kappa coefficient between the two eval- (i.e., standalone and non-standalone). The results
uators is 0.92. On 41 functions, gpt-4 and devel- are consistent with the above Table 7. Code con-
opers tie. In the remaining functions, gpt-4 wins texts significantly improve the Pass@1 on non-
by 5 functions, and developers win by 4 functions. standalone functions. Meanwhile, the Pass@1 on
These results show that gpt-4 can produce high- standalone functions also slightly increases. We
quality requirements comparable to human-written speculate that the domain knowledge (e.g., private
requirements in most cases (92% = 46/50). We objects) within contexts helps LLMs understand
also inspect the four functions lost by gpt-4 and find requirements. However, the Pass@1 on both types
that some necessary details (e.g., hyper-parameters) of programs is still low. The coding abilities of
are missing in its requirements. In the future, we existing LLMs in real-world repositories need to
will explore new techniques to solve this problem, be further improved.
e.g., controllable text generation (Dekoninck et al.,
Results on different dependency types. Figure 5
2023). Besides the high-quality requirements, gpt-
shows the Recall@1 of gpt-4 on different depen-
4 shows advantages in costs. As shown in Table 5,
dency types (i.e., intra-class, intra-file, and cross-
got-4 costs less time and money to annotate require-
file). The results yield two insights. ❶ Without
ments. Thus, it is a feasible and efficient approach
context, LLMs can reason about some simple de-
5
[Link] pendencies from requirements (e.g., initialization
achieving significant advancements in code gen-
eration, such as Codex (Chen et al., 2021), Chat-
GPT (OpenAI, 2023a), CodeLlama (Rozière et al.,
2023), DeepSeek Coder (Guo et al., 2024), and
StarCoder2 (Lozhkov et al., 2024).
Xueying Du, Mingwei Liu, Kaixin Wang, Hanlin Wang, Srinivasan Iyer, Ioannis Konstas, Alvin Cheung, and
Junwei Liu, Yixuan Chen, Jiayi Feng, Chaofeng Luke Zettlemoyer. 2018. Mapping language to code
Sha, Xin Peng, and Yiling Lou. 2023. Classeval: A in programmatic context. In Proceedings of the 2018
manually-crafted benchmark for evaluating llms on Conference on Empirical Methods in Natural Lan-
class-level code generation. CoRR, abs/2308.01861. guage Processing, Brussels, Belgium, October 31 -
November 4, 2018, pages 1643–1652. Association
Daniel Fried, Armen Aghajanyan, Jessy Lin, Sida Wang, for Computational Linguistics.
Eric Wallace, Freda Shi, Ruiqi Zhong, Scott Yih,
Luke Zettlemoyer, and Mike Lewis. 2023. Incoder: Xue Jiang, Yihong Dong, Lecheng Wang, Qiwei Shang,
A generative model for code infilling and synthesis. and Ge Li. 2023. Self-planning code generation with
In ICLR. [Link]. large language model. CoRR, abs/2303.06689.
Deep Ganguli, Liane Lovitt, Jackson Kernion, Amanda Carlos E. Jimenez, John Yang, Alexander Wettig,
Askell, Yuntao Bai, Saurav Kadavath, Ben Mann, Shunyu Yao, Kexin Pei, Ofir Press, and Karthik
Ethan Perez, Nicholas Schiefer, Kamal Ndousse, Narasimhan. 2023. Swe-bench: Can language
Andy Jones, Sam Bowman, Anna Chen, Tom Con- models resolve real-world github issues? CoRR,
erly, Nova DasSarma, Dawn Drain, Nelson Elhage, abs/2310.06770.
Jia Li, Ge Li, Yongmin Li, and Zhi Jin. 2023a. Struc- Disha Shrivastava, Hugo Larochelle, and Daniel Tar-
tured chain-of-thought prompting for code genera- low. 2023. Repository-level prompt generation for
tion. arXiv preprint arXiv:2305.06599. large language models of code. In International Con-
ference on Machine Learning, ICML 2023, 23-29
Jia Li, Yongmin Li, Ge Li, Zhi Jin, Yiyang Hao, and July 2023, Honolulu, Hawaii, USA, volume 202 of
Xing Hu. 2023b. Skcoder: A sketch-based approach Proceedings of Machine Learning Research, pages
for automatic code generation. In 45th IEEE/ACM 31693–31715. PMLR.
International Conference on Software Engineering,
ICSE 2023, Melbourne, Australia, May 14-20, 2023, Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier
pages 2124–2135. IEEE. Martinet, Marie-Anne Lachaux, Timothée Lacroix,
Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal
Jia Li, Yunfei Zhao, Li Yongmin, Ge Li, and Zhi Jin. Azhar, Aurélien Rodriguez, Armand Joulin, Edouard
2023c. Acecoder: Utilizing existing code to enhance Grave, and Guillaume Lample. 2023. Llama: Open
code generation. arXiv preprint arXiv:2303.17780. and efficient foundation language models. CoRR,
abs/2302.13971.
Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Pengcheng Yin, Bowen Deng, Edgar Chen, Bogdan
Julian Schrittwieser, Rémi Leblond, Tom Eccles, Vasilescu, and Graham Neubig. 2018. Learning to
James Keeling, Felix Gimeno, Agustin Dal Lago, mine aligned code and natural language pairs from
et al. 2022. Competition-level code generation with stack overflow. In Proceedings of the 15th Interna-
alphacode. Science, 378(6624):1092–1097. tional Conference on Mining Software Repositories,
MSR 2018, Gothenburg, Sweden, May 28-29, 2018,
Tianyang Liu, Canwen Xu, and Julian J. McAuley. 2023. pages 476–486. ACM.
Repobench: Benchmarking repository-level code
auto-completion systems. CoRR, abs/2306.03091. Hao Yu, Bo Shen, Dezhi Ran, Jiaxin Zhang, Qi Zhang,
Yuchi Ma, Guangtai Liang, Ying Li, Tao Xie, and
Anton Lozhkov, Raymond Li, Loubna Ben Allal, Fed- Qianxiang Wang. 2023. Codereval: A benchmark
erico Cassano, Joel Lamy-Poirier, Nouamane Tazi, of pragmatic code generation with generative pre-
Ao Tang, Dmytro Pykhtar, Jiawei Liu, Yuxiang Wei, trained models. CoRR, abs/2302.00288.
et al. 2024. Starcoder 2 and the stack v2: The next
generation. arXiv preprint arXiv:2402.19173. Daoguang Zan, Bei Chen, Dejian Yang, Zeqi Lin, Minsu
Kim, Bei Guan, Yongji Wang, Weizhu Chen, and
Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Jian-Guang Lou. 2022. CERT: continual pre-training
Wang, Yingbo Zhou, Silvio Savarese, and Caiming on sketches for library-oriented code generation. In
Xiong. 2023. Codegen: An open large language Proceedings of the Thirty-First International Joint
model for code with multi-turn program synthesis. Conference on Artificial Intelligence, IJCAI 2022,
In ICLR. [Link]. Vienna, Austria, 23-29 July 2022, pages 2369–2375.
[Link].
OpenAI. 2023a. gpt-3.5-turbo. https:
Fengji Zhang, Bei Chen, Yue Zhang, Jacky Keung, Jin
//[Link]/docs/models/
Liu, Daoguang Zan, Yi Mao, Jian-Guang Lou, and
gpt-3-5.
Weizhu Chen. 2023. Repocoder: Repository-level
code completion through iterative retrieval and gen-
OpenAI. 2023b. GPT-4 technical report. CoRR, eration. In Proceedings of the 2023 Conference on
abs/2303.08774. Empirical Methods in Natural Language Process-
ing, EMNLP 2023, Singapore, December 6-10, 2023,
Pyan. 2023. Pyan. [Link] pages 2471–2484. Association for Computational
davidfraser/pyan. Linguistics.
Baptiste Rozière, Jonas Gehring, Fabian Gloeckle, Sten
Sootla, Itai Gat, Xiaoqing Ellen Tan, Yossi Adi,
Jingyu Liu, Tal Remez, Jérémy Rapin, Artyom
Kozhevnikov, Ivan Evtimov, Joanna Bitton, Man-
ish Bhatt, Cristian Canton-Ferrer, Aaron Grattafiori,
Wenhan Xiong, Alexandre Défossez, Jade Copet,
Faisal Azhar, Hugo Touvron, Louis Martin, Nico-
las Usunier, Thomas Scialom, and Gabriel Synnaeve.
2023. Code llama: Open foundation models for code.
CoRR, abs/2308.12950.
Input Code:
```Python
{signature}
{requirement}
```
Completed Code:
Please complete the {function_name} function in the middle of a file.
Figure 7: The prompt template in the without context The contexts above the function are:
setting. ```Python
{contexts_above}
```
Please complete the {function_name} function based on the The contexts below the function are:
contexts above the function. ```Python
{contexts_below}
The contexts above the function are: ```
```Python
{contexts_above} The code to be completed is:
``` ```Python
{signature}
The code to be completed is: {requirement}
```Python ```
{signature} Completed code:
{requirement}
```
Completed code: Figure 9: The prompt template in the local file (infilling)
setting.
Figure 8: The prompt template in the local file (comple-
tion) setting.
EvoCodeBench employs metrics like Pass@k and Recall@k. Pass@k evaluates a model's ability to generate functionally correct code, while Recall@k assesses the ability to correctly invoke dependencies defined in the context of a repository. These metrics are robust because they provide a comprehensive measure of coding ability that includes both correctness and context-awareness, which are crucial for real-world applicability .
The pipeline for collecting EvoCodeBench data involves repository selection, function parsing, test construction, and deduplication. Repository selection ensures high-quality, recent repositories with more than 50 stars are included. Function parsing extracts relevant functions and dependencies. Test construction involves extracting and executing test cases to verify function executability. Deduplication removes redundant data. These steps ensure that the benchmark is representative, up-to-date, and free from biases, contributing to its reliability .
EvoCodeBench maintains its relevance by dynamically updating its dataset every six months. This is achieved through an automatic pipeline that continuously incorporates samples from newly-created repositories, ensuring that the benchmark remains aligned with the latest trends in software development and avoids overlap with data available to LLMs during training, thus providing a fresh and unbiased basis for evaluation .
EvoCodeBench provides comprehensive annotations, including natural language requirements, reference code, and detailed dependency paths. These annotations distinguish EvoCodeBench from other benchmarks which may only provide dependency names, leading to ambiguity. By offering complete paths for dependencies and context, EvoCodeBench allows accurate verification of generated code and facilitates a deeper evaluation of repository-level code generation .
Existing benchmarks for evaluating LLMs in code generation face challenges due to poor alignment with real-world code repositories. They often lack realistic code and dependency distributions, comprehensive annotations, robust evaluation metrics, and mechanisms to avoid data leakage. These shortcomings prevent accurate assessments of LLMs' coding abilities in real development contexts .
The performance of gpt-4 on EvoCodeBench, with a highest Pass@1 rate of 20.73%, suggests limited capabilities in generating functionally correct code within the specific contexts provided. This result implies that while gpt-4 may be effective in general code generation tasks, it struggles with the complexities and dependencies typical in real-world repositories, highlighting a need for further improvement in contextual understanding and integration skills .
EvoCodeBench aligns with real-world practices by including both standalone and non-standalone code samples, maintaining realistic ratios of these types. It ensures that the number of dependencies in its samples is consistent with those found in 500 real-world repositories, thus accurately reflecting the complexity and context-awareness required in practical coding .
The repository-level code generation task simulates the real-world coding process by requiring LLMs to generate code within the context of an existing repository. This task is significant because it tests the model's ability to understand and integrate with existing codebases, reflecting the actual challenges developers face. It moves beyond isolated function generation to assess how models handle dependencies and adapt code generation to fit within a pre-existing project structure .
EvoCodeBench addresses data leakage by being an evolving benchmark that updates periodically using an automatic pipeline. This pipeline collects data from the latest high-quality open-source repositories created after the training cutoff for the latest LLMs, thus ensuring that the benchmark does not contain data that the models might have been trained on .
Unlike benchmarks such as CoNaLA and HumanEval, which may not fully capture real-world code distributions, EvoCodeBench ensures alignment with real-world repositories by collecting samples that include both standalone and non-standalone codes. It also maintains consistent dependency distributions with real-world practices, addressing a gap that other benchmarks have not fully bridged .