Knowledge Graph Prompt Generation for Language Model Reasoning

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current large language models face challenges in generating high-quality prompts efficiently, particularly in terms of correctness of facts, credibility, and controllability of generated content.

Innovation Solution

A method and apparatus for generating prompts based on a knowledge graph, which involves obtaining a reasoning rule and a matched instance subgraph, constructing a question and answer template, and generating a target text to serve as a prompt for adjusting a language model.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Manufacturing precision

If traditional prompt generation methods are used, then the process is simple, but the quality and logical strength of generated prompts are insufficient

Engineering Contradiction:
Improveprompt qualityVSAvoidgeneration process complexity
Core Design Contradiction:
Manufacturing precisionVSDevice complexity

Solution Approach 1:

The patent introduces a knowledge graph as an intermediary component between the prompt generation process and the language model. The knowledge graph stores structured reasoning rules and factual knowledge, serving as a mediator that enhances prompt quality without requiring complex modifications to the language model itself. This intermediary structure enables systematic integration of logical reasoning capabilities.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent segments the prompt generation process into distinct components: reasoning rule extraction from the knowledge graph, template construction based of the extracted rules, and prompt generation by filling templates with specific data. This segmentation allows each component to be optimized independently while maintaining overall system simplicity.

Inventive Principle:
Principle #1Segmentation

2Reliability

If more reasoning rules and knowledge are integrated into prompts, then the logic and reasoning capabilities improve, but the generation efficiency decreases

Engineering Contradiction:
Improvereasoning capabilityVSAvoidgeneration efficiency
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent performs preliminary actions by pre-extracting and storing reasoning rules in the knowledge graph before actual prompt generation. The reasoning rules are extracted once and stored in a structured format, allowing rapid retrieval and application during prompt generation without reprocessing the same logical structures repeatedly.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent uses template copying as a mechanism to efficiently generate multiple prompts. Once a reasoning rule is extracted and a corresponding template is constructed, this template can be copied and filled with different data instances to generate multiple high-quality prompts systematically, maintaining consistency while improving efficiency.

Inventive Principle:
Principle #26Copying

3Manufacturing precision

If structured reasoning rules from knowledge graph are used, then the controllability and factual correctness improve, but the complexity of prompt structure increases

Engineering Contradiction:
Improvefactual correctnessVSAvoidprompt structure complexity
Core Design Contradiction:
Manufacturing precisionVSDevice complexity

Solution Approach 1:

The patent applies parameter changes by transforming structured reasoning rules from the knowledge graph into standardized text templates with specific parameters. The reasoning rules are converted from a structured graph format into flexible text templates that maintain the logical structure while adapting to different generation scenarios, effectively managing complexity through parameterized transformations.

Inventive Principle:
Principle #35Parameter changes

4Loss of information

If templates are constructed based on reasoning rules, then the semantic richness and logical strength improve, but the generation time increases

Engineering Contradiction:
Improvesemantic richnessVSAvoidgeneration time
Core Design Contradiction:
Loss of informationVSLoss of time

Solution Approach 1:

The patent performs preliminary template construction based on extracted reasoning rules. By pre-constructing templates that capture the semantic structure of reasoning rules, the system avoids repeated semantic processing during actual prompt generation, thereby maintaining semantic richness while reducing generation time.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS20250148317A1Method and apparatus for generating prompt data based on knowledge graph
Publication Date: 2025.05.08 ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
  • US20250148317A1 patent drawing
  • US20250148317A1 patent drawing

AI summary

Embodiments of this specification provide a method and an apparatus for generating a prompt based on a knowledge graph. In the method, a reasoning rule and an instance subgraph from the knowledge graph that match each other can be obtained in a plurality of manners. A question and answer template is constructed based on the reasoning rule. The question and answer template includes a question template and an answer template, and the answer template includes a cause template and a result template. A target text can be generated based on a combination of the question and answer template and the instance subgraph. The target text includes a question text and an answer text, and the answer text includes a cause text and a result text. The target text is used as a prompt to adjust a language model.