Method, medium and system for acquiring accurate prompt of user

By extracting the semantic features of user problems and building augmented semantic feature map, generating candidate paths, and finally generating accurate propt based on the path, the problem of lack of overall coherence and difference in the propt generation in the existing technology is solved, and the large language model is improved The application effect.

CN119476500AActive Publication Date: 2025-02-18青岛网信信息科技有限公司

Patent Information

Application Number
CN202510044709.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-02-18
Estimated Expiration
2045-01-13

AI Technical Summary

Technical Problem

In the prior art, the generation of prompt focuses on phrase-level template filling, lacks consideration of the overall consistency and difference of prompt, which limits the effect of large language models in practical applications.

Method used

By obtaining the basic problems of users, extracting semantic features, and performing synonyms expansion, context association analysis, and domain knowledge supplementation, augmented semantic feature map is constructed, and candidate paths are generated using the depth-first search algorithm, and finally generating accurate props based on the path.

Benefits of technology

The overall coherence and difference optimization of the propt is achieved, and the generated propt is closer to user needs and improves the effect of the large language model in practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119476500A_ABST
    Figure CN119476500A_ABST
Patent Text Reader

Abstract

The invention provides a method, medium and system for obtaining accurate prompt of a user, and belongs to the technical field of large language models.The method comprises the steps that questions proposed by the user are obtained, and semantic features are extracted from the questions; the semantic features are expanded and supplemented to form a richer semantic feature set; based on the increased and expanded semantic features, a semantic feature map is established to represent concepts and relationships; in combination with the context of the user, analyzing the intention and demand of the user, and performing weighted sorting on nodes in the semantic feature map to form a weighted semantic feature map; searching a plurality of candidate paths from the weighted semantic feature map, and generating a prompt for each path; generating a series of questions according to the prompts by utilizing a pre-trained question generation model, and presenting the questions to a user; and the user selects one problem as the final accurate prompt, so that the problem that the overall continuity and difference of the prompt are not considered in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of large language models, and in particular, relates to a method, medium and system for obtaining a user's precise prompt. Background Art

[0002] With the widespread application of large language models in the field of natural language processing, users can obtain the knowledge and reasoning ability of the model by asking various open-ended questions. However, the basic questions asked by users are often too simple or vague and cannot well reflect their actual needs. In order to accurately obtain the user's true intention and generate more targeted answers, it is necessary to conduct in-depth semantic analysis and expansion of the user's basic questions.

[0003] Currently, some researchers are trying to enhance the pertinence and richness of user prompts through methods such as semantic feature extraction, knowledge graph construction, and path-based prompt generation. For example, semantic features such as keywords, named entities, and key phrases can be extracted from questions, and expanded using dictionaries and knowledge bases to build a knowledge graph that reflects semantic concepts and their associations. On this basis, prompts that are close to user needs can be generated by exploring paths on the knowledge graph. These methods have improved the quality of prompts and enhanced user experience to a certain extent.

[0004] However, in the prior art, prompt generation focuses on phrase-level template filling, and lacks consideration of the overall coherence and diversity of prompts. This problem limits the effectiveness of large language models in practical applications. Summary of the invention

[0005] In view of this, the present invention provides a method, medium and system for obtaining accurate prompts from users, which can solve the technical problem that prompt generation in the prior art focuses on template filling at the phrase level and lacks consideration of the overall coherence and diversity of the prompts.

[0006] The present invention is achieved in that: A first aspect of the present invention provides a method for obtaining a user's precise prompt, comprising the following steps: S10, obtaining questions raised by the user to the large language model as basic questions, and extracting semantic features of the basic questions; S20, performing synonym expansion, context association analysis, and domain knowledge supplementation according to the semantic features to obtain an augmented semantic feature set; S30, establishing an augmented semantic feature graph according to the augmented semantic feature set, wherein the nodes of the augmented semantic feature graph represent semantic concepts or keywords, and the edges represent semantic relationships or logical connections between nodes; S40, according to the context input by the user, using the large language model to analyze the user's intention and needs, identify key concepts and constraints, assign weights and prioritize nodes in the augmented semantic feature graph, and obtain a weighted semantic feature graph; S50, using a depth-first search algorithm for the weighted semantic feature graph to obtain multiple candidate paths of the weighted semantic feature graph; S60, generating a corresponding prompt according to each candidate path using a prompt generation algorithm based on the path, and combining each prompt with a pre-adjusted prompt generation question model to generate a question, obtain a question list and output it to the user; S70: Obtain the question selected by the user according to the question list as the selected question, and use the prompt corresponding to the selected question as the user's precise prompt.

[0007] Based on the above technical solution, a method for obtaining a user's precise prompt of the present invention can also be improved as follows: The prompt question generation model is based on the large language model and is obtained by fine-tuning and training a large number of high-quality prompt-question pairs.

[0008] Specifically, step S10 is a semantic feature extraction step, which specifically includes: segmenting and part-of-speech tagging the basic question raised by the user to obtain the basic information of each word in the question; calculating the TF-IDF value of each word to reflect the importance of the word in the question; identifying the named entities in the question to find important concepts such as names of people, places, and organizations; extracting key phrases in the question to better capture the semantic information of the question. The above three types of features are combined to form a semantic feature vector of the question, laying the foundation for the subsequent semantic feature expansion and the construction of the augmented semantic feature graph.

[0009] Among them, step S20 is a semantic feature expansion step, which specifically includes: for each feature in the extracted semantic feature vector, searching for its synonyms in the synonym dictionary or word embedding model, and performing synonym expansion; defining a context window, analyzing the preceding and following neighboring words of each feature, and extracting high-frequency co-occurring words as context-related words; mapping the features to the knowledge graph or domain ontology library, and extracting nodes directly connected to these entities as supplementary knowledge. Through the above three expansion methods, the original semantic features are enriched, providing more comprehensive information for the subsequent construction of the augmented semantic feature graph.

[0010] Among them, step S30 is a step of constructing an augmented semantic feature graph, which specifically includes: taking the expanded semantic features as nodes of the graph, adding edges to the graph according to the condition that the similarity between the nodes is greater than a certain threshold, indicating the semantic association between the nodes; assigning weights to each edge, indicating the strength of association between the nodes. In this way, an augmented semantic feature graph reflecting semantic concepts and their relationships is constructed, providing a basis for the subsequent generation of weighted semantic feature graphs.

[0011] Among them, step S40 is a step of generating a weighted semantic feature graph, which specifically includes: calculating the relevance score of each node according to the context information input by the user, reflecting the relevance degree of the node to the user's needs; using the PageRank algorithm or centrality calculation to obtain the importance score of each node, reflecting the status and influence of the node in the entire semantic system. The relevance score and the importance score are applied together to the edge weight of the augmented semantic feature graph to obtain a weighted semantic feature graph, highlighting the semantic concepts that are relevant and important to the user's needs.

[0012] Among them, step S50 is a candidate path generation step, which specifically includes: determining the node with the highest weight in the weighted semantic feature graph as the starting node, selecting the node most relevant to the user's intention as the ending node; using a depth-first search algorithm to explore multiple candidate paths from the starting node to the ending node on the weighted semantic feature graph, providing a basis for subsequent prompt generation. In this way, multiple candidate paths that reflect the logical relationship and reasoning process between semantic concepts can be obtained.

