AST-Based Code Chunk Summarization for Accurate Source Code Retrieval

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing source code retrieval and generation techniques face challenges due to inadequate documentation, complex syntactic rules, and the lack of generalized training datasets, leading to inefficient and resource-intensive code adaptation.

Innovation Solution

The method involves generating an abstract syntax tree from source code, aggregating nodes into code chunks, and using a large language model (LLM) with prompts to summarize features, improving the extraction and summarization of code features.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of manufacture

If keyword-based approaches are used for source code retrieval, then the retrieval process is simple to implement, but the retrieval accuracy is low due to complex syntactic rules and inadequate documentation

Engineering Contradiction:
Improveimplementation simplicityVSAvoidretrieval accuracy
Core Design Contradiction:
Ease of manufactureVSMeasurement precision

Solution Approach 1:

The patent introduces an abstract syntax tree (AST) as an intermediary structure between the source code and the retrieval system. The AST captures the syntactic and semantic structure of the code, serving as a mediator that transforms complex code into a structured representation that can be effectively queried and matched, thereby improving retrieval accuracy without sacrificing implementation simplicity

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent transforms the retrieval approach by changing the parameters from simple keyword matching to structured AST-based matching. This parameter change enables the system to consider syntactic relationships, code hierarchy, and semantic meaning, significantly improving retrieval accuracy while maintaining computational efficiency

Inventive Principle:
Principle #35Parameter changes

2Measurement precision

If domain-specific models are trained on code comments and documentation, then the model can understand code semantics, but the model does not generalize well to different codebases and programming languages

Engineering Contradiction:
Improvecode semantics understandingVSAvoidgeneralization capability
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The patent employs ASTs as a universal representation that can capture the structure of different programming languages and codebases. The AST approach provides a language-agnostic framework that maintains semantic understanding capabilities while enabling broad generalization across diverse code repositories, making the retrieval system universally applicable

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

Solution Approach 2:

The patent segments the code into hierarchical structures within the AST, breaking down complex code into manageable nodes representing different linguistic constructs. This segmentation enables the system to understand code semantics at multiple levels while maintaining adaptability to different languages through the standardized AST representation

Inventive Principle:
Principle #1Segmentation

3Reliability

If LLMs are used for code generation, then the generated code can be syntactically and semantically correct in various languages, but the generation process requires large training datasets that are not widely available

Engineering Contradiction:
Improvecode correctnessVSAvoidtraining data requirements
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The patent performs preliminary action by generating AST representations and code summaries before the actual code generation task. This pre-processing creates structured training data that captures syntactic and semantic information, enabling LLMs to learn from organized representations rather than requiring vast amounts of raw code examples

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent uses ASTs and code summaries as intermediary representations that bridge the gap between raw code and LLM training data. These intermediaries distill essential structural and semantic information into compact forms, reducing the quantity of training data needed while maintaining code generation reliability

Inventive Principle:
Principle #24Intermediary (Mediator)

4Ease of operation

If conventional RAG-based models are used for code retrieval, then the models can process source code, but the models struggle with large documents due to limited context windows and produce inconsistent results

Engineering Contradiction:
Improvecode processing capabilityVSAvoidresult consistency
Core Design Contradiction:
Ease of operationVSMeasurement precision

Solution Approach 1:

The patent segments large code documents into smaller, manageable chunks represented as AST subtrees. This segmentation allows the retrieval system to process code within context window limits while maintaining structural relationships, thereby improving result consistency without sacrificing code processing capability

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent employs a nested structure where AST nodes are hierarchically organized, with smaller code units nested within larger structures. This nesting enables the system to maintain context across different levels of code organization, improving consistency in retrieval results while working within context window constraints

Inventive Principle:
Principle #7Nested doll (Nesting)

Data Source

PatentUS20260072654A1Techniques for extracting source code features to support source code retrieval and generation
Publication Date: 2026.03.12 NUTANIX INC
  • US20260072654A1 patent drawing
  • US20260072654A1 patent drawing
  • US20260072654A1 patent drawing

AI summary

Techniques for extracting source code features to support source code retrieval and generation include receiving source code; generating an abstract syntax tree (AST) based upon the source code; aggregating a plurality of nodes of the AST into a code chunk; presenting the code chunk to a large language model (LLM) with at least one prompt based on a type of feature of a language in which the source code is represented; and receiving a summary of the code chunk from the LLM based upon the at least one prompt, wherein the summary summarizes one or more features of the code chunk.