A method and system for optimizing AI dialogue prompts

By performing semantic segmentation and importance scoring on the prompt words of the AI ​​dialogue system, combined with knowledge graph expansion and multi-dimensional similarity assessment, diverse and grammatically correct candidate prompt words that conform to user intent are generated. This solves the problem of insufficient prompt word optimization in existing technologies and achieves efficient semantic relevance and grammatical rationality.

CN121029959BActive Publication Date: 2026-05-26JIANGXI RONG MEDIA BRAIN TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JIANGXI RONG MEDIA BRAIN TECHNOLOGY CO LTD
Filing Date
2025-10-31
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing AI dialogue system prompt word optimization methods rely on a single expansion strategy or a fixed template library, resulting in insufficient diversity of generated candidate prompt words. They cannot effectively balance semantic relevance and grammatical rationality, and the evaluation dimensions are too singular, which can easily deviate from the user's original intention or generate content that does not meet expectations.

Method used

By semantically segmenting and sorting the original prompt words, identifying key entity words and assigning importance scores and semantic relevance, and expanding upon them with knowledge graphs, the system utilizes a prompt word generation rule engine and text model to conduct multi-dimensional similarity evaluation, generating and fusing candidate prompt words that match the user's intent.

Benefits of technology

This ensures that the optimization process stays on topic, enriches the contextual information and semantic depth of the prompts, generates diverse and grammatically correct candidate prompts, and achieves a high degree of consistency and effectiveness between the optimization results and the user's intent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121029959B_ABST
    Figure CN121029959B_ABST
Patent Text Reader

Abstract

This invention discloses an AI dialogue prompt word optimization method and system. The method includes: inputting each candidate prompt word into a preset text model, the text model outputting candidate text corresponding to each candidate prompt word; determining a first semantic similarity between each candidate text and the original text of the original prompt word, and determining a second semantic similarity between each candidate text and the corresponding candidate prompt word; determining a target candidate prompt word set based on the first and second semantic similarities, and fusing each target candidate prompt word in the target candidate prompt word set with the original prompt word using preset optimization rules to obtain the final optimized target prompt word. This significantly improves the accuracy of prompt word optimization in AI dialogue.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing technology, and in particular relates to an AI dialogue prompt word optimization method and system. Background Technology

[0002] With the rapid development of artificial intelligence technology, especially the continuous progress in the field of Natural Language Processing (NLP), AI dialogue systems have been widely used in various fields. Users interact with AI systems by inputting natural language prompts, and the quality of these prompts directly affects the accuracy and relevance of the text generated by the AI. Therefore, optimizing prompts has become a key aspect of improving the performance of AI dialogue systems.

[0003] Currently, most existing suggestion word optimization methods are based on rule templates or simple keyword replacement, lacking a deep understanding of the user's original intent and semantic expansion. For example, some methods optimize suggestions only by adding synonyms or adjusting sentence structure, failing to fully consider the semantic relationships between key entities and their importance in the overall context. Furthermore, existing methods typically rely on a single expansion strategy or a fixed template library, resulting in insufficient diversity of generated candidate suggestions and an inability to effectively balance semantic relevance and grammatical correctness.

[0004] On the other hand, although some methods introduce semantic similarity evaluation mechanisms to filter generated results, their evaluation dimensions are relatively singular, failing to comprehensively consider the semantic consistency between the generated text and the original prompts, as well as the degree of matching between the generated text and the optimized prompts. This limitation can easily lead to optimized prompts deviating from the user's original intent, or generated content that does not meet expectations. Summary of the Invention

[0005] This invention provides an AI dialogue prompt word optimization method and system to solve the technical problem that usually relies on a single expansion strategy or a fixed template library, resulting in insufficient diversity of generated candidate prompt words and an inability to effectively balance semantic relevance and grammatical rationality.

[0006] In a first aspect, the present invention provides an AI dialogue prompt word optimization method, comprising:

[0007] Obtain the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence;