[0013] Among them, step S60 is a prompt generation step, which specifically includes: defining a prompt template function, filling the nodes in the candidate path into the predefined template, and generating a preliminary prompt; considering the coherence of the prompt, calculating the semantic similarity of adjacent nodes in the path, and ensuring the continuity and fluency of the semantics inside the prompt; considering the diversity of the prompt, calculating the Jaccard distance between the current prompt and other prompts, and ensuring the differences between different prompts. Taking these factors into consideration, multiple candidate prompts are generated for users to choose.

[0014] Among them, step S70 is a precise prompt acquisition step, which specifically includes: presenting multiple candidate prompts generated in step S60 to the user, allowing the user to select according to their own needs; the prompt selected by the user is used as the final precise prompt, as the input for subsequent processing of the large language model. Through this interactive method, it is ensured that the final prompt can accurately meet the actual needs of the user.

[0015] Optionally, in step S10, the semantic feature extraction algorithm may also include using a deep learning model to perform semantic representation learning on the question to obtain an embedded representation of the question as part of the semantic feature vector. This semantic feature extraction method based on deep learning can better capture the implicit semantic information in the question.

[0016] Optionally, in step S20, the synonym expansion can also combine context information to select synonyms that are more relevant to the current question, further improving the pertinence of the semantic features. At the same time, when supplementing domain knowledge, it is also possible to consider using keywords appearing in the question to more accurately search and associate the knowledge graph or ontology library to obtain supplementary knowledge that is closer to the question.

[0017] Optionally, in step S40, in addition to using the PageRank algorithm, other centrality indicators such as degree centrality, closeness centrality, etc. can be used to calculate the node importance score, and a suitable algorithm can be selected according to the specific application scenario.

[0018] Optionally, in step S50, the depth-first search algorithm can also be combined with a heuristic search strategy, such as an A* algorithm, to improve the efficiency and quality of path exploration. At the same time, multiple termination nodes can also be set to generate multiple groups of candidate paths for different user intentions.

[0019] The semantic features of the basic question are extracted, which is specifically expressed as follows: The semantic feature extraction algorithm is specifically expressed as follows: ; In the formula, is the extracted semantic feature vector; For basic questions; For the feature extraction function; For the The weight of each feature; is the number of feature extraction functions; Embedding representation for the problem; is the weight coefficient of the embedding representation.

[0020] Parameter acquisition method: This can be achieved through different natural language processing technologies, such as TF-IDF, part-of-speech tagging, named entity recognition, etc. The specific steps are as follows: Step 1: Question Perform word segmentation and part-of-speech tagging; Step 2: Calculate the TF-IDF value of each word; Step 3: Identify named entities; Step 4: Extract key phrases.

[0021] and default , each equal, Pick or, and It is obtained through machine learning model training, and the training data is a large number of labeled question-feature pairs.

[0022] Obtained through pre-trained language models (such as ChatGlm6B and Tongyi Qianwen).

[0023] According to the semantic features, synonym expansion, context association analysis, and domain knowledge supplementation are performed to obtain an augmented semantic feature set, which is specifically expressed as follows: ; In the formula, is the expanded semantic feature set; is the original semantic feature vector; Extension functions for synonyms; It is the context association analysis function; Supplement functions for domain knowledge; is the weight coefficient of each expansion method.

[0024] Parameter acquisition method: It is calculated through a synonym dictionary or word embedding model. The specific steps are as follows: Step 1: For For each feature in , look up its synonyms in the thesaurus; Step 2: Use the word embedding model to calculate the similarity and select words with similarity higher than the threshold as synonyms.

[0025] It is obtained through context window analysis or topic model. The specific steps are as follows: Step 1: Define the context window size ; Step 2: For For each feature in words and extract high-frequency co-occurring words.

[0026] Obtained through knowledge graph or domain ontology library, the specific steps are as follows: Step 1: The features in are mapped to entities in the knowledge graph; Step 2: Extract the nodes directly connected to these entities as supplementary knowledge.

[0027] The default is 1 / 3, or The optimal value is preferably determined by a cross-validation method.

[0028] The algorithm for constructing the augmented semantic feature graph is specifically expressed as follows: ; ; ; ; In the formula, To augment the semantic feature map; is a node set, corresponding to the expanded semantic features; is the edge set; is the edge weight matrix; For Node and The similarity function between is the similarity threshold.

[0029] Parameter acquisition method: It can be calculated by cosine similarity or Jaccard similarity: ; ; The default is 0.75, or you can start with 0.5 and gradually adjust it to get the best performance through experimentation.

[0030] The weighted semantic feature map generation algorithm is specifically expressed as follows: ; ; ; In the formula, is the weighted semantic feature map; is the new edge weight matrix; is matrix element-wise multiplication; To adjust the matrix; is the sigmoid function; For Node 's relevance score; For Node Importance score.

[0031] Parameter acquisition method: Calculated by correlation with the user input context: ; in, A collection of words in the context of user input.

[0032] Obtained through PageRank algorithm or centrality calculation: ; in, is the damping factor, usually 0.85; For Node The set of neighbor nodes.

[0033] The depth-first search algorithm is specifically expressed as follows: ; ; In the formula, is a set of candidate paths; is the starting node; is the termination node; is the maximum path length; For Node The set of neighbor nodes.

[0034] Parameter acquisition method: Select the node with the highest weight in the weighted semantic feature graph; Select the node that is most relevant to the user's intent; Determined through experiments, the value usually ranges from 3 to 7.

[0035] The path-based prompt generation algorithm is specifically expressed as follows: ; In the formula, For the A prompt for candidate paths to be generated; For the candidate paths; Fill in the template with functions; is the coherence scoring function; is the diversity scoring function; is the weight coefficient.

[0036] Parameter acquisition method: This is done through a predefined prompt template, which fills the nodes in the path into the placeholders in the template.

[0037] By calculating the semantic similarity of adjacent nodes in the path, we can get: ; By calculating the average Jaccard distance between the current path and other paths, we can get: ; Default All are 0.5, and the others are The optimal value can also be determined through grid search and cross validation.

[0038] A second aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are run in a computer, they are used to execute the above-mentioned method of obtaining a user's precise prompt.

[0039] A third aspect of the present invention provides a system for obtaining a user's precise prompt, which includes the above-mentioned computer-readable storage medium.

[0040] Compared with the prior art, the method, medium and system for obtaining a user's precise prompt provided by the present invention have the following beneficial effects: 1. The extraction and expansion of semantic features are more comprehensive and dynamic. In addition to using static dictionaries and knowledge bases, this method also combines pre-trained language models to learn deep semantic representations of questions and capture implicit semantic information. At the same time, in terms of synonym expansion, contextual association analysis, and domain knowledge supplementation, contextual information and prior knowledge are fully utilized to make semantic features closer to the actual semantics of the question.

