Templatized Query Prompt System for Natural Language to SQL Conversion

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Large language models (LLM) face challenges in converting natural language to structured queries due to performance, cost, and accuracy issues, particularly in understanding domain-specific queries and generating complex outputs, which can be resource-intensive and costly.

Innovation Solution

A method involving a machine learning model to extract placeholder names and values from natural language inputs, replace them with placeholder names in templatized query prompts, and generate query language queries, using a simplified LLM for improved efficiency and accuracy.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a large language model is used to convert natural language to query language, then the understanding of domain-specific queries is improved, but the processing time and computational resources increase significantly

Engineering Contradiction:
Improvequery generation accuracyVSAvoidprocessing time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent segments the query generation process into two distinct parts: (1) a template matching component that handles the conversion of natural language to query language using pre-defined templates, and (2) a large language model component that is only invoked when template matching fails or for complex queries. This segmentation allows the system to achieve high accuracy for common queries using the efficient template approach while maintaining the ability to handle complex cases with the LLM.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs preliminary action by pre-defining query templates with placeholders for common query patterns before runtime. During query generation, the system first attempts to match the natural language input against these pre-defined templates, which are prepared in advance. This preliminary template matching approach enables fast processing for standard queries without requiring the computationally expensive LLM to be invoked for every query.

Inventive Principle:
Principle #10Preliminary action

2Manufacturing precision

If a large language model is used to generate and summarize query results, then the accuracy and quality of output is improved, but the token requirements and costs increase

Engineering Contradiction:
Improvequery output qualityVSAvoidtoken requirements
Core Design Contradiction:
Manufacturing precisionVSQuantity of substance

Solution Approach 1:

The patent applies partial action by using the large language model only partially - specifically, only for generating response summaries when needed, rather than for the entire query generation and processing pipeline. For the query generation itself, the system uses efficient template matching that requires minimal tokens. The LLM is selectively applied only to the summarization step for complex or user-requested queries, reducing overall token consumption while maintaining output quality where it matters most.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The patent introduces an intermediary component - the template-based query generation system - that acts as a mediator between the natural language input and the large language model. This intermediary handles the bulk of query generation tasks using pre-defined templates, thereby reducing the amount of work that needs to be done by the LLM and consequently reducing token requirements. The LLM serves as a secondary intermediary only when template matching is insufficient.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Reliability

If retrieval augmented generation is used to improve query accuracy, then the understanding of domain context is improved, but the data engineering overhead and complexity increase

Engineering Contradiction:
Improvequery accuracyVSAvoidsystem complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent uses copying by creating pre-defined query templates that capture common query patterns and domain knowledge. Instead of using RAG to retrieve and process domain information for each query, the system copies proven query patterns into templates that can be directly applied to new queries. This template copying approach encapsulates domain expertise in a reusable format, achieving high query accuracy without the infrastructure complexity of RAG systems.

Inventive Principle:
Principle #26Copying

Data Source

PatentUS20250335433A1Techniques for generating query language queries using templatized query prompts
Publication Date: 2025.10.30 MICROSOFT TECHNOLOGY LICENSING LLC
  • US20250335433A1 patent drawing
  • US20250335433A1 patent drawing
  • US20250335433A1 patent drawing

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.