[0008] Based on the importance of each key entity word, the key entity word sequence is segmented using a preset partitioning strategy to obtain at least one key entity word subsequence. The at least one key entity word subsequence is then semantically expanded to obtain a set of associated entity words corresponding to the at least one key entity word subsequence.

[0009] The original prompt words and each set of associated entity words are input into a preset prompt word generation rule engine. The prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words. The prompt word generation rule engine has a variety of sentence structure templates pre-stored.

[0010] Each candidate prompt word is input into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word;

[0011] Determine the first semantic similarity between each candidate text and the original text of the original prompt word, and determine the second semantic similarity between each candidate text and the corresponding candidate prompt word;

[0012] Based on the first semantic similarity and the second semantic similarity, a set of target candidate prompt words is determined, and each target candidate prompt word in the set of target candidate prompt words is fused with the original prompt word using a preset optimization rule to obtain the final optimized target prompt word. The target candidate prompt word is the candidate prompt word among the candidate prompt words that meets the preset conditions.

[0013] Secondly, the present invention provides an AI dialogue prompt word optimization system, comprising:

[0014] The acquisition module is configured to acquire the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence;

[0015] The extension module is configured to segment the key entity word sequence based on the importance of each key entity word using a preset segmentation strategy to obtain at least one key entity word subsequence, and to perform semantic expansion on the at least one key entity word subsequence to obtain a set of associated entity words corresponding to the at least one key entity word subsequence.

[0016] The first output module is configured to input the original prompt words and each set of associated entity words into a preset prompt word generation rule engine, wherein the prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words, and wherein the prompt word generation rule engine has a variety of sentence structure templates pre-stored.

[0017] The second output module is configured to input each candidate prompt word into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word.

[0018] The determining module is configured to determine a first semantic similarity between each candidate text and the original text of the original prompt word, and to determine a second semantic similarity between each candidate text and the corresponding candidate prompt word;

[0019] The optimization module is configured to determine a set of target candidate prompt words based on the first semantic similarity and the second semantic similarity, and to fuse each target candidate prompt word in the set of target candidate prompt words with the original prompt words using a preset optimization rule to obtain the final optimized target prompt words, wherein the target candidate prompt words are the candidate prompt words among the candidate prompt words that meet the preset conditions.

[0020] Thirdly, an electronic device is provided, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the steps of the AI ​​dialogue prompt optimization method of any embodiment of the present invention.

[0021] Fourthly, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein when the program instructions are executed by a processor, the processor performs the steps of the AI ​​dialogue prompt word optimization method according to any embodiment of the present invention.

[0022] The AI ​​dialogue prompt optimization method and system of this application firstly, by semantically segmenting and sorting the original prompts, accurately identifies and focuses on the user's core intent, ensuring that the optimization process does not deviate from the topic; secondly, based on importance scores and semantic relevance, key entity words are intelligently grouped and used as a whole unit for semantic expansion with the help of knowledge graphs, effectively enriching the contextual information and semantic depth of the prompts, overcoming the semantic fragmentation problem caused by isolated keyword expansion in traditional methods; thirdly, through a preset prompt generation rule engine and grammatical role matching mechanism, candidate prompts with diverse sentence structures and grammatical correctness are generated, avoiding awkward splicing; in addition, a dual semantic similarity evaluation (similarity between candidate text and original text, and similarity between candidate text and corresponding prompts) is used for screening, ensuring that the optimization results simultaneously meet the dual standards of "faithfulness to the original meaning" and "effective guidance"; finally, a fusion strategy is dynamically selected based on the number of candidate results to intelligently generate refined final prompts. Attached Figure Description

[0023] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 A flowchart illustrating an AI dialogue prompt word optimization method provided in an embodiment of the present invention;

[0025] Figure 2 This is a structural block diagram of an AI dialogue prompt word optimization system provided in an embodiment of the present invention;

[0026] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0028] Please see Figure 1 The diagram shows a flowchart of an AI dialogue prompt optimization method according to this application.