[0041] 2. The construction and weighting of the augmented semantic feature graph are more intelligent. This method not only considers the similarity relationship between nodes, but also introduces the relevance and importance information of nodes. Through weighted adjustment, concepts that are more relevant to user needs and have a more important position in the entire semantic system receive more attention. This modeling and analysis method based on semantic feature graphs can better reflect the semantic structure and internal logic involved in the problem.

[0042] 3. Prompt generation not only considers template filling at the phrase level, but also optimizes the overall coherence and diversity of prompts. By calculating the semantic similarity of adjacent nodes in the candidate path, the internal semantic fluency of the generated prompt is ensured; at the same time, by analyzing the Jaccard distance between different prompts, the diversity of prompt selection is improved to meet the user's demand for differentiated selection.

[0043] In general, the method proposed in the present invention makes full use of technical means such as semantic analysis, knowledge graph, and graph algorithm, and comprehensively considers multiple factors such as user needs, semantic associations, and concept importance, and can better extract and generate accurate prompts that meet the actual needs of users from basic questions. It solves the technical problem that prompt generation in the prior art focuses on template filling at the phrase level and lacks consideration of the overall coherence and diversity of prompts. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A flow chart of the method provided by the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0046] like Figure 1 FIG. 1 is a flow chart of a method for obtaining a user's precise prompt provided by the present invention. The method comprises the following steps: S10, obtaining questions raised by the user to the large language model as basic questions, and extracting semantic features of the basic questions; S20, performing synonym expansion, context association analysis, and domain knowledge supplementation according to the semantic features to obtain an expanded semantic feature set; S30, establishing an augmented semantic feature graph according to the augmented semantic feature set, wherein the nodes of the augmented semantic feature graph represent semantic concepts or keywords, and the edges represent semantic relationships or logical connections between the nodes; S40, according to the context input by the user, using a large language model to analyze the user's intention and needs, identify key concepts and constraints, assign weights and prioritize nodes in the augmented semantic feature graph, and obtain a weighted semantic feature graph; S50, using a depth-first search algorithm on the weighted semantic feature graph to obtain multiple candidate paths of the weighted semantic feature graph; S60, generating a corresponding prompt according to each candidate path using a prompt generation algorithm based on the path, and combining each prompt with a pre-adjusted prompt generation question model to generate a question, obtain a question list and output it to the user; S70. Obtain the question selected by the user from the question list as the selected question, and use the prompt corresponding to the selected question as the user's precise prompt.

[0047] The specific implementation methods of the above steps are described in detail below: Step S10: First, the purpose of this step is to extract semantic features from the basic questions raised by the user. The specific implementation is as follows: First, perform word segmentation and part-of-speech tagging on the basic question Q. Word segmentation can use common word segmentation algorithms, such as HanLP, jieba, etc.; part-of-speech tagging can use corresponding natural language processing tools, such as Stanford Core NLP. Through word segmentation and part-of-speech tagging, basic information about each word in the question can be obtained.

[0048] Next, calculate the TF-IDF value of each word. TF-IDF is a commonly used text feature representation method that can reflect the importance of a word in a text. The specific calculation formula is: ; Among them, TF stands for term frequency and IDF stands for inverse document frequency. The higher the TF-IDF value, the more important the word is in the question.

[0049] In addition, it is also necessary to identify the named entities in the question. Named entity recognition is an important task in natural language processing, which can discover important concepts such as names of people, places, and organizations in the question. You can use pre-trained named entity recognition models, such as those provided by tools such as NLTK and spaCy. This feature can be expressed as: ; Finally, extract the key phrases in the question. Key phrases usually contain multiple words and can better capture the semantic information of the question. You can use key phrase extraction algorithms based on grammatical rules or machine learning, such as TextRank, RAKE, etc. This feature can be expressed as: ; Combining the above three types of features, we can get the semantic feature vector F of question Q: ; in, is the weight coefficient of each feature, is the weight coefficient of the embedding representation, The embedded representation of the question can be obtained through pre-trained language models (such as ChatGlm6B and Tongyi Qianwen).

[0050] These features can capture the semantic information of the problem more comprehensively, laying the foundation for the subsequent semantic feature expansion and the construction of the augmented semantic feature graph. and It can be obtained through machine learning model training, and the training data is a large number of labeled question-feature pairs.

[0051] Step S20: The purpose of this step is to expand the basic semantic features extracted in step S10 to obtain a richer set of semantic features. The specific implementation is as follows: First, synonym expansion is performed. For each feature in the semantic feature vector F obtained in step S10, its synonym is searched in the synonym dictionary or word embedding model. The synonym dictionary can use existing resources, such as HowNet, WordNet, etc.; the word embedding model can use pre-trained models, such as Word2Vec, GloVe, etc., calculate the similarity and select words with similarity higher than a certain threshold as synonyms. This step of expansion can be expressed as: ; Secondly, perform context association analysis. Define a context window size k, and for each feature in F, analyze the k words before and after it, and extract high-frequency co-occurring words as context-related words. This step of expansion can be expressed as: ; Finally, supplement domain knowledge. Map the features in F to entities in the knowledge graph or domain ontology library, and extract nodes directly connected to these entities as supplementary knowledge. This step of expansion can be expressed as: ; Combining the above three expansion methods, we can get the expanded semantic feature set : ; in, is the weight coefficient of each expansion method, and the optimal value can be determined by cross-validation method.

[0052] The purpose of this step is to enrich the semantic features and provide more comprehensive information for the subsequent construction of the augmented semantic feature graph. Synonym expansion can increase the coverage of concepts, context analysis can capture semantic associations, and domain knowledge supplementation can increase professionalism. By weighted combination of these three expansion methods, a more comprehensive semantic feature set can be obtained.

[0053] Step S30: The purpose of this step is to construct an augmented semantic feature graph based on the extended semantic feature set obtained in step S20 to better reflect the relationship and structure between semantics. The specific implementation is as follows: First, the extended semantic feature set Each feature in is a node in the graph , forming a node set V: ; Next, determine the edge E between the nodes. For any two nodes and , if their similarity is greater than a certain threshold , then add an edge to the graph The similarity can be calculated using cosine similarity or Jaccard similarity: ; ; It is an adjustable parameter, usually with a value of around 0.5, and can be adjusted according to actual conditions.

[0054] Finally, assign weights to each edge. , represents the node and The strength of the association between: ; To sum up, we can get an augmented semantic feature graph G: ; Among them, V is the node set, E is the edge set, and W is the edge weight matrix.

[0055] The purpose of this step is to construct a semantic feature graph that reflects semantic concepts and their relationships. The nodes in the graph represent semantic concepts or keywords, and the edges represent semantic relationships or logical connections between nodes. By calculating node similarity and constructing edges, the connection between semantic features can be captured, providing a basis for the subsequent generation of weighted semantic feature graphs. Threshold The settings need to be adjusted according to the specific application scenario to obtain the best semantic feature association.

[0056] Step S40: The purpose of this step is to weight the augmented semantic feature graph constructed in step S30 according to the user's context information to reflect the importance of the node and its relevance to the user's needs. The specific implementation is as follows: First, calculate each node The relevance score The relevance score reflects the relevance of the node to the user input context and can be calculated by the following formula: ; in, A collection of words in the context of user input, For Node With context words The similarity can be calculated using cosine similarity or Jaccard similarity.

