Code Radar Using Attention Matrices for Source Navigation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional large language models discard attention matrices after generating source code completions, missing an opportunity to provide valuable context for source code navigation within integrated development environments (IDEs).

Innovation Solution

Utilizing attention matrices to generate mappings of token relevance, which are then used to provide a 'code radar' user interface experience, highlighting relevant source code locations to the user, including documentation, variable declarations, and assignments, by leveraging self-attention architectures and postprocessing techniques like attention mean, max, rollout, and follow-up attention.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of energy

If attention matrices are discarded after generating source code completions, then computational resources are freed, but valuable context information for source code navigation is lost

Engineering Contradiction:
Improvecomputational resourcesVSAvoidcontext information
Core Design Contradiction:
Loss of energyVSLoss of information

Solution Approach 1:

The system recovers and reuses attention matrices that would otherwise be discarded after code completion generation. By storing these matrices and applying postprocessing techniques (attention mean, max, rollout, follow-up attention), the system extracts meaningful token relationships to power the code radar navigation feature, thus recovering valuable information from previously discarded computational artifacts.

Inventive Principle:
Principle #34Discarding and recovering

2Ease of operation

If attention matrices are processed to generate token relevance mappings, then source code navigation context is improved, but computational overhead increases

Engineering Contradiction:
Improvesource code navigationVSAvoidcomputational overhead
Core Design Contradiction:
Ease of operationVSDevice complexity

Solution Approach 1:

Instead of processing all attention matrix data equally, the system applies selective postprocessing techniques to extract the most relevant token relationships. The code radar feature processes only the necessary portion of attention information to provide effective navigation context, avoiding unnecessary computational overhead while maintaining navigation quality.

Inventive Principle:
Principle #16Partial or excessive action

3Measurement precision

If multiple postprocessing techniques are applied to attention matrices, then mapping accuracy is improved, but processing time increases

Engineering Contradiction:
Improvemapping accuracyVSAvoidprocessing time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The system precomputes and stores multiple types of attention mappings (mean, max, rollout, follow-up attention) during the code completion generation phase. These preprocessed mappings are then readily available for rapid retrieval during code navigation, eliminating the need for real-time computation and reducing processing delays when the code radar feature is activated.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS20240127112A1Code radar
Publication Date: 2024.04.18 MICROSOFT TECHNOLOGY LICENSING LLC
  • US20240127112A1 patent drawing
  • US20240127112A1 patent drawing
  • US20240127112A1 patent drawing

AI summary

Using a language model attention matrix to facilitate a “code radar” source code navigation experience that highlights related source code locations. A computer system identifies a first source code location within source code that is displayed at a code editor user interface (UI). From a set of mappings generated based on a language model attention matrix, the computer system identifies a second source code location as being related to the first source code location. Concurrent with presenting the first source code location in the code editor UI, the computer system presents a related source code navigation experience, which includes both (i) presenting the second source code location in the code editor UI, and (ii) presenting a visual indication that the second source code location is related to the first source code location. Some embodiments include generating the set of mappings based on a language model attention matrix.