[0029] like Figure 1 As shown, the AI ​​dialogue prompt word optimization method specifically includes the following steps:

[0030] Step S101: Obtain the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence.

[0031] In this step, after obtaining the original prompt words input by the user, a pre-trained part-of-speech tagging model is used to segment and tag the original prompt words, retaining nouns, verbs, adjectives and proper nouns, and filtering out stop words and punctuation marks to obtain a candidate vocabulary set;

[0032] Key entity words are identified from the candidate vocabulary set. Specifically, a pre-trained named entity recognition model is used to identify and extract key entity words of specific types, including personal names, place names, organization names, dates and times, and proprietary technical terms.

[0033] The key entity words are sorted according to the order in which they first appear in the original prompt words to obtain the key entity word sequence.

[0034] It should be noted that the pre-trained part-of-speech tagging model is a BERT model based on the Transformer architecture, a Conditional Random Field model, or a model from the spaCy or NLTK open-source toolkit. The named entity recognition model is a model based on the BiLSTM-CRF architecture or a model from the Stanford CoreNLP or spaCy open-source toolkit.

[0035] Step S102: Based on the importance of each key entity word, the key entity word sequence is segmented using a preset segmentation strategy to obtain at least one key entity word subsequence, and the at least one key entity word subsequence is semantically expanded to obtain a set of associated entity words corresponding to the at least one key entity word subsequence.

[0036] In this step, based on the importance of each key entity word, a preset segmentation strategy is used to segment the key entity word sequence to obtain at least one key entity word subsequence. The following steps are specifically executed:

[0037] Step S1021: Obtain the importance score of each key entity word in the key entity word sequence. The importance score is determined based on the inverse document frequency value of the key entity word or its grammatical role in the sentence.

[0038] In this embodiment, the importance score is determined based on the inverse document frequency (IVF) of key entity words. Specifically, the original prompt words are treated as a document, and the word frequency of the key entity words in the document is calculated. A large, pre-built corpus related to the AI ​​dialogue domain is used to calculate the inverse document frequency of the key entity words in the corpus. The word frequency and the inverse document frequency are multiplied to obtain the importance score.

[0039] Importance scores are determined based on the grammatical roles in a sentence. Specifically, a grammatical role weight mapping table is predefined, and fixed importance scores are assigned to common grammatical roles. Among them, grammatical roles include at least: subject, object, core predicate, attributive, and adverbial. The rules for assigning importance scores are as follows: the core predicate and subject have the highest importance scores, followed by the object, and then the attributive and adverbial.

[0040] Step S1022: Based on the importance score, remove key entity words in the key entity word sequence whose importance score is lower than the preset threshold, and retain the remaining key entity words in their original order to obtain the core sequence.

[0041] Step S1023: Determine the semantic relevance between the first key entity word and the second key entity word in the core sequence, and determine whether the semantic relevance is greater than the preset relevance threshold.

[0042] In this embodiment, the first key entity word and the second key entity word are converted into word vectors respectively, the cosine similarity between the two word vectors is calculated, and the value of the cosine similarity is used as the semantic relevance.

[0043] Step S1024: If the relevance is greater than the preset relevance threshold, the first key entity word and the second key entity word are divided into the same subsequence to obtain at least one key entity word sequence.

[0044] Step S1025: If the relevance is not greater than the preset relevance threshold, the first key entity word and the second key entity word are divided into different subsequences to obtain at least one key entity word subsequence.

[0045] Furthermore, semantic expansion is performed on at least one key entity word subsequence to obtain a set of associated entity words corresponding to the at least one key entity word subsequence. Specifically, the following steps are performed:

[0046] Multiple key entity words contained in a key entity subsequence are taken as a whole query unit and input into a preset knowledge graph model. The knowledge graph model outputs a related entity word that has a semantic relationship with the multiple key entity words.

[0047] In this embodiment, the knowledge graph model is trained based on the CN-Dbpedia network, the nceptNet network, or the Wikidat network. The training process involves inputting key entity words and their corresponding associated entity word labels into the CN-Dbpedia network to train the knowledge graph model. The training process is a conventional network training process, so it will not be described in detail here.

