Abstract
Standard Large Language Models (LLMs) for code generation often fail to capture the unique architectural patterns and naming conventions of specific software projects. This paper investigates the personalization of pre-trained models to individual repositories. By comparing full fine-tuning against parameter-efficient methods such as Prefix Tuning and Last Decoder Block (L-LDB) tuning, we demonstrate that project-specific adaptation can more than double performance metrics and significantly improve the stylistic alignment of generated code with existing developer practices.
Introduction
Large Language Models for code are typically trained on massive, heterogeneous datasets like GitHub. While these models excel at general programming tasks, they often struggle when deployed within specific enterprise environments or niche private repositories. Every codebase possesses its own "idiosyncrasies"—unique APIs, internal libraries, specific naming conventions, and distinct architectural patterns.
Standard models typically operate within a limited context window (e.g., 1024 tokens), preventing them from accessing the broader project context necessary to generate truly idiomatic code. This research addresses a critical question: How can we efficiently adapt a pre-trained model to a specific project's "personality" without the prohibitive costs of full-scale retraining and storage?
Methodology
The study evaluates four distinct strategies for personalizing a BART Transformer model (406M parameters) specifically for generating Java unit tests:
- Full Fine-tuning: The baseline "gold standard" where all 406M parameters are updated. While high-performing, it requires storing a complete model instance for every project.
- L-EO (Lightweight - Embeddings and Output): Only the token embeddings and the final softmax layer are tuned, representing approximately 13% of the total parameters.
- L-LDB (Lightweight - Last Decoder Block): Only the parameters in the final decoder block are updated (4.2% of parameters). This method targets the layers that undergo the most significant changes during adaptation.
- Prefix Tuning: The base model remains frozen. A small set of project-specific "virtual tokens" (a prefix) is prepended to the input and optimized, involving only 2.4% of the parameters.
Data and Project Diversity
The researchers utilized Methods2Test, a large-scale dataset of Java focal methods and their corresponding unit tests. For the personalization experiments, the authors sampled 20 diverse GitHub repositories, ranging from small tutorials to large-scale projects from Apache and Google.
A preliminary diversity study of 930 Java projects revealed that the median project shares only 13% of its unique identifiers with any other project. This lack of overlap underscores the necessity of personalization; general models simply cannot predict project-specific identifiers without prior exposure to the specific repository.
Key Insights
The "Deep Change" Phenomenon
By analyzing parameter shifts during full fine-tuning, the authors observed that the magnitude of weight changes increases as one moves deeper into the model. The last decoder block undergoes the most significant transformation. This observation explains why the L-LDB method is remarkably effective despite tuning only a fraction of the model.
Stylistic Alignment
Personalization is not merely about logical correctness; it is about "vocabulary similarity." Personalized models demonstrated a much higher cosine similarity to the developer's original code regarding identifier usage (variable and function names), suggesting that the models successfully learned the project's specific dialect.
The Prefix Tuning Paradox
While Prefix Tuning is the most storage-efficient method, it proved to be the most computationally expensive to train. Because the prefix begins with poor initialization, it requires significantly more compute cycles to reach the same loss level as methods that start with pre-trained weights.
Results
- Performance Gains: Across all 20 projects, personalization led to a dramatic jump in BLEU4 scores, rising from a baseline of 16.1 to approximately 37–38.
- Perfect Matches: The baseline model achieved a "perfect match" (code identical to the developer's original test) in less than 1% of cases. In contrast, personalized models achieved perfect matches in 4–6% of cases for their top prediction.
- Structural Accuracy: When evaluating "Abstracted Code Matches" (which ignore specific variable names to focus on code structure), personalized models improved from a 3% success rate to 13–14%.
- Efficiency Winner: L-LDB emerged as the most practical solution, providing performance nearly identical to full fine-tuning while requiring only 4.2% of the storage capacity.
Limitations and Future Work
The study currently focuses on Java and unit test generation; further research is required to determine if these results generalize to other languages like Python or more complex system-level tasks. Additionally, while parameter-efficient methods reduce storage, serving thousands of personalized model variants in a production environment remains an engineering challenge regarding memory swapping and inference latency. Future work may explore "on-device" personalization through model pruning or quantization to allow for client-side training.
Summary updated