Retrieval-Augmented Code Completion via Hybrid Vector Indexing
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Large machine learning models for code completion require significant computing resources, making them impractical for deployment in systems with limited resources despite achieving high accuracy through large-scale training.
Innovation Solution
A retrieval-augmented code completion system uses a hybrid retrieval technique to find semantically similar source code segments from a database, combining embedding and sparse vector indices to predict the next tokens in a source code snippet, reducing the need for extensive training data and model size.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If large-scale machine learning models are trained on large datasets to achieve high code completion accuracy, then prediction accuracy is improved, but model size and computing resource requirements increase
Solution Approach 1:
The patent segments the code completion task into two parts: (1) a retrieval component that fetches relevant code snippets from a database using embedding vectors, and (2) a smaller decoder model that generates completions based on retrieved snippets. This segmentation allows the system to achieve high accuracy without requiring a single large model to handle all aspects of the task
Solution Approach 2:
The patent introduces a retrieval database as an intermediary between the input code snippet and the completion generator. The database stores pre-processed code embeddings that serve as intermediate representations, allowing the decoder model to focus on generation rather than both retrieval and generation, thereby reducing model size while maintaining accuracy
2Measurement precision
If large machine learning models with billions of parameters are deployed for accurate code completion, then prediction quality is improved, but computing resources required for deployment increase
Solution Approach 1:
The system segments the computational workload between offline retrieval database construction and online code completion. The computationally intensive embedding training is performed offline, while the online decoder model remains small and resource-efficient, reducing deployment computing requirements while maintaining prediction quality
Solution Approach 2:
The patent performs preliminary processing by pre-training embedding models and constructing the retrieval database offline before deployment. This preliminary action transfers computational burden from the deployment phase to the preparation phase, allowing the deployed system to use smaller, more resource-efficient models
3Reliability
If extensive training data is used to train large models for code completion, then model performance is improved, but training time and computational cost increase
Solution Approach 1:
The training process is segmented into two stages: (1) training embedding models on large code corpora to create the retrieval database, and (2) training a smaller decoder model on retrieved examples. This segmentation allows the system to leverage extensive training data for the embedding stage while keeping the decoder training faster and more efficient
Data Source
AI summary
A retrieval-augmented code completion system uses the context of a partially-formed source code snippet of a source code program and a hint to predict the source code tokens needed to complete the partially-formed source code snippet. The hint is a source code segment that completes a semantically-similar source code segment of the partially-formed source code snippet. The hint is found in a retrieval source code database using a hybrid retrieval technique. A deep learning decoder model uses the context of the partially-formed source code snippet and the hint to predict the most likely candidate sequence of source code tokens to complete the partially-formed source code snippet.