[0048] Determine the degree of association between a certain related entity word and each key entity word in a certain overall query unit, and determine a certain comprehensive degree of association between the certain related entity word and the query unit based on each degree of association;

[0049] In this embodiment, the expression for calculating the overall correlation degree is:

[0050] ,

[0051] In the formula, Score1, Score2, and Scoren represent the degree of association between a certain related entity word and the 1st, 2nd, and nth key entity words in a certain overall query unit, respectively; w1, w2, and wn are the weight coefficients set according to the importance scores of the key entity words corresponding to the related entity words; and N is the number of key entity words in a certain overall query unit.

[0052] Determine whether a certain comprehensive correlation degree is greater than a preset correlation degree threshold;

[0053] If the correlation degree is greater than a preset correlation threshold, then the certain related entity word is assigned to a certain related entity word set, wherein the certain related entity word set is the set of related entity words corresponding to the certain key entity subsequence;

[0054] If the correlation is not greater than the preset correlation threshold, then the associated entity word will be removed.

[0055] Step S103: Input the original prompt words and each set of associated entity words into a preset prompt word generation rule engine. The prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words. The prompt word generation rule engine has a variety of sentence structure templates pre-stored.

[0056] In this step, based on the grammatical structure of the original prompt word, a target sentence structure template corresponding to the original prompt word is selected from a preset sentence structure template library. The target sentence structure template is a target text frame containing fixed vocabulary and at least one replaceable slot.

[0057] It should be noted that dependency parsing is performed on the original prompt words to obtain their syntactic structure tree; the similarity between the syntactic structure tree and the example syntactic tree of each template in the template library is calculated; and one or more sentence structure templates with similarity higher than the threshold are selected.

[0058] Specifically, dependency parsing of the original prompt words is achieved by calling the dependency parsing functions in existing, well-known open-source NLP tool libraries (such as Stanford CoreNLP, spaCy, HanLP, and LTP).

[0059] Obtain all replaceable slots and the preset grammatical roles of each replaceable slot in the target sentence structure template;

[0060] Based on the matching results of the grammatical roles of each associated entity word in a certain set of associated entity words with the preset grammatical roles, each associated entity word is filled into the corresponding replaceable slot of the sentence structure template to generate at least one candidate prompt word.

[0061] Step S104: Input each candidate prompt word into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word.

[0062] In this step, the text model is obtained by training a neural network.

[0063] Step S105: Determine the first semantic similarity between each candidate text and the original text of the original prompt word, and determine the second semantic similarity between each candidate text and the corresponding candidate prompt word;

[0064] Step S106: Based on the first semantic similarity and the second semantic similarity, determine the target candidate prompt word set, and use a preset optimization rule to fuse each target candidate prompt word in the target candidate prompt word set with the original prompt word to obtain the final optimized target prompt word, wherein the target candidate prompt word is the candidate prompt word among the candidate prompt words that meets the preset conditions.

[0065] In this step, for each candidate suggestion word, its corresponding first semantic similarity S1 and second semantic similarity S2 are weighted and summed according to the following formula to obtain the comprehensive score:

[0066] ,

[0067] Where α and β are preset weighting coefficients, and ;

[0068] Sort all candidate prompts by their overall score from highest to lowest, and select the top K candidate prompts to form the target candidate prompt set, where K is an integer greater than or equal to 1.

[0069] Determine whether the number of target candidate prompts in the target candidate prompt set is greater than a preset threshold;

[0070] If the number is not greater than the preset threshold, then the target candidate prompt words in the target candidate prompt word set are directly defined as target prompt words;

[0071] If the number exceeds a preset threshold, the original prompt word and all target candidate prompt words in the target candidate prompt word set are input into the preset text fusion model. The text fusion model uses the original prompt word as the semantic basis, merges all target candidate prompt words, and generates the target prompt word.

