LLM Prompt Construction for Accurate API Action Selection

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing natural language processing systems face inefficiencies in accurately determining actions responsive to user inputs due to the need to process irrelevant information, leading to degraded accuracy and longer prompts, especially when using large language models.

Innovation Solution

A system is developed to generate a prompt for a language model that includes only relevant information such as API definitions, exemplars, device states, and contextual data, enabling one-shot/few-shot learning and improving accuracy by reducing irrelevant considerations.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If more information is included in the prompt to improve action determination accuracy, then accuracy is improved, but prompt length and processing time increase

Engineering Contradiction:
Improveaction determination accuracyVSAvoidprompt processing time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent extracts and filters only the most relevant information from the complete context to include in the prompt. By identifying and extracting only necessary elements (such as relevant API definitions, exemplars, device states, and contextual data) while excluding irrelevant information, the system achieves accurate action determination with reduced prompt length and processing time.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent segments the information processing into distinct components: identifying relevant information, extracting key elements, and constructing the prompt. This segmentation allows the system to handle complex information systematically, separating essential data from redundant content to optimize both accuracy and processing efficiency.

Inventive Principle:
Principle #1Segmentation

2Measurement precision

If more information is processed to improve action determination accuracy, then accuracy is improved, but computational overhead increases

Engineering Contradiction:
Improveaction determination accuracyVSAvoidcomputational overhead
Core Design Contradiction:
Measurement precisionVSUse of energy by moving object

Solution Approach 1:

The patent applies extraction by identifying and selecting only the most computationally efficient relevant information needed for action determination. By extracting only necessary data elements (API definitions, exemplars, device states, contextual data) and excluding irrelevant information, the system reduces computational overhead while maintaining high accuracy in action determination.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent uses partial action by processing only the essential portion of information required for accurate action determination, rather than processing all available data. This selective processing approach achieves sufficient accuracy without the excessive computational cost of analyzing every piece of information.

Inventive Principle:
Principle #16Partial or excessive action

3Adaptability or versatility

If all available information is processed to ensure comprehensive action determination, then completeness is improved, but system complexity increases

Engineering Contradiction:
Improveinformation completenessVSAvoidsystem complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent extracts only the necessary information elements from the complete data available. By identifying and extracting specific relevant components (API definitions, exemplars, device states, contextual data) while filtering out irrelevant information, the system maintains comprehensive action determination capability without increasing system complexity.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent applies local quality by treating different information elements differently based on their relevance. Instead of uniformly processing all information, the system selectively processes and weights information based on its local importance to the specific action determination task, reducing overall system complexity while maintaining completeness where needed.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS20260038504A1Natural language generation
Publication Date: 2026.02.05 AMAZON TECH INC
  • US20260038504A1 patent drawing
  • US20260038504A1 patent drawing
  • US20260038504A1 patent drawing

AI summary

Techniques for generating a prompt for a language model to determine an action responsive to a user input, are described. In some embodiments, the system receives a user input, determines one or more application programming interfaces (APIs) configured to perform actions that are relevant to the user input and exemplars representing examples of using the APIs with respect to user inputs similar to the current user input. The system further determines device states of devices that are determined to be related to the user input and also determines other contextual information (e.g., weather information, time of day, geographic location, etc.). The system generates a prompt including the user input, the APIs, the exemplars, the device states, and the other contextual information. A language model processes the prompt to determine an action responsive to the user input and the system causes performance of the action.