AST Path Prediction for Syntax-Aware Code Language Models

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing natural language processing (NLP) models, such as BERT, struggle to accurately encode and analyze the structural and semantic information of programming languages due to the loss of important tree topology details during flattening, leading to suboptimal inference accuracy.

Innovation Solution

A novel encoded tree generator is used to finetune a pretrained logic encoder, incorporating structural and semantic information from abstract syntax trees (ASTs) into language models like BERT through a self-supervised training objective called AST path prediction, where AST information flows in a backward path using neural backpropagation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of information

If state of the art feature encoding is used to encode logical tree, then encoding can be performed, but important tree topology details are lost and inference accuracy is poor

Engineering Contradiction:
Improvetree topology detailsVSAvoidinference accuracy
Core Design Contradiction:
Loss of informationVSMeasurement precision

Solution Approach 1:

The patent segments the logical tree into fixed-size encoded tree representations, dividing the complex tree structure into manageable fixed-size segments that preserve topological information while enabling efficient processing by machine learning models

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent changes the encoding parameters by using fixed-size encoded tree representations with specific dimensional constraints, transforming the variable-size tree structure into a fixed-dimensional format that retains essential topological details while being suitable for model input

Inventive Principle:
Principle #35Parameter changes

2Quantity of substance

If dense encoding is used to encode logical tree, then space efficiency is improved, but important information may be lost

Engineering Contradiction:
Improveencoding space efficiencyVSAvoidimportant tree information
Core Design Contradiction:
Quantity of substanceVSLoss of information

Solution Approach 1:

The patent applies local quality by preserving critical topological information in specific regions of the encoded representation while using fixed-size constraints elsewhere, ensuring that important structural details are maintained without requiring excessive space

Inventive Principle:
Principle #3Local quality

3Adaptability or versatility

If large language models are used for source codes, then model capacity is increased, but computational cost and data requirements increase significantly

Engineering Contradiction:
Improvemodel capacityVSAvoidcomputational cost
Core Design Contradiction:
Adaptability or versatilityVSUse of energy by moving object

Solution Approach 1:

The patent performs preliminary action by pre-processing source code into fixed-size encoded tree representations before feeding them to the language model, preparing the data in advance in a format that maximizes model effectiveness while minimizing computational requirements during training and inference

Inventive Principle:
Principle #10Preliminary action

4Speed

If BERT forgoes parsing to accept lexical tokens, then processing speed is improved, but accuracy decreases

Engineering Contradiction:
Improveprocessing speedVSAvoidinference accuracy
Core Design Contradiction:
SpeedVSMeasurement precision

Solution Approach 1:

The patent performs parsing and tree encoding as a preliminary action before BERT processing, so that the structural information is prepared in advance in fixed-size encoded format, allowing BERT to process the encoded representation efficiently without performing parsing itself, thus maintaining both speed and accuracy

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS12498910B2Training syntax-aware language models with AST path prediction
Publication Date: 2025.12.16 ORACLE INT CORP
  • US12498910B2 patent drawing
  • US12498910B2 patent drawing
  • US12498910B2 patent drawing

AI summary

In an embodiment, a computer stores and operates a logic encoder that is an artificial neural network that infers a fixed-size encoded logic from textual or tokenized source logic. Without machine learning, a special parser generates a parse tree that represents the source logic and a fixed-size correctly encoded tree that represents the parse tree. For finetuning the logic encoder, an encoded tree generator is an artificial neural network that accepts the fixed-size encoded logic as input and responsively infers a fixed-size incorrectly encoded tree that represents the parse tree. The neural weights of the logic encoder (and optionally of the encoded tree generator) are adjusted based on backpropagation of error (i.e. loss) as a numerically measured difference between the fixed-size incorrectly encoded tree and the fixed-size correctly encoded tree.