[0072] In this embodiment, the text fusion model is an encoder-decoder model based on the Transformer architecture. Its encoder encodes both the original prompt word and all target candidate prompt words simultaneously, and its decoder generates the target text by fusing all encoded information based on a cross-attention mechanism.

[0073] When generating target prompts, the text fusion model uses a beam search algorithm and introduces a coverage mechanism during the decoding process to ensure that the generated target prompts can evenly cover the key semantic elements in the original prompts and the target candidate prompts set.

[0074] In summary, the method of this application can achieve the following technical effects:

[0075] 1. Structured decomposition and prioritization based on semantic understanding ensure that the optimization process closely follows the user's core intent:

[0076] By semantically segmenting and sorting the original prompts to obtain a sequence of key entity words, this method can accurately identify and focus on the most core elements in the user's query. This feature overcomes the shortcomings of traditional simple keyword replacement or template filling methods that ignore the importance and logical relationships between word elements, ensuring that all subsequent optimization operations revolve around the entities that users care about most, and preventing the optimization process from deviating from the core topic from the source;

[0077] 2. Through intelligent grouping and knowledge graph-driven semantic expansion, the contextual information of the prompt words is greatly enriched:

[0078] This invention does not expand each entity word in isolation. Instead, it segments the key entity word sequence into subsequences based on importance and semantic relevance, and then expands these subsequences as a whole unit. This method is fundamentally different from the traditional approach of "expanding each keyword individually and then simply combining them." It respects the inherent semantic relationships between entities (e.g., "Forbidden City" and "Beijing" should be expanded as a whole concept, not separately), and combines this with a knowledge graph model to obtain related entity words with high comprehensive relevance. This ensures that the expanded new content (e.g., "Hall of Supreme Harmony" and "Forbidden City") is highly relevant to the original intent and rich in context, thereby guiding AI to generate more information-rich and in-depth text.

[0079] 3. By using a rule engine and matching grammatical roles to generate candidate suggestion words, the diversity of generated sentence patterns and grammatical correctness are ensured:

[0080] The pre-defined prompt word generation rule engine embeds multiple sentence structure templates and selects the appropriate template based on the grammatical structure of the original prompt words. More importantly, when filling slots, it matches the grammatical roles of associated entity words with the pre-defined grammatical roles of the templates. This mechanism ensures that even when new entities are incorporated, the generated numerous candidate prompt words are rich and diverse in sentence structure (such as generating interrogative sentences, declarative sentences, task-oriented instructions, etc.) while maintaining correct and natural grammatical structure, avoiding awkward splicing and grammatical errors.

[0081] 4. A multi-dimensional similarity evaluation mechanism was used for screening, achieving both effectiveness and purpose. Figure 1 Double protection for consistency:

[0082] The filtering mechanism of this invention is not a single-dimensional process, but simultaneously calculates the first semantic similarity between the candidate text and the original text, as well as the second semantic similarity with the candidate prompt words. The first similarity ensures that the optimized result remains highly consistent with the user's original intent, preventing irrelevant answers; the second similarity assesses whether the generated prompt words can effectively guide the AI ​​to produce the expected content, verifying the effectiveness of the prompt words themselves. This dual evaluation system can accurately filter out the best prompt words from a massive candidate set that are both "faithful to the original meaning" and "efficient and powerful," significantly improving the reliability and usability of the optimization results.

[0083] 5. The final prompt words are generated through an intelligent fusion strategy, achieving an optimal balance between optimization efficiency and result quality:

[0084] The final optimization rule dynamically selects the fusion strategy based on the number of target candidate prompts. When there are few candidate words, the strategy is directly specified to ensure efficiency; when there are many candidate words, a text fusion model is invoked to perform intelligent fusion based on the semantics of the original prompts. This avoids problems such as verbose prompts and instruction conflicts caused by simply piling up all candidate words.

[0085] Please see Figure 2 The diagram shows a structural block diagram of an AI dialogue prompt word optimization system according to this application.