[0057] Next, calculate each node Importance score The importance score reflects the status and influence of the node in the entire semantic feature graph, which can be obtained by using the PageRank algorithm or centrality calculation: ; in, is the damping factor, usually 0.85; For Node The set of neighbor nodes.

[0058] Finally, according to the relevance score and importance score of the node, the edge weight W of the augmented semantic feature graph G is adjusted to obtain the weighted semantic feature graph : ; ; in, represents matrix element-wise multiplication, is the sigmoid function.

[0059] The purpose of this step is to weight the semantic feature graph according to the contextual information input by the user, so as to highlight the semantic concepts and keywords related to the user's needs and reflect their status in the entire semantic system. The relevance score and importance score work together to adjust the edge weight, so that more relevant and important semantic features receive more attention and priority in the subsequent candidate path generation.

[0060] Step S50: The purpose of this step is to Based on this, multiple candidate paths are generated to provide options for subsequent prompt generation. The specific implementation is as follows: First, determine the starting node and the terminal node . The node with the highest weight in the weighted semantic feature graph is selected, which reflects the core concept of the entire semantic system; The node most relevant to the user's intention is selected, which can be determined based on the contextual information input by the user.

[0061] Next, the depth-first search (DFS) algorithm is used to search the weighted semantic feature graph. Generate candidate paths: ; in, is the maximum path length, usually ranging from 3 to 7, and can be adjusted according to actual conditions. The specific implementation of the DFS algorithm is as follows: ; The algorithm starts from the node Start and perform a depth-first search along the edges in the graph until you encounter a terminal node or reaches the maximum path length , and record the searched path.

[0062] In this way, multiple arrive Candidate paths for , providing a basis for subsequent prompt generation.

[0063] The purpose of this step is to generate multiple candidate paths from the core concept to the user intention-related concepts based on the weighted semantic feature graph. These candidate paths reflect the logical relationship and reasoning process between semantic concepts, providing diverse choices for subsequent prompt generation. The DFS algorithm can effectively explore the paths in the graph, and the determination of the start and end nodes reflects the focus on user needs.

[0064] Step S60: The purpose of this step is to generate multiple candidate prompts for the user based on the candidate paths generated in step S50 using a prompt generation algorithm based on the path. The specific implementation is as follows: First, define a prompt template function , the candidate path Fill the nodes in the predefined prompt template to get a preliminary prompt: ; Next, consider the coherence and diversity of the prompt. Coherence reflects the continuity and fluency of the semantics within the prompt, which can be evaluated by calculating the semantic similarity of adjacent nodes in the path: ; Diversity reflects the differences between different prompts, which can be evaluated by calculating the Jaccard distance between the current prompt and other prompts: ; Finally, we can get the i-th candidate prompt: ; in, and The weight coefficients for coherence and diversity can be determined by grid search and cross validation.

[0065] The purpose of this step is to generate multiple prompts for users to choose from based on the candidate paths. Fill the semantic concepts in the path into the predefined template to form a complete prompt; coherence scoring function This ensures the continuity and fluency of the internal semantics of the prompt. The diversity scoring function This ensures the differences between different prompts, thereby providing users with more choices.

[0066] By adding coherence and diversity scores, we can ensure that the generated prompt not only covers various semantic concepts involved in user needs, but also reflects the logical relationship between semantics, while also providing differentiated choices to meet the diverse needs of users.

[0067] Step S70: The purpose of this step is to obtain the precise prompt that the user finally selects. The specific implementation is as follows: First, the prompt list generated in step S60 is presented to the user, allowing the user to select according to his or her needs. The prompt selected by the user is used as the final accurate prompt.

[0068] Next, the prompt selected by the user is used as the output and the input for subsequent processing of the large language model. This prompt has been optimized through steps such as semantic feature extraction, expansion and weighting, and candidate path generation, and can better reflect the actual needs of users.

[0069] The core of this step is to allow users to choose the prompt that best suits their needs. The previous steps provide users with a variety of prompt options, and users can choose according to their own understanding and preferences. This interactive approach can ensure that the final prompt meets the user's needs more accurately.

[0070] A second aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are run in a computer, they are used to execute the above-mentioned method of obtaining a user's precise prompt.

[0071] A third aspect of the present invention provides a system for obtaining a user's precise prompt, which includes the above-mentioned computer-readable storage medium.

[0072] Specifically, the principle of the present invention: The method for obtaining an accurate prompt proposed by the present invention mainly includes the following key steps: 1. Semantic feature extraction The core idea of ​​this step is to extract multi-dimensional semantic features including word frequency, named entities, key phrases, etc. through in-depth analysis of the basic questions raised by users, laying the foundation for subsequent semantic expansion and knowledge modeling. Specifically, firstly, word segmentation and part-of-speech tagging are performed to obtain the basic information of each word in the question; then the TF-IDF value of each word is calculated to reflect the importance of the word in the question; at the same time, the named entities in the question are identified to find important concepts such as names of people and places; finally, key phrases are extracted to better capture the semantic connotation of the question. These features are combined to form the semantic feature vector of the question.

[0073] The reason for adopting this multi-dimensional feature extraction method is that a single feature is difficult to fully reflect the semantics of the question. The word frequency can reflect the topic keywords of the question, the named entity reveals the important entities involved in the question, and the key phrase better captures the internal logic between the semantics. By integrating these features, the semantic characteristics of the question can be more comprehensively portrayed, providing richer information for subsequent expansion and analysis.

[0074] 2. Semantic feature expansion The purpose of this step is to expand the basic semantic feature vector extracted in step 1 to obtain a richer set of semantic features. It specifically includes three aspects:

[0075] Synonym expansion: For each word in the base feature, look up its synonyms in the synonym dictionary or word embedding model to increase the concept coverage. This can make up for the semantic information that may be missed in the base feature.

[0076] Contextual association analysis: define a context window, analyze the co-occurring words before and after each feature word, extract high-frequency related words, and capture the association between semantics. This is conducive to reflecting the contextual semantics of the problem.

[0077] Domain knowledge supplement: Map the basic features to the knowledge graph or ontology library, extract the nodes directly related to these concepts, and increase professional knowledge. This can make up for the lack of domain information in the basic features.

[0078] Through the organic combination of the above three expansion methods, a more comprehensive, dynamic and professional semantic feature set can be constructed, providing a richer foundation for subsequent knowledge modeling and prompt generation.

[0079] 3. Construction of augmented semantic feature graph Based on the semantic feature set obtained in step 2, the purpose of this step is to construct a knowledge graph that reflects semantic concepts and their relationships. Specifically, each semantic feature is first used as a node of the graph, and then edges are constructed based on the similarity relationship between nodes to form an augmented semantic feature graph. The weight of the edge reflects the strength of the semantic association between nodes.

[0080] This knowledge representation method based on semantic feature graphs can better capture the semantic structure and internal logic involved in the problem. Compared with the traditional triple-based knowledge base, semantic feature graphs can more delicately depict the various relationships between concepts and provide richer information for subsequent reasoning and analysis.

