Code Block Search Using Package And Functionality Embeddings
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing semantic and neural code search techniques struggle with identifying relevant code blocks within the correct software package, often misidentifying due to domain mismatches, requiring precise queries, and facing scalability issues with large code block databases.
Innovation Solution
Code blocks are clustered by functionality using embeddings, generating package, functionality, and code block embeddings, which are then used to accurately identify relevant code blocks within the correct software package.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If existing semantic and neural code search techniques are used, then code blocks can be identified, but accuracy deteriorates due to domain mismatches and package context loss
Solution Approach 1:
The patent implements a hierarchical embedding structure where code block embeddings are nested within functionality cluster embeddings, which are in turn nested within software package embeddings. This nested structure preserves multiple levels of context (package-level, functionality-level, and code block-level) simultaneously, allowing the search system to maintain accurate package context information while identifying relevant code blocks.
Solution Approach 2:
The patent introduces a new dimensional structure by organizing code blocks into functionality clusters as an intermediate layer between individual code blocks and software packages. This adds a functionality dimension to the search space, enabling queries to match code blocks not only by syntax but also by functional semantics, thereby improving identification accuracy without losing package context.
2Quantity of substance
If comprehensive code block databases are searched, then more code blocks can be found, but productivity deteriorates due to scalability issues
Solution Approach 1:
The patent segments the large code block database into smaller functionality clusters grouped by software package. Instead of searching through all code blocks directly, the system first identifies relevant software packages using package embeddings, then searches only within those packages using functionality cluster embeddings. This segmentation dramatically reduces the search space while maintaining comprehensive coverage of relevant code blocks.
Solution Approach 2:
The patent performs preliminary organization of code blocks into functionality clusters and software package groupings before the actual search process. By pre-computing and storing hierarchical embeddings at the package and functionality levels, the system prepares the data structure in advance, enabling efficient filtering and reducing the computational burden during query execution.
3Measurement precision
If precise queries are required for accurate results, then identification accuracy improves, but ease of operation deteriorates
Solution Approach 1:
The patent creates a universal search system that handles multiple types of queries (functional requirements, domain-specific searches, package-level searches) through a single unified embedding-based interface. The hierarchical embedding structure allows the same search mechanism to work effectively whether the query is broad or specific, eliminating the need for users to learn different query formulations for different search scenarios.
Solution Approach 2:
The patent transforms the query formulation parameters from requiring precise syntactic matching to utilizing semantic embeddings. By changing the search parameter from exact code pattern matching to vector-space similarity based on hierarchical embeddings, the system accepts natural language and diverse query formats while maintaining high identification accuracy through the semantic richness of the embedding representations.
Data Source
AI summary
A database stores, for each of a number of software packages, a software package embedding representing the software package. The database stores, for each software package, code block embeddings respectively representing code blocks of the software package. The database stores, for each software package, functionality embeddings respectively representing functionality clusters into which the code block embeddings representing the code blocks of the software package have been clustered. A query embedding representing a query is generated, and used to query the database to identify a relevant code block within a relevant software package for the query.


