Code Completion Using Machine Learning Ranking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing code completion systems face challenges in efficiently recommending method invocation parameters due to large numbers of irrelevant or lengthy candidate lists, which can hinder developer productivity and increase errors.

Innovation Solution

A machine learning-based approach that uses a weighted sum of scope, edit distance, and declaration proximity scores to rank candidate variables for method invocations, trained on a scope model and method overload model, to provide more accurate and relevant recommendations.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Quantity of substance

If a large list of type-compatible candidates is provided for method parameter completion, then the completeness of candidate coverage is improved, but the time required for developers to browse and select the correct element increases

Engineering Contradiction:
Improvenumber of candidate variablesVSAvoidtime to browse candidates
Core Design Contradiction:
Quantity of substanceVSLoss of time

Solution Approach 1:

The patent replaces the mechanical browsing process with an intelligent recommendation system using machine learning. The system automatically ranks candidate variables based on multiple scoring factors (scope score, edit distance score, declaration proximity score) and presents only the most relevant candidates, eliminating the need for developers to manually browse through lengthy lists while maintaining comprehensive candidate coverage.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Solution Approach 2:

The patent changes the parameter of candidate presentation from displaying all type-compatible candidates to displaying ranked candidates based on computed scores. By introducing scoring parameters (scope, edit distance, declaration proximity) and weighting them appropriately, the system transforms the candidate list from an exhaustive unranked collection to a prioritized recommendation list, reducing browsing time while maintaining completeness.

Inventive Principle:
Principle #35Parameter changes

2Device complexity

If traditional code completion methods are used, then the implementation is simple, but the accuracy of recommendations is low due to irrelevant candidates

Engineering Contradiction:
Improvesystem complexityVSAvoidrecommendation accuracy
Core Design Contradiction:
Device complexityVSMeasurement precision

Solution Approach 1:

The patent performs preliminary actions by pre-training machine learning models on scope models and method overload models before actual code completion. These pre-trained models capture patterns and relationships in the codebase, enabling accurate recommendations without requiring complex real-time analysis. The scope model and method overload model are prepared in advance to quickly evaluate candidate variables during completion.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces machine learning models as intermediaries between the code context and candidate variable selection. Instead of directly matching candidates based on simple type compatibility, the system uses trained models to compute scope scores, edit distance scores, and declaration proximity scores, which serve as intermediate evaluations to determine the most relevant candidates, thereby improving recommendation accuracy.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Adaptability or versatility

If multiple features are added to detect coding patterns, then the detection capability is improved, but the system complexity increases necessitating modifications to recommendation logic

Engineering Contradiction:
Improvepattern detection capabilityVSAvoidsystem complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent creates a universal machine learning framework that can handle multiple coding patterns and features through a single cohesive system. Instead of implementing separate detection mechanisms for different patterns, the system uses trained models that generalize across various coding contexts. The scope model, method overload model, and scoring mechanism work together as a multi-functional system that adapts to different patterns without requiring separate recommendation logic for each feature.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentEP3891599B1Code completion of method parameters with machine learning
Publication Date: 2024.05.29 MICROSOFT TECHNOLOGY LICENSING LLC
  • EP3891599B1 patent drawingFigure 1
  • EP3891599B1 patent drawingFigure 2A
  • EP3891599B1 patent drawingFigure 2B

AI summary

A code completion tool uses machine learning models to more precisely predict the likelihood of the parameters of a method invocation. A score is computed for each candidate variable that is used to rank the viability of a variable as the intended parameter. The score is a weighted sum of a scope factor, an edit distance factor and a declaration proximity factor. The factors are based on a scope model, a method overload model, and a weight file trained offline on a training set of source code programs utilizing various method invocations.