[0081] 4. Weighted semantic feature map generation Based on the augmented semantic feature graph constructed in step 3, the purpose of this step is to weight the nodes in the graph according to the contextual information input by the user, so as to highlight the concepts that are more relevant to user needs and have a more important position in the entire semantic system.

[0082] Specifically, the relevance score of each node is first calculated, which reflects the relevance of the node to the user context. At the same time, the importance score of each node is also calculated, which reveals the status and influence of the node in the entire semantic system. Combining these two scoring factors, the edges of the augmented semantic feature graph are weighted and adjusted, so that more relevant and important semantic concepts receive more attention in the subsequent candidate path generation.

[0083] This weighting method based on node relevance and importance can effectively integrate user demand information into knowledge modeling, making the knowledge graph better fit the actual application scenario. Compared with the simple similarity-based construction method, this method can more intelligently discover and highlight semantic concepts related to user needs.

[0084] 5. Candidate Path Generation Based on the weighted semantic feature map generated in step 4, the purpose of this step is to explore multiple candidate paths from core semantic concepts to user intent-related concepts, providing a basis for subsequent prompt generation.

[0085] Specifically, we first determine the starting node as the core concept of the entire semantic system, and the ending node as the concept most relevant to the user's intention. Then, we use the depth-first search algorithm to explore paths on the weighted semantic feature graph and generate multiple candidate paths. These paths reflect the logical relationship and reasoning process between semantic concepts, providing rich choices for the subsequent prompt generation.

[0086] Compared with the simple shortest path algorithm, depth-first search can better discover the hidden semantic associations in the graph and generate more diverse candidate paths. At the same time, by reasonably determining the starting and ending nodes, it also reflects the importance of user needs, making the generated path closer to the actual application scenario.

[0087] 6. Prompt generation The purpose of this step is to provide users with multiple candidate prompts based on the candidate paths generated in step 5 using a path-based prompt generation algorithm.

[0088] Specifically, we first define a prompt template function, fill the semantic concepts in the candidate path into the predefined template, and form a preliminary prompt. Next, we consider the coherence and diversity of the prompt. Coherence reflects the fluency of the internal semantics of the prompt, which can be evaluated by calculating the semantic similarity of adjacent nodes in the path; diversity reflects the differences between different prompts, which can be measured by analyzing the Jaccard distance between prompts. Taking these two factors into consideration, we generate the final prompt.

[0089] This path-based prompt generation method can make full use of the semantic knowledge graph constructed in the previous steps and is closer to the actual semantic connotation of the question. Compared with simple template filling, this method not only considers the internal coherence of the prompt, but also improves the diversity of prompt selection, which can better meet the personalized needs of users.

[0090] In order to better understand and implement the present invention, a specific embodiment 1 of the method of the present invention is provided below. The relevant steps of this embodiment 1 are specifically described as follows: Step S10: semantic feature extraction The purpose of this step is to ask basic questions from users Extract semantic feature vectors from The specific implementation is as follows: First, the problem Perform word segmentation and part-of-speech tagging to obtain basic information about each word in the question. Word segmentation can be done using common word segmentation algorithms such as HanLP and Jieba, while part-of-speech tagging can be done using natural language processing tools such as Stanford Core NLP. This step can get the question Collection of words and the corresponding part-of-speech set .

[0091] Next, calculate the TF-IDF value of each word. TF-IDF is a commonly used text feature representation method that can reflect the importance of a word in a text. The specific calculation formula is: ; in, is the total number of documents, To contain words The higher the TF-IDF value, the more likely the word is in the question. China is more important.

[0092] In addition, it is also necessary to identify the named entities in the question. Named entity recognition is an important task in natural language processing, which can discover important concepts such as names of people, places, and organizations. You can use pre-trained named entity recognition models, such as those provided by tools such as NLTK and spaCy. This feature can be expressed as: ; in, For the problem The number of named entities in The type of i named entities, such as names of people, places, etc.

[0093] Finally, extract the key phrases in the question. Key phrases usually contain multiple words and can better capture the semantic information of the question. You can use key phrase extraction algorithms based on grammatical rules or machine learning, such as TextRank, RAKE, etc. This feature can be expressed as: ; in, For the problem The number of key phrases extracted from each Indicates a key phrase.

[0094] Combining the above three characteristics, we can get the problem The semantic feature vector of : ; in, is the weight coefficient of each feature, is the weight coefficient of the embedding representation, The embedded representation of the question can be obtained through pre-trained language models (such as ChatGlm6B and Tongyi Qianwen).

[0095] These features can capture the semantic information of the problem more comprehensively, laying the foundation for the subsequent semantic feature expansion and the construction of the augmented semantic feature graph. and It can be obtained through machine learning model training, and the training data is a large number of labeled question-feature pairs.

[0096] Step S20: semantic feature expansion The purpose of this step is to extract the basic semantic feature vector in step S10. Based on this, we expand it to obtain a richer set of semantic features. The specific implementation is as follows: First, synonym expansion is performed. Each feature in , find its synonym set in the synonym dictionary or word embedding model The synonym dictionary can use existing resources such as HowNet and WordNet; the word embedding model can use pre-trained models such as Word2Vec and GloVe to calculate similarity and select words with similarity above a certain threshold as synonyms. This step of expansion can be expressed as: ; Secondly, we conduct context association analysis. Define a context window size ,for Each feature in , analyze the before and after words, extract high-frequency co-occurring words as a set of context-related words This step of expansion can be expressed as: ; Finally, supplement the domain knowledge. Features in Map to entities in the knowledge graph or domain ontology library and extract the node sets directly connected to these entities As supplementary knowledge. This step of expansion can be expressed as: ; Combining the above three expansion methods, we can get the expanded semantic feature set : ; in, is the weight coefficient of each expansion method, and the optimal value can be determined by cross-validation method.

[0097] The purpose of this step is to enrich the semantic features and provide more comprehensive information for the subsequent construction of the augmented semantic feature graph. Synonym expansion can increase the coverage of concepts, context analysis can capture semantic associations, and domain knowledge supplementation can increase professionalism. By weighted combination of these three expansion methods, a more comprehensive semantic feature set can be obtained.

[0098] Step S30: Construction of augmented semantic feature graph The purpose of this step is to expand the semantic feature set obtained in step S20. , construct an augmented semantic feature graph , to better reflect the relationship and structure between semantics. The specific implementation is as follows: First, the extended semantic feature set Each feature in As the nodes of the graph, they constitute a node set : ; Next, determine the edges between nodes For any two nodes and , if their similarity Greater than a certain threshold , then add an edge to the graph The similarity can be calculated using cosine similarity or Jaccard similarity: ; ; It is an adjustable parameter, usually with a value of around 0.5, and can be adjusted according to actual conditions.

[0099] Finally, for each edge Assign weight , represents the node and The strength of the association between: ; In summary, we can get an augmented semantic feature map : ; in, is a collection of nodes, is the edge set, is the edge weight matrix.

[0100] The purpose of this step is to construct a semantic feature graph that reflects semantic concepts and their relationships. The nodes in the graph represent semantic concepts or keywords, and the edges represent semantic relationships or logical connections between nodes. By calculating node similarity and constructing edges, the connection between semantic features can be captured, providing a basis for the subsequent generation of weighted semantic feature graphs. Threshold The settings need to be adjusted according to the specific application scenario to obtain the best semantic feature association.