[0086] like Figure 2 As shown, the AI ​​dialogue prompt word optimization system 200 includes an acquisition module 210, an extension module 220, a first output module 230, a second output module 240, a determination module 250, and an optimization module 260.

[0087] The acquisition module 210 is configured to acquire the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence; the extension module 220 is configured to segment the key entity word sequence based on the importance of each key entity word using a preset segmentation strategy to obtain at least one key entity word subsequence, and perform semantic expansion on the at least one key entity word subsequence to obtain a set of associated entity words corresponding to the at least one key entity word subsequence; the first output module 230 is configured to input the original prompt words and each set of associated entity words into a preset prompt word generation rule engine, wherein the prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words, wherein the prompt word generation rule... The engine pre-stores various sentence structure templates; the second output module 240 is configured to input each candidate prompt word into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word; the determination module 250 is configured to determine the first semantic similarity between each candidate text and the original text of the original prompt word, and to determine the second semantic similarity between each candidate text and the corresponding candidate prompt word; the optimization module 260 is configured to determine a target candidate prompt word set based on the first semantic similarity and the second semantic similarity, and to fuse each target candidate prompt word in the target candidate prompt word set with the original prompt word using preset optimization rules to obtain the final optimized target prompt word, wherein the target candidate prompt word is the candidate prompt word among the candidate prompt words that meets the preset conditions.

[0088] It should be understood that Figure 2 The modules and references described in the document Figure 1 The steps described in the text correspond to those in the method described above. Therefore, the operations, features, and corresponding technical effects described above also apply to the method described in the text. Figure 2 The various modules in the document will not be described in detail here.

[0089] In other embodiments, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein when the program instructions are executed by a processor, the processor performs the AI ​​dialogue prompt word optimization method in any of the above method embodiments.

[0090] In one embodiment, the computer-readable storage medium of the present invention stores computer-executable instructions, which are configured as follows:

[0091] Obtain the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence;

[0092] Based on the importance of each key entity word, the key entity word sequence is segmented using a preset partitioning strategy to obtain at least one key entity word subsequence. The at least one key entity word subsequence is then semantically expanded to obtain a set of associated entity words corresponding to the at least one key entity word subsequence.

[0093] The original prompt words and each set of associated entity words are input into a preset prompt word generation rule engine. The prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words. The prompt word generation rule engine has a variety of sentence structure templates pre-stored.

[0094] Each candidate prompt word is input into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word;

[0095] Determine the first semantic similarity between each candidate text and the original text of the original prompt word, and determine the second semantic similarity between each candidate text and the corresponding candidate prompt word;

[0096] Based on the first semantic similarity and the second semantic similarity, a set of target candidate prompt words is determined, and each target candidate prompt word in the set of target candidate prompt words is fused with the original prompt word using a preset optimization rule to obtain the final optimized target prompt word. The target candidate prompt word is the candidate prompt word among the candidate prompt words that meets the preset conditions.

[0097] Computer-readable storage media may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application program required for at least one function; the data storage area may store data created based on the use of the AI ​​dialogue prompt optimization system, etc. Furthermore, the computer-readable storage medium may include high-speed random access memory, and may also include memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the computer-readable storage medium may optionally include memory remotely configured relative to a processor, which can be connected to the AI ​​dialogue prompt optimization system via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0098] Figure 3 This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present invention, such as... Figure 3As shown, the device includes a processor 310 and a memory 320. The electronic device may also include an input device 330 and an output device 340. The processor 310, memory 320, input device 330, and output device 340 can be connected via a bus or other means. Figure 3 Taking a bus connection as an example, the memory 320 is the computer-readable storage medium described above. The processor 310 executes various server functions and data processing by running non-volatile software programs, instructions, and modules stored in the memory 320, thereby implementing the AI ​​dialogue prompt optimization method described in the above embodiment. The input device 330 can receive input numeric or character information and generate key signal inputs related to user settings and function control of the AI ​​dialogue prompt optimization system. The output device 340 may include a display device such as a screen.

