Templatized Query Prompts for Faster Natural-Language Query Generation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Large language models (LLM) face performance, cost, and accuracy issues in converting natural language to structured queries, requiring significant processing time and resources, especially when generating queries for large subject entities, and often produce complex outputs that are inefficient.

Innovation Solution

A method using templatized query prompts and machine learning models to extract placeholder names and values from natural language inputs, matching them to templatized query prompts, and generating query language queries by replacing placeholders with values, reducing the complexity and resource requirements.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Manufacturing precision

If LLM is used to convert natural language to structured query, then query generation capability is improved, but processing time increases

Engineering Contradiction:
Improvequery generation accuracyVSAvoidprocessing time
Core Design Contradiction:
Manufacturing precisionVSLoss of time

Solution Approach 1:

The patent segments the query generation process into two distinct parts: (1) a template matching stage that handles structured query templates efficiently, and (2) an LLM-based stage that only processes unstructured or complex queries. This segmentation allows most routine queries to be handled by the fast template matching mechanism while reserving LLM resources for more challenging cases, thereby reducing overall processing time while maintaining query generation accuracy.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent implements preliminary action by pre-defining query templates with placeholders for common query structures. Before invoking the LLM, the system performs template matching to see if the natural language query fits any predefined patterns. This preliminary step allows the system to quickly resolve many queries without involving the computationally expensive LLM, thus reducing processing time while preserving accuracy for templatable queries.

Inventive Principle:
Principle #10Preliminary action

2Manufacturing precision

If LLM is used to convert natural language to structured query, then query understanding capability is improved, but cost increases

Engineering Contradiction:
Improvequery understanding accuracyVSAvoidcomputational cost
Core Design Contradiction:
Manufacturing precisionVSLoss of energy

Solution Approach 1:

The patent divides the query processing workload between a low-cost template matching component and a high-cost LLM component. By segmenting queries into templatable and non-templatable categories, the system ensures that only necessary queries incur LLM costs, thereby reducing overall computational expenditure while maintaining understanding accuracy for the subset of queries that require LLM processing.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent uses template copying as a cheaper alternative to LLM processing for routine queries. Instead of invoking the expensive LLM for every query, the system copies and fills predefined query templates that have been previously validated for accuracy. This copying approach dramatically reduces computational cost while maintaining query understanding accuracy for standard query patterns.

Inventive Principle:
Principle #26Copying

3Adaptability or versatility

If LLM is used to generate query for large subject entity, then query coverage is improved, but token requirement increases

Engineering Contradiction:
Improvequery coverageVSAvoidtoken requirement
Core Design Contradiction:
Adaptability or versatilityVSQuantity of substance

Solution Approach 1:

The patent segments the query generation task by identifying and extracting entities that match predefined templates. For queries involving large subject entities, the system segments the processing into: (1) entity recognition and classification, (2) template selection based on entity type, and (3) template filling. This segmentation allows the system to handle complex queries with multiple entities efficiently by reusing templates rather than generating entire queries from scratch with the LLM, thereby reducing token requirements while maintaining comprehensive query coverage.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent implements universality through reusable query templates that can handle multiple entity types and query patterns. A single template can serve multiple purposes by accepting different entity names and attributes as parameters. This multi-functionality allows the system to cover a wide range of queries involving large subject entities without requiring separate LLM processing for each specific query structure, thus reducing token consumption while maintaining adaptability.

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

4Manufacturing precision

If LLM is used to summarize and format data output, then data presentation quality is improved, but additional processing time is required

Engineering Contradiction:
Improvedata presentation qualityVSAvoidsummarization time
Core Design Contradiction:
Manufacturing precisionVSLoss of time

Solution Approach 1:

The patent segments the data processing pipeline into distinct stages: query execution, raw data retrieval, and formatted presentation. By separating these functions, the system can apply appropriate processing methods at each stage. The template matching component handles structured data retrieval efficiently, while summary and formatting operations are applied only to the retrieved results, not to the entire query processing flow. This segmentation reduces overall processing time while maintaining data presentation quality.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent applies preliminary action by pre-defining output templates and formatting structures for common query results. Instead of using LLM to generate formatting from scratch for each query, the system has pre-prepared templates that specify the desired output structure. This preliminary preparation allows for rapid formatting of query results without requiring expensive LLM processing at runtime, thus reducing summarization time while preserving data presentation quality.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentEP4641399A1Techniques for generating query language queries using templatized query prompts
Publication Date: 2025.10.29 MICROSOFT TECHNOLOGY LICENSING LLC
  • EP4641399A1 patent drawingFigure 1
  • EP4641399A1 patent drawingFigure 2
  • EP4641399A1 patent drawingFigure 3

AI summary

Described are examples for converting a natural language input into a query language query. One or more placeholder names and one or more corresponding placeholder values can be extracted from the natural language input. The one or more corresponding placeholder values in the natural language input can be replaced with the one or more placeholder names. The natural language input having the one or more placeholder names can be matched to a templatized query prompt that includes the one or more placeholder names. The query language query can be generated at least in part by replacing the one or more placeholder names in the templatized query prompt with the one or more corresponding placeholder values.