[0101] Step S40: Weighted semantic feature map generation The purpose of this step is to augment the semantic feature graph constructed in step S30 based on the user's context information. Weighting is performed to reflect the importance of the node and its relevance to user needs. The specific implementation is as follows: First, calculate each node The relevance score The relevance score reflects the relevance of the node to the user input context and can be calculated by the following formula: ; in, A collection of words in the context of user input, For Node With context words The similarity can be calculated using cosine similarity or Jaccard similarity.

[0102] Next, calculate each node Importance score The importance score reflects the status and influence of the node in the entire semantic feature graph, which can be obtained by using the PageRank algorithm or centrality calculation: ; in, is the damping factor, usually 0.85; For Node The set of neighbor nodes.

[0103] Finally, the augmented semantic feature graph is constructed based on the relevance score and importance score of the node. The edge weight Adjust to get the weighted semantic feature map : ; ; in, represents matrix element-wise multiplication, is the sigmoid function.

[0104] The purpose of this step is to weight the semantic feature graph according to the contextual information input by the user, so as to highlight the semantic concepts and keywords related to the user's needs and reflect their status in the entire semantic system. The relevance score and importance score work together to adjust the edge weight, so that more relevant and important semantic features receive more attention and priority in the subsequent candidate path generation.

[0105] Step S50: Candidate path generation The purpose of this step is to Based on , providing options for subsequent prompt generation. The specific implementation is as follows: First, determine the starting node and the terminal node . The node with the highest weight in the weighted semantic feature graph is selected, which reflects the core concept of the entire semantic system; The node most relevant to the user's intention is selected, which can be determined based on the contextual information input by the user.

[0106] Next, the depth-first search (DFS) algorithm is used to search the weighted semantic feature graph. Generate candidate paths: ; in, is the maximum path length, usually ranging from 3 to 7, and can be adjusted according to actual conditions.

[0107] The algorithm starts from the node Start and perform a depth-first search along the edges in the graph until you encounter a terminal node or reaches the maximum path length , and record the searched path.

[0108] In this way, multiple arrive Candidate paths for , providing a basis for subsequent prompt generation.

[0109] The purpose of this step is to generate multiple candidate paths from the core concept to the user intention-related concepts based on the weighted semantic feature graph. These candidate paths reflect the logical relationship and reasoning process between semantic concepts, providing diverse choices for subsequent prompt generation. The DFS algorithm can effectively explore the paths in the graph, and the determination of the start and end nodes reflects the focus on user needs.

[0110] Step S60: Prompt generation The purpose of this step is to generate candidate paths based on the candidate paths generated in step S50. ,Using the path-based prompt generation algorithm, multiple candidate prompts are generated for users The specific implementation is as follows: First, define a prompt template function , the candidate path Fill the nodes in the predefined prompt template to get the initial prompt : ; Next, consider the consistency and variety of prompts.

[0111] ; Diversity reflects the differences between different prompts, which can be evaluated by calculating the Jaccard distance between the current prompt and other prompts: ; Finally, we can get Candidate prompts: ; in, and The weight coefficients for coherence and diversity can be determined by grid search and cross validation.

[0112] The purpose of this step is to generate multiple prompts for users to choose from based on the candidate paths. Fill the semantic concepts in the path into the predefined template to form a complete prompt; coherence scoring function This ensures the continuity and fluency of the internal semantics of the prompt. The diversity scoring function This ensures the differences between different prompts, thereby providing users with more choices.

[0113] By adding coherence and diversity scores, we can ensure that the generated prompt not only covers various semantic concepts involved in user needs, but also reflects the logical relationship between semantics, while also providing differentiated choices to meet the diverse needs of users.

[0114] Step S70: Accurate prompt acquisition The purpose of this step is to obtain the precise prompt that the user finally selected. The specific implementation is as follows: First, the prompt list generated in step S60 Present it to the user, allowing the user to choose according to their needs. The prompt selected by the user is used as the final accurate prompt.

[0115] Next, the prompt selected by the user is used as the output and the input for subsequent processing of the large language model. This prompt has been optimized through steps such as semantic feature extraction, expansion and weighting, and candidate path generation, and can better reflect the actual needs of users.

[0116] In order to further better understand and implement the present invention, the following is an example 2 of a specific application scenario of the present invention: A technical team has developed a conversation assistant based on a large language model, where users can ask various questions in natural language and the system will give corresponding answers. In the actual application process, the technical team found that the basic questions raised by users are often too simple or vague, and it is difficult to accurately reflect their real needs, resulting in a certain deviation in the answers given by the system and a poor user experience. For this reason, the technical team decided to adopt the method of obtaining accurate prompts proposed in the present invention to improve the service quality of the system.

[0117] The technical team's dialogue system mainly consists of three modules: question understanding module, knowledge base construction module and answer generation module. The following takes the question "How to prevent water pipes from bursting" raised by a user named Zhang San as an example to explain in detail the implementation process of each module.

[0118] 1. Question understanding module The main task of this module is to extract accurate prompts using the method of the present invention based on the basic questions raised by the user. The specific steps are as follows: Step S10: semantic feature extraction The basic question raised by the user is "How to prevent water pipes from bursting". First, the question is segmented and POS tagged, and the following results are obtained, as shown in Table 1: Table 1 Part-of-speech tagging table Words Part of Speech how conjunction prevent verb water pipe noun rupture verb Next, calculate the TF-IDF value of each word. Take "water pipe" as an example. It appears 10 times in the question corpus, and there are 100 words in total. The TF-IDF value of "water pipe" is: ; Similarly, the TF-IDF values ​​of other words are calculated and summarized as shown in Table 2: Table 2 TF-IDF value table Words TF-IDF value how 0.8 prevent 1.5 water pipe 2.0 rupture 1.8 In addition, through named entity recognition, it was found that "water pipe" is an important geographical feature concept.

[0119] Finally, the TextRank algorithm is used to extract key phrases and the result is “prevent water pipes from bursting”.

[0120] Combining the above features, the semantic feature vector of the question is formed : ; Step S20: semantic feature expansion Next, the semantic feature vector To expand: 1) Synonym expansion: Searching for synonyms for "water pipe" in HowNet, we get "pipeline", "water pipe", "water supply pipe", etc.

[0121] Calculate the similarity in the Word2Vec model and select words with a similarity greater than 0.7, such as "drain pipe", "water pipe", etc.

[0122] Synonym set pipe, water pipe, water supply pipe, drainage pipe, water pipe .

[0123] 2) Contextual analysis: Define the context window size ,Analyzing the first three and last three words of “water pipe”, we found that “household”, “installation”, and “material” appear frequently.

[0124] Get context-related word set Home, installation, material .

[0125] 3) Domain knowledge supplement: When mapping "water pipe" to the knowledge graph, we find that concepts such as "pipe material", "water pressure" and "anti-corrosion" are directly connected to it.

[0126] Get a supplementary set of domain knowledge Pipe, water pressure, anti-corrosion .

