Repository-Level Prompt Augmentation for Private Code Completion
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Large language models trained on publicly-available code repositories struggle with code completion tasks involving private repositories due to the absence of context from methods, classes, and namespaces not seen in the training dataset.
Innovation Solution
Augmenting the prompt for the large language model with repository-level context, including few-shot examples and focal context from private repositories, which includes method signatures and namespace information, to guide the model in generating accurate code completion candidates without retraining.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If a large language model is trained on publicly-available code repositories, then the model can perform code completion tasks, but the model performs poorly with source code from private repositories containing unseen methods, classes, and types
Solution Approach 1:
The patent extracts and stores method signatures, namespace information, and code context from private repositories in advance, creating a repository-level context database before code completion is needed. This preliminary action enables the model to access relevant private repository information during code completion without requiring retraining
Solution Approach 2:
The patent introduces a repository-level context as an intermediary between the large language model and private repository code. This context includes method signatures, namespace information, and code fragments that bridge the gap between the model's training data and the private repository's unique code structures
2Reliability
If the large language model is fine-tuned on private repository data, then the model can accurately complete code from private repositories, but the process is costly and resource-intensive
Solution Approach 1:
The patent extracts only the essential repository-level context (method signatures, namespace information, and relevant code fragments) from private repositories, separating this critical information from the complete codebase. This extraction approach provides the model with necessary context without requiring full model retraining on entire repositories
Solution Approach 2:
Instead of fully retraining the model on private repository data, the patent applies partial action by augmenting the prompt with selected repository-level context. This provides just enough additional information to improve accuracy for private repository code without the excessive computational cost of complete fine-tuning
Data Source
AI summary
A code completion system utilizes a large language model to complete a partially-formed source code snippet of a source code program given a prompt that includes a repository-level context, an extended context and a local context. The repository-level extended context includes a few-shot examples and a focal context. The few-shot examples are code fragments from the repository having a close similarity to the partially-formed source code snippet. The focal context includes method signatures and namespace information of methods of custom classes defined in the repository. The augmentation of the prompt with the various context data enables the model to predict more relevant code completion candidates for custom data without training the model on the custom data.


