Contextualized Code Pretraining for Code Generation

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Liu, Chen, Liang, Qingyuan, Zhang, Hanwen, Sun, Zeyu, Zhang, Yakun, Zhang, Lu
Natura: Preprint
Pubblicazione: 2026
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866913140293238784
author Liu, Chen
Liang, Qingyuan
Zhang, Hanwen
Sun, Zeyu
Zhang, Yakun
Zhang, Lu
author_facet Liu, Chen
Liang, Qingyuan
Zhang, Hanwen
Sun, Zeyu
Zhang, Yakun
Zhang, Lu
contents As code generation becomes increasingly central to improving software development efficiency, modern code models are largely trained and evaluated on code with natural-language descriptions. In real projects, developers often implement missing functions under limited project-specific artifacts, while the local call-site context is already available in the surrounding code. This usage context provides actionable cues about expected behavior, but existing models are not explicitly optimized to leverage it reliably, leading to implementations that may not integrate smoothly with surrounding usage in repository settings. In this work, we propose contextualized code pretraining, an invocation-aware framework that integrates calling context into both the training and evaluation of code models. Using static analysis, we automatically extract large-scale caller-callee pairs from real repositories to construct pretraining tasks and benchmarks that condition generation on the calling context. We train CallerGen, the first code models pretrained with invocation-aware objectives spanning multiple sizes, and evaluate them on CallerEval, a new benchmark featuring realistic scenarios. Experiments show that CallerGen outperforms comparable-scale models and remains competitive with larger ones across two benchmarks. Our 220M and 0.5B models achieve 16.58% and 22.81@% pass1, surpassing baselines on CallerEval. These results highlight the importance of calling context in realistic code generation.
format Preprint
id arxiv_https___arxiv_org_abs_2605_17957
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Contextualized Code Pretraining for Code Generation
Liu, Chen
Liang, Qingyuan
Zhang, Hanwen
Sun, Zeyu
Zhang, Yakun
Zhang, Lu
Software Engineering
As code generation becomes increasingly central to improving software development efficiency, modern code models are largely trained and evaluated on code with natural-language descriptions. In real projects, developers often implement missing functions under limited project-specific artifacts, while the local call-site context is already available in the surrounding code. This usage context provides actionable cues about expected behavior, but existing models are not explicitly optimized to leverage it reliably, leading to implementations that may not integrate smoothly with surrounding usage in repository settings. In this work, we propose contextualized code pretraining, an invocation-aware framework that integrates calling context into both the training and evaluation of code models. Using static analysis, we automatically extract large-scale caller-callee pairs from real repositories to construct pretraining tasks and benchmarks that condition generation on the calling context. We train CallerGen, the first code models pretrained with invocation-aware objectives spanning multiple sizes, and evaluate them on CallerEval, a new benchmark featuring realistic scenarios. Experiments show that CallerGen outperforms comparable-scale models and remains competitive with larger ones across two benchmarks. Our 220M and 0.5B models achieve 16.58% and 22.81@% pass1, surpassing baselines on CallerEval. These results highlight the importance of calling context in realistic code generation.
title Contextualized Code Pretraining for Code Generation
topic Software Engineering
url https://arxiv.org/abs/2605.17957