[0127] Combining the above three expansion methods, we get the expanded semantic feature set : ; ; Step S30: Construction of augmented semantic feature graph Based on the expanded semantic feature set , build an augmented semantic feature graph .

[0128] First, each semantic feature is regarded as a node of the graph. "how", "prevent", "water pipe", "rupture", "pipe", "water pipe", "water supply pipe", "drain pipe", "water pipe", "home use", "installation", "material", "pipe", "water pressure", "anti-corrosion" .

[0129] Next, we calculate the cosine similarity between any two nodes, and if the similarity is greater than 0.6, we add an edge to the graph. It is the similarity value divided by the sum of the total similarities of the node.

[0130] The final constructed augmented semantic feature map As shown in Table 3: Table 3 Augmented semantic feature graph Adjacency List Representation node Edges and weights how ("prevent", 0.72) prevent ("how", 0.72), ("water pipe", 0.68), ("broken", 0.74) water pipe ("prevention", 0.68), ("pipe", 0.78), ("water pipe", 0.71), ("drain pipe", 0.65), ("water pipe", 0.62), ("pipe material", 0.67), ("water pressure", 0.59) rupture ("prevent", 0.74) pipeline ("water pipe", 0.78), ("water supply pipe", 0.75), ("drainage pipe", 0.68) Water pipes ("water pipe", 0.73), ("tap pipe", 0.68) Water supply pipe ("water pipe", 0.71), ("pipe", 0.75), ("water pipe", 0.73), ("material", 0.62) Drain ("water pipe", 0.65), ("pipeline", 0.68) Water pipe ("water pipe", 0.62), ("water pipe", 0.68) Home ("Water pipe", 0.58), ("Material", 0.63) Install ("Water pipe", 0.61), ("Material", 0.67) Material ("water pipe", 0.62), ("household", 0.63), ("installation", 0.67) Pipe ("Water pipe", 0.67), ("Anti-corrosion", 0.72) Water pressure ("Water pipe", 0.59) Anti-corrosion ("Pipe", 0.72) Step S40: Weighted semantic feature map generation According to the question raised by the user, "How to prevent water pipes from bursting", the relevance score and importance score of each node are calculated, and the augmented semantic feature graph is Weighted, get the weighted semantic feature map .

[0131] 1) Node relevance score calculation: The keywords in the user's question are "water pipe", "rupture", and "prevent". The similarity between each node and these keywords is calculated, and the relevance score of the node is obtained as shown in Table 4.

[0132] Table 4 Node correlation scores node Relevance score how 0.62 prevent 0.78 water pipe 0.88 rupture 0.82 pipeline 0.72 Water pipes 0.65 Water supply pipe 0.75 Drain 0.61 Water pipe 0.58 Home 0.53 Install 0.55 Material 0.62 Pipe 0.68 Water pressure 0.59 Anti-corrosion 0.51

[0133] 2) Node importance score calculation: The PageRank algorithm is used to calculate the importance score of each node, and the results are shown in Table 5.

[0134] Table 5 Node importance scores node Importance score how 0.068 prevent 0.129 water pipe 0.186 rupture 0.112 pipeline 0.152 Water pipes 0.093 Water supply pipe 0.127 Drain 0.084 Water pipe 0.072 Home 0.045 Install 0.052 Material 0.091 Pipe 0.108 Water pressure 0.038 Anti-corrosion 0.043

[0135] 3) Weighted semantic feature map generate: According to the relevance score and importance score of the node, the augmented semantic feature graph The edge weights are adjusted to obtain the weighted semantic feature graph , as shown in Table 6.

[0136] Table 6 Weighted semantic feature map The adjacency list representation of node Edges and weights how ("prevent", 0.78) prevent ("how", 0.78), ("water pipe", 0.84), ("broken", 0.88) water pipe ("prevention", 0.84), ("pipe", 0.92), ("water pipe", 0.85), ("drain pipe", 0.72), ("water pipe", 0.65), ("pipe material", 0.81), ("water pressure", 0.62) rupture ("Prevent", 0.88) pipeline ("water pipe", 0.92), ("water supply pipe", 0.88), ("water pipeline", 0.82) Water pipes ("Water supply pipe", 0.75), ("Tap water pipe", 0.71) Water supply pipe ("water pipe", 0.85), ("pipe", 0.88), ("water pipe", 0.75), ("material", 0.72) Drain ("water pipe", 0.72), ("pipeline", 0.75) Water pipe ("water pipe", 0.65), ("water pipe", 0.71) Home ("Water pipe", 0.48), ("Material", 0.58) Install ("Water pipe", 0.52), ("Material", 0.62) Material ("water pipe", 0.72), ("household", 0.58), ("installation", 0.62) Pipe ("Water pipe", 0.81), ("Anti-corrosion", 0.84) Water pressure ("Water pipe", 0.62) Anti-corrosion ("Pipe", 0.84)

[0137] It can be seen that through weighted adjustment, the edge weights of nodes that are more relevant to user questions and have a more important position in the entire semantic system, such as "water pipe", "prevention", "rupture", etc., have been improved, and they will receive more attention in the subsequent candidate path generation.

[0138] Step S50: Candidate path generation In the weighted semantic feature map Based on this, a depth-first search algorithm is used to generate candidate paths from the starting node "water pipe" to the ending node "rupture". The maximum path length is set to 5, and the following three candidate paths are explored:

[0139] ={"Water pipe"->"Pipeline"->"Water supply pipe"->"Material"->"Broken"}; ={"Water pipe"->"Pipe material"->"Anti-corrosion"->"Rupture"}; ={"water pipe"->"water pressure"->"rupture"}; These candidate paths reflect different semantic logics and reasoning processes, providing a basis for subsequent prompt generation.

[0140] Step S60: Prompt generation According to the three candidate paths generated in step S50, the path-based prompt generation algorithm is used to generate the following three candidate prompts: ="To prevent water pipes from bursting, we must first understand the material characteristics of the water pipes and select appropriate pipe materials and anti-corrosion measures."

[0141] ="The root cause of water pipe rupture is often excessive water pressure, so it is necessary to reasonably control the water pressure and select pipes with good pressure resistance."

[0142] ="Common causes of water pipe rupture include material degradation, improper installation, and excessive water pressure, and prevention requires multiple aspects."

[0143] in, Emphasis on materials and anti-corrosion, Highlight water pressure control, Preventive measures are proposed from a comprehensive perspective.

[0144] To further optimize prompt, the following two factors were considered: Coherence: Calculate the cosine similarity of adjacent nodes in the candidate path and get the coherence score of each prompt as follows: ; ; ; Diversity: Calculating the average Jaccard distance between the three prompts yielded a diversity score of 0.71.

[0145] Adding the coherence and diversity scores to the prompt generation formula, we finally get three optimized candidate prompts: To prevent water pipes from bursting, we must first understand the material characteristics of the water pipes and select appropriate pipe materials and anti-corrosion measures; The root cause of water pipe rupture is often excessive water pressure. Therefore, it is necessary to reasonably control the water pressure and select pipes with good pressure resistance; Common causes of water pipe rupture include material degradation, improper installation, and excessive water pressure, which require prevention from multiple aspects; Step S70: Accurate prompt acquisition The three optimized candidate prompts are presented to user Zhang San, allowing him to choose according to his own needs.

[0146] User Zhang San selected As a final precise reminder: "To prevent water pipe rupture, we must first understand the material characteristics of the water pipe and select appropriate pipe materials and anti-corrosion measures."

[0147] The prompt has been optimized in the above steps and can better meet Zhang San's actual needs. Next, the dialogue system takes this prompt as input and provides the user with a corresponding answer through the answer generation module.

[0148] The answer generation module mainly includes the following steps: 1. Input the prompt selected by the user, "To prevent water pipes from bursting, we must first understand the material properties of water pipes and select appropriate pipe materials and anti-corrosion measures" into the question-answering generation model based on the large language model.

[0149] 2. The model has been pre-trained for prompt-question-answer pairs and can generate fluent and coherent answers based on the input prompt.

[0150] 3. The generated answer is as follows: "The material of the water pipe is the key factor in preventing the water pipe from bursting. Common water pipe materials include PVC, copper, stainless steel, etc., and each material has its own characteristics. PVC pipes have good corrosion resistance but low strength and are prone to bursting under high water pressure; copper pipes have high strength but are easily corroded; stainless steel pipes have better overall performance and are a more ideal choice. In addition to choosing the right pipe material, it is also important to do a good job of daily anti-corrosion maintenance. Anti-corrosion coatings, anti-corrosion boxes and other measures can be used to effectively extend the service life of water pipes and reduce leakage and rupture problems caused by corrosion. In short, we must start from the two aspects of water pipe material characteristics and anti-corrosion measures to better prevent the occurrence of water pipe ruptures." 4. Return the generated answer to user Zhang San, completing the entire question-and-answer interaction process.

[0151] Through the above implementation process, we can see how the method for obtaining accurate prompt proposed by the present invention works in practical applications: First, the question understanding module can extract the semantic features of user questions more comprehensively, and generate prompts that are close to the user's actual needs through means such as expansion and knowledge modeling, which provides a good foundation for subsequent answer generation.

[0152] Secondly, the prompt generation process takes into account the two factors of coherence and diversity, ensuring that the generated prompt is not only semantically coherent, but also meets the user's needs for differentiated choices. This improves the user experience to a certain extent.

[0153] Finally, the dialogue system can generate more targeted answers based on the precise prompt selected by the user. Compared with the answers generated directly based on the original question, this method can better understand the user's true intention and provide a solution that better meets the needs.

[0154] In general, through the application of the method of the present invention, the dialogue system has made significant progress in improving service quality, enhancing user satisfaction, etc. This technical path based on semantic analysis, knowledge modeling, and prompt optimization provides a valuable reference solution for similar dialogue system applications.

[0155] Of course, in actual applications, further optimization and adjustment are needed for different scenarios. For example, we can consider combining the domain knowledge in the knowledge graph to make prompt generation and answer content more professional and detailed; we can also try to use reinforcement learning and other methods to continuously optimize system performance through interactive feedback with users.

[0156] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A method for obtaining a user's precise prompt, characterized in that: The following steps are involved: S10, obtaining questions raised by the user to the large language model as basic questions, and extracting semantic features of the basic questions; S20, performing synonym expansion, context association analysis, and domain knowledge supplementation according to the semantic features to obtain an augmented semantic feature set; S30, establishing an augmented semantic feature graph according to the augmented semantic feature set, wherein the nodes of the augmented semantic feature graph represent semantic concepts or keywords, and the edges represent semantic relationships or logical connections between nodes; S40, according to the context input by the user, using the large language model to analyze the user's intention and needs, identify key concepts and constraints, assign weights and prioritize nodes in the augmented semantic feature graph, and obtain a weighted semantic feature graph; S50, using a depth-first search algorithm for the weighted semantic feature graph to obtain multiple candidate paths of the weighted semantic feature graph; S60, generating a corresponding prompt according to each candidate path using a prompt generation algorithm based on the path, and combining each prompt with a pre-adjusted prompt generation question model to generate a question, obtain a question list and output it to the user; S70: Obtain the question selected by the user according to the question list as the selected question, and use the prompt corresponding to the selected question as the user's precise prompt.

2. A method for obtaining a user's precise prompt according to claim 1, characterized in that: The prompt question generation model is based on the large language model and is obtained by fine-tuning and training a large number of preset high-quality prompt-question pairs.

3. A method for obtaining a user's precise prompt according to claim 1, characterized in that: The semantic features of the basic question are extracted, which are specifically expressed as follows: ; In the formula, is the extracted semantic feature vector; For basic questions; For the feature extraction function; For the The weight of each feature; is the number of feature extraction functions; Embedding representation for the problem; is the weight coefficient of the embedding representation.

4. A method for obtaining a user's precise prompt according to claim 3, characterized in that: The steps of obtaining the augmented semantic feature set are specifically expressed as follows: ; In the formula, is the expanded semantic feature set; is the original semantic feature vector; Extension functions for synonyms; It is the context association analysis function; Supplement functions for domain knowledge; is the weight coefficient of each expansion method.

5. A method for obtaining a user's precise prompt according to claim 4, characterized in that: The augmented semantic feature graph is specifically expressed as follows: ; ; ; ; In the formula, To augment the semantic feature map; is a node set, corresponding to the expanded semantic features; is the edge set; is the edge weight matrix; For Node and The similarity function between is the similarity threshold.

6. A method for obtaining a user's precise prompt according to claim 5, characterized in that: The weighted semantic feature map is specifically expressed as follows: ; ; ; In the formula, is the weighted semantic feature map; is the new edge weight matrix; is matrix element-wise multiplication; To adjust the matrix; is the sigmoid function; For Node 's relevance score; For Node Importance score.

7. A method for obtaining a user's precise prompt according to claim 6, characterized in that: The depth-first search algorithm is specifically expressed as follows: ; ; In the formula, is a set of candidate paths; is the starting node; is the termination node; is the maximum path length; For Node The set of neighbor nodes.

8. The method for obtaining a user's precise prompt according to claim 7, characterized in that: The path-based prompt generation algorithm is specifically expressed as follows: ; In the formula, For the A prompt for candidate paths to be generated; For the candidate paths; Fill in the template with functions; is the coherence scoring function; is the diversity scoring function; is the weight coefficient.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and when the program instructions are executed in a computer, they are used to execute the method for obtaining a precise prompt from a user as described in any one of claims 1 to 8.

10. A system for obtaining accurate prompts from users, characterized in that: A computer-readable storage medium comprising the computer-readable storage medium of claim 9.

Citation Information

Patent Citations

  • Personalized image browsing and recommending method based on labelling semantics and system thereof

    CN102663010A

  • Top-k multi-request path planning method based on semantic perception

    CN109974732A

  • Method, device and equipment for generating chat reply based on dynamic Prompt and medium

    CN115599896A

  • Method and device for training generative large language model based on knowledge base feedback

    CN117009490A

  • Power file question and answer type intelligent retrieval method and system

    CN117171333A

Cited By

  • AI dialogue cue word optimization method and system

    CN121029959A