[0099] The aforementioned electronic device can execute the method provided in the embodiments of the present invention, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in this embodiment can be found in the method provided in the embodiments of the present invention.

[0100] In one implementation, the above-described electronic device is applied to an AI dialogue prompt optimization system for a client, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0101] Obtain the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence;

[0102] Based on the importance of each key entity word, the key entity word sequence is segmented using a preset partitioning strategy to obtain at least one key entity word subsequence. The at least one key entity word subsequence is then semantically expanded to obtain a set of associated entity words corresponding to the at least one key entity word subsequence.

[0103] The original prompt words and each set of associated entity words are input into a preset prompt word generation rule engine. The prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words. The prompt word generation rule engine has a variety of sentence structure templates pre-stored.

[0104] Each candidate prompt word is input into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word;

[0105] Determine the first semantic similarity between each candidate text and the original text of the original prompt word, and determine the second semantic similarity between each candidate text and the corresponding candidate prompt word;

[0106] Based on the first semantic similarity and the second semantic similarity, a set of target candidate prompt words is determined, and each target candidate prompt word in the set of target candidate prompt words is fused with the original prompt word using a preset optimization rule to obtain the final optimized target prompt word. The target candidate prompt word is the candidate prompt word among the candidate prompt words that meets the preset conditions.

[0107] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.

[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An AI conversation prompt word optimization method, characterized in that, include: Obtain the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence; Based on the importance of each key entity word, a preset segmentation strategy is used to segment the key entity word sequence to obtain at least one key entity word subsequence. Then, semantic expansion is performed on the at least one key entity word subsequence to obtain a set of associated entity words corresponding to the at least one key entity word subsequence. The segmentation strategy used to obtain at least one key entity word subsequence includes: Obtain an importance score for each key entity word in the key entity word sequence. The importance score is determined based on the inverse document frequency value of the key entity word or its grammatical role in the sentence. Based on the importance score, key entity words with an importance score lower than a preset threshold in the key entity word sequence are removed, and the remaining key entity words are retained in their original order to obtain the core sequence. Determine the semantic relevance between adjacent first key entity words and second key entity words in the core sequence, and determine whether the semantic relevance is greater than a preset relevance threshold; If the relevance is greater than a preset relevance threshold, the first key entity word and the second key entity word are divided into the same subsequence to obtain at least one key entity word subsequence. If the relevance is not greater than a preset relevance threshold, the first key entity word and the second key entity word are divided into different subsequences to obtain at least one key entity word subsequence. The original prompt words and each set of associated entity words are input into a preset prompt word generation rule engine. The prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words. The prompt word generation rule engine has a variety of sentence structure templates pre-stored. Each candidate prompt word is input into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word; Determine the first semantic similarity between each candidate text and the original prompt word, and determine the second semantic similarity between each candidate text and the corresponding candidate prompt word; Based on the first semantic similarity and the second semantic similarity, a set of target candidate prompt words is determined, and each target candidate prompt word in the set of target candidate prompt words is fused with the original prompt word using a preset optimization rule to obtain the final optimized target prompt word. The target candidate prompt word is the candidate prompt word among the candidate prompt words that meets the preset conditions.

2. The AI conversation prompt optimization method of claim 1, wherein, The semantic expansion of the at least one key entity word subsequence to obtain a set of associated entity words corresponding to the at least one key entity word subsequence includes: Multiple key entity words contained in a certain key entity word subsequence are taken as a whole query unit and input into a preset knowledge graph model. The knowledge graph model outputs a certain associated entity word that has a semantic relationship with the multiple key entity words. Determine the degree of association between a certain related entity word and each key entity word in a certain overall query unit, and determine a certain comprehensive degree of association between the certain related entity word and the query unit based on each degree of association; Determine whether a certain comprehensive correlation degree is greater than a preset correlation degree threshold; If the correlation degree is greater than a preset correlation threshold, then the certain related entity word is assigned to a certain related entity word set, wherein the certain related entity word set is the set of related entity words corresponding to the subsequence of the certain key entity word; If the correlation is not greater than the preset correlation threshold, then the associated entity word will be removed.

3. The AI ​​dialogue prompt word optimization method according to claim 1, characterized in that, The step of inputting the original prompt words and each set of associated entity words into a preset prompt word generation rule engine, wherein the prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words, including: Based on the grammatical structure of the original prompt word, a target sentence structure template corresponding to the original prompt word is selected from a preset sentence structure template library. The target sentence structure template is a target text frame containing fixed vocabulary and at least one replaceable slot. Obtain all replaceable slots and the preset grammatical roles of each replaceable slot in the target sentence structure template; Based on the matching results of the grammatical roles of each associated entity word in a certain set of associated entity words with the preset grammatical roles, each associated entity word is filled into the corresponding replaceable slot of the target sentence structure template to generate at least one candidate prompt word.

4. The AI ​​dialogue prompt word optimization method according to claim 1, characterized in that, The process of fusing each target candidate prompt word in the target candidate prompt word set with the original prompt words using preset optimization rules to obtain the final optimized target prompt words includes: Determine whether the number of target candidate prompts in the target candidate prompt set is greater than a preset number threshold; If the number is not greater than a preset threshold, then the target candidate prompt words in the target candidate prompt word set are directly defined as target prompt words; If the number exceeds a preset threshold, the original prompt word and all target candidate prompt words in the target candidate prompt word set are input into a preset text fusion model. The text fusion model uses the original prompt word as the semantic basis, fuses all target candidate prompt words, and generates the target prompt word.

5. An AI dialogue prompt word optimization system, characterized in that, include: The acquisition module is configured to acquire the original prompt words input by the user, perform semantic segmentation on the original prompt words to obtain at least one key entity word, and sort the at least one key entity word to obtain a key entity word sequence; The extension module is configured to segment the key entity word sequence based on the importance of each key entity word using a preset segmentation strategy to obtain at least one key entity word subsequence, and to perform semantic expansion on the at least one key entity word subsequence to obtain a set of associated entity words corresponding to the at least one key entity word subsequence. The segmentation of the key entity word sequence using the preset segmentation strategy to obtain at least one key entity word subsequence includes: Obtain an importance score for each key entity word in the key entity word sequence. The importance score is determined based on the inverse document frequency value of the key entity word or its grammatical role in the sentence. Based on the importance score, key entity words with an importance score lower than a preset threshold in the key entity word sequence are removed, and the remaining key entity words are retained in their original order to obtain the core sequence. Determine the semantic relevance between adjacent first key entity words and second key entity words in the core sequence, and determine whether the semantic relevance is greater than a preset relevance threshold; If the relevance is greater than a preset relevance threshold, the first key entity word and the second key entity word are divided into the same subsequence to obtain at least one key entity word subsequence. If the relevance is not greater than a preset relevance threshold, the first key entity word and the second key entity word are divided into different subsequences to obtain at least one key entity word subsequence. The first output module is configured to input the original prompt words and each set of associated entity words into a preset prompt word generation rule engine, wherein the prompt word generation rule engine outputs candidate prompt words corresponding to each set of associated entity words, and wherein the prompt word generation rule engine has a variety of sentence structure templates pre-stored. The second output module is configured to input each candidate prompt word into a preset text model, and the text model outputs candidate text corresponding to each candidate prompt word. The determining module is configured to determine a first semantic similarity between each candidate text and the original prompt word, and to determine a second semantic similarity between each candidate text and the corresponding candidate prompt word; The optimization module is configured to determine a set of target candidate prompt words based on the first semantic similarity and the second semantic similarity, and to fuse each target candidate prompt word in the set of target candidate prompt words with the original prompt words using a preset optimization rule to obtain the final optimized target prompt words, wherein the target candidate prompt words are the candidate prompt words among the candidate prompt words that meet the preset conditions.

6. An electronic device, characterized in that, include: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method described in any one of claims 1 to 4.