Enhanced prompt-based controllable reply generation method and apparatus, and storage medium
By extracting word-level features and generating large language models from historical texts of multi-turn dialogues, the problem of difficulty in ensuring the consistency of context attributes in reply generation in multi-turn dialogue scenarios is solved, and the user experience and emotional attribute control accuracy are improved.
Patent Information
- Application Number
- CN202410763060.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-10-08
AI Technical Summary
In a multi-turn dialogue scenario, it is difficult for the existing technology to ensure the consistency of the contextual attributes of reply generation, resulting in a decline in user experience.
By obtaining the historical text of multiple rounds of dialogue, word-level text feature extraction is performed, including features such as parts of speech, syllables, and modal particles, and a large language model is used to generate replies to ensure the contextual consistency of the replies.
The accuracy of controlling the emotional attributes of replies is improved, allowing replies to comply with predefined control attribute requirements, thereby improving user experience.
Smart Images

Figure CN118747526A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a controllable response generation method, device and storage medium based on enhanced prompts. Background Art
[0002] A multi-turn dialogue system is a computer program that can simulate human conversation behavior, interact with users through natural language, and complete specific tasks. Early multi-turn dialogue systems were mainly based on rule matching and template filling methods, which performed poorly in the face of complex and changing dialogue scenarios. With the development of deep learning technology, multi-turn dialogue systems based on neural networks have gradually become mainstream. This type of system can automatically learn the rules of dialogue from a large amount of dialogue data and generate responses that meet the context requirements.
[0003] In multi-round conversations, emotional factors have an important impact on the fluency of the conversation and the user experience. Controllable emotion generation technology refers to the technology that can automatically adjust the emotional attributes in the conversation according to the context of the conversation and the needs of the user. However, it is difficult to ensure the consistency of the context attributes generated by controllable responses in multi-round conversation scenarios, resulting in a decline in user experience. Summary of the invention
[0004] The present invention provides a controllable reply generation method, device and storage medium based on enhanced prompts, which are used to solve the technical problem of poor user experience in multi-round dialogue scenarios in the prior art.
[0005] In a first aspect, the present invention provides a controllable reply generation method based on enhanced prompts, comprising: Get multi-round conversation history text; Extracting word-level text features from the multiple rounds of conversation history texts to obtain word-level text features; A response is generated based on the word-level text features and the large language model.
[0006] In some embodiments, extracting word-level text features from the multi-round dialogue history texts to obtain word-level text features includes: Acquire word-level text features according to the parts of speech, syllable words, modal particles and / or idioms of the words in the multi-round dialogue history text; the word-level text features include one or more of the following: A first text feature; the first text feature is used to characterize the part-of-speech information in the multi-round dialogue history text; A second text feature; the second text feature is used to characterize the syllable information in the multi-round dialogue history text; The third text feature: The third text feature is used to characterize the modal particle information and idiom information in the multi-round dialogue history text.
[0007] In some embodiments, the acquiring word-level text features according to the parts of speech of the words in the multi-round dialogue history texts includes: Performing part-of-speech classification on words in the multi-round dialogue history texts to obtain part-of-speech distribution corresponding to the multi-round dialogue history texts; The part-of-speech category with the highest part-of-speech probability in the part-of-speech distribution is used as the first text feature.
[0008] In some embodiments, the acquiring word-level text features according to the syllable words in the multi-round dialogue history text includes: Performing syllable classification on the words in the multi-round dialogue history text; the types of syllables include monosyllables and polysyllables; The most frequently appearing monosyllabic words and the most frequently appearing polysyllabic words in the multi-round dialogue history texts are used as second text features.
[0009] In some embodiments, the acquiring word-level text features according to the modal particles and idioms in the multi-round dialogue history texts includes: Using a modal particle library and an idiom library to perform regular matching on words in the multi-round dialogue history texts, to obtain the modal particles and idioms that appear most frequently in the multi-round dialogue history texts; The modal particles and idioms that appear most frequently in the multi-round dialogue history texts are used as the third text features.
[0010] In some embodiments, generating a response based on the word-level text features and the large language model includes: Convert the word-level text features into natural language form to obtain prompts; A response is generated based on the prompt and utilizing a large language model.
[0011] In some embodiments, the method further comprises: In the case that the attributes of the reply are inconsistent with the predefined attributes, the prompt is modified, and the reply is updated using the large language model based on the modified prompt until the attributes of the updated reply meet the predefined attributes.
[0012] In a second aspect, the present invention provides a controllable reply generation device based on enhanced prompts, comprising: The acquisition module is used to obtain the historical text of multiple rounds of dialogues; A feature extraction module, used to extract word-level text features from the multi-round dialogue history texts to obtain word-level text features; A reply generation module is used to generate a reply based on the word-level text features and the large language model.
[0013] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for generating a controllable reply based on enhanced prompts as described in the first aspect above is implemented.
[0014] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the controllable response generation method based on enhanced prompts as described in the first aspect above.
[0015] In a fifth aspect, the present invention further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the controllable response generation method based on enhanced prompts as described in the first aspect above.
[0016] The controllable reply generation method, device and storage medium based on enhanced prompts provided by the present invention obtain multi-round dialogue history texts; extract word-level text features from the multi-round dialogue history texts to obtain word-level text features; and generate replies based on the word-level text features and a large language model. Based on these word-level text features, a large language model can be used to generate replies with higher consistency in contextual text features, improve the accuracy of emotional attribute control of generated replies, and enable replies to meet predefined control attribute requirements, thereby improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a flow chart of the controllable reply generation method based on enhanced prompts provided by the present invention.
[0019] Figure 2 It is a structural schematic diagram of a controllable reply generation device based on enhanced prompts provided by the present invention.
[0020] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0021] By using the emotion controllable generation technology, the dialogue system can have the following capabilities: Improve the coherence of the conversation: In a multi-round conversation, emotional consistency is crucial to the coherence of the conversation. Emotional controllable generation technology can automatically adjust the expression of emotions according to the context of the conversation, making the conversation more natural and smooth.
[0022] Improve user experience: In multi-round conversations, users often hope that the dialogue system can understand their emotional needs and give appropriate responses. Emotionally controllable generation technology can generate responses that meet user expectations based on user emotional needs, thereby improving user experience.
[0023] Enhance the personalization of the dialogue system: Different users may have different emotional preferences. Emotion-controllable generation technology can generate personalized responses based on the user's emotional preferences to meet the user's needs.
[0024] Improve the intelligence of the dialogue system: Emotion is an important part of human intelligence. Emotion controllable generation technology can enable the dialogue system to have emotion recognition and processing capabilities, thereby improving the intelligence of the dialogue system.
[0025] However, the consistency of the contextual text features generated by the current controllable replies is difficult to ensure, and the accuracy of the emotional attribute control of the reply generation is also low.
[0026] Based on the above technical problems, the present invention proposes a controllable reply generation method based on enhanced prompts, first obtaining multi-round dialogue history texts, extracting word-level text features from the multi-round dialogue history texts, obtaining word-level text features, and then generating replies based on the word-level text features and a large language model. Based on these word-level text features, a large language model can be used to generate replies with higher context consistency, improve the accuracy of emotional attribute control of generated replies, and enable replies to meet predefined control attribute requirements, thereby improving user experience.
[0027] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] Figure 1 is a flow chart of a controllable reply generation method based on enhanced prompts provided by the present invention, such as Figure 1 As shown, the present invention provides a controllable reply generation method based on enhanced prompts. The method includes the following steps 101 and 102.
[0029] Step 101: Obtain multi-round conversation history texts.
[0030] Specifically, we collect multi-round conversation history texts on social media as a multi-round conversation dataset.
[0031] In the embodiment of the present application, data preprocessing is also performed on the collected multi-round dialogue history texts to obtain data forms that can be used for training and testing.
[0032] Optionally, preprocessing of the multi-round conversation history texts includes operations such as deduplication, advertisement and sensitive word filtering, and / or language filtering.
[0033] Step 102: extract word-level text features from the multi-round dialogue history texts to obtain word-level text features.
[0034] Specifically, words are the basis of text and play a vital role in shaping language features. We perform quantitative analysis on words in multi-round dialogue history texts to extract text features, and extract features from multi-round dialogue history texts from the word-level dimension to obtain word-level text features.
[0035] For example, analyze the part of speech of each word in the history text of multiple rounds of dialogues and extract text features related to the part of speech; or analyze the syllable words in the history text of multiple rounds of dialogues and extract text features related to the syllables of the words; or analyze the modal particles in the history text of multiple rounds of dialogues and extract text features related to the modal particles; or analyze the idioms in the history text of multiple rounds of dialogues and extract text features related to the idioms.
[0036] Step 103: Generate a response based on the word-level text features and the large language model.
[0037] Specifically, a large language model is used in combination with extracted word-level text features to generate responses.
[0038] In some embodiments, a response is generated based on the word-level text features and the large language model. Specifically, the word-level text features can be converted into a natural language form to obtain a prompt; and a response is generated based on the prompt and using the large language model.
[0039] Specifically, after obtaining word-level text features, the word-level text features are converted into natural language form to obtain prompts that are easy for the large language model to understand. Based on the prompts constructed from the word-level text features, the large model can generate context-consistent responses.
[0040] For example, features such as parts of speech, syllables, modal particles, and idioms are extracted from the historical texts of multiple rounds of conversations. Based on linguistic theory, these features are converted into natural language to generate prompts, and the large model generates responses based on these prompts.
[0041] The controllable reply generation method based on enhanced prompts provided in the embodiment of the present application uses a text feature extraction module to extract word-level text features of multiple rounds of dialogue history. Based on these word-level text features, it helps the large model to generate context-consistent replies, improves the accuracy of emotional attribute control of generated replies, and enables the replies to meet predefined control attribute requirements, thereby improving the user experience.
[0042] In some embodiments, extracting word-level text features from the multi-round dialogue history texts to obtain word-level text features includes: Acquire word-level text features according to the parts of speech, syllable words, modal particles and / or idioms of the words in the multi-round dialogue history text; the word-level text features include one or more of the following: A first text feature; the first text feature is used to characterize the part-of-speech information in the multi-round dialogue history text; A second text feature; the second text feature is used to characterize the syllable information in the multi-round dialogue history text; The third text feature: The third text feature is used to characterize the modal particle information and idiom information in the multi-round dialogue history text.
[0043] Specifically, the text features of multi-round dialogue history texts are deeply analyzed from multiple perspectives such as part of speech, syllable words, modal particles and idioms, and the word-level text features obtained include first text features, second text features and third text features.
[0044] Among them, the word parts of speech in the multi-round dialogue history text are analyzed to obtain a first text feature for characterizing the word part information in the multi-round dialogue history text. The syllable words in the multi-round dialogue history text are analyzed to obtain a second text feature for characterizing the syllable information in the multi-round dialogue history text. The modal particles and idioms in the multi-round dialogue history text are analyzed to obtain a third text feature for characterizing the modal particle information and idiom information in the multi-round dialogue history text.
[0045] In some embodiments, the acquiring word-level text features according to the parts of speech of the words in the multi-round dialogue history texts includes: Performing part-of-speech classification on words in the multi-round dialogue history texts to obtain part-of-speech distribution corresponding to the multi-round dialogue history texts; The part-of-speech category with the highest part-of-speech probability in the part-of-speech distribution is used as the first text feature.
[0046] Specifically, the word parts of speech are divided into content words and function words. Content words include nouns, verbs, adjectives and adverbs, and function words include prepositions and conjunctions, etc. Parts of speech analysis is performed on words in multi-round dialogue history texts, that is, the words are classified into parts of speech to obtain the part-of-speech distribution corresponding to the multi-round dialogue history texts.
[0047] Optionally, use the natural language toolkit NLTK to perform part-of-speech analysis on words in the multi-turn dialogue history text.
[0048] After obtaining the part-of-speech distribution, the part-of-speech category with the highest probability in the part-of-speech distribution is determined, and the part-of-speech category is used as the first text feature.
[0049] For example, the word sequence in the multi-round dialogue history text is represented as W = {w1, w2, ..., w i , w n}, where L represents the total number of words in the multi-round dialogue history text; the word part-of-speech tag is L = {l1, l2, ..., l i , l n By classifying and counting words, we can analyze the distribution of parts of speech. ps : d ps =argmax(Count ps (w i , l i ))
[0050] Among them, Count ps is a statistical function used to count the number of words in each part-of-speech tag. Then the word type with the highest part-of-speech probability is selected as the part-of-speech feature, i.e., the first text feature.
[0051] In some embodiments, the acquiring word-level text features according to the syllable words in the multi-round dialogue history text includes: The words in the multi-round dialogue history text are classified into syllable types; the types of syllables include monosyllables and polysyllables; and the most frequently appearing monosyllable words and the most frequently appearing polysyllable words in the multi-round dialogue history text are used as second text features.
[0052] Specifically, the number of syllables is often used to calculate the readability score of a text. Longer syllable words tend to increase the complexity of the text, which may make the text more difficult to read and understand. The number of syllables is one of the important text features. Syllable classification is performed on words in multi-round dialogue history texts to distinguish whether each word is a monosyllabic word or a polysyllabic word.
[0053] Optionally, the number of syllables in the words is analyzed using the Natural Language Toolkit NLTK to distinguish monosyllabic words from polysyllabic words.
[0054] After analyzing the syllables of the words, the most frequently occurring monosyllabic words and the most frequently occurring polysyllabic words are used as the second text features.
[0055] For example, the set of monosyllabic words in the words in the multi-round dialogue history text is S single, the set of polysyllabic words is S multi . Statistics of the most common monosyllabic words and the most frequent Top K multi Polysyllabic words ( TopK multi is a positive integer), and use and d multi express:
[0056] in, Indicates one or more monosyllabic words with the highest frequency; d multi Indicates one or more polysyllabic words with the highest frequency of occurrence; the argTopK() function is used to obtain the value of the variable when freq() reaches the maximum value; freq(·) is a function used to count word frequencies. and d multi As a second text feature.
[0057] In some embodiments, the acquiring word-level text features according to the modal particles and idioms in the multi-round dialogue history texts includes: Using the modal particle library and the idiom library to perform regular matching on the words in the multi-round dialogue history text, to obtain the modal particles and idioms that appear most frequently in the multi-round dialogue history text; The modal particles and idioms that appear most frequently in the multi-round dialogue history texts are used as the third text features.
[0058] Specifically, the modal particle library and idiom library are used to perform regular matching on the words in the multi-round dialogue history text to extract the TopP words with the highest frequency. modal modal particles and TopP idom Idioms as text features (TopP modal 、TopP idom is a positive integer), and use d modal and d idom express: d modal =argTopP modal {freq(Re(Wi,S modal ))} d idom =argTopP idom {freq(Re(Wi,S idom ))}
[0059] Among them, d modal Indicates one or more modal particles that appear most frequently; d idomIndicates one or more idioms with the highest frequency; the argTopP() function is used to obtain the value of the variable when freq() reaches the maximum value; S modal and S idom Represent the modal particle library and idiom library respectively, Re(·) represents regular matching; Wi represents the i-th word in the word sequence of the multi-round dialogue history text. modal and d idom As a third text feature.
[0060] After obtaining all sub-features, integrate these sub-features to obtain the word-level feature set d word : d word =concat(d ps ,d single ,d multi ,d modal ,d idom )
[0061] Among them, the concat function is a concatenation function. The obtained d word That is the final word-level text feature.
[0062] The controllable response generation method based on enhanced prompts provided in the embodiment of the present application performs word-level text feature extraction on multi-round dialogue history texts, extracts features including parts of speech, syllable words, modal particles, and idioms, and interacts with a large language model based on these features, thereby improving the large language model's ability to understand text and generating responses that are consistent with contextual text features.
[0063] In some embodiments, the method further comprises: In the case that the attributes of the reply are inconsistent with the predefined attributes, the prompt is modified, and the reply is updated using the large language model based on the modified prompt until the attributes of the updated reply meet the predefined attributes.
[0064] Specifically, after the first round of conversation with the large language model using prompts with strong text features, the large language model can generate a response based on the prompt requirements. However, even if accurate instructions have been given in the prompt, the large language model may still generate a response that does not meet the attribute requirements. To address this issue, after the large language model generates a response, it also performs attribute judgment and feedback on the response.
[0065] When the attributes of the reply are inconsistent with the predefined attributes, modify or adjust the prompt language constructed based on the word-level text features, and regenerate the reply based on the modified prompt language using the large language model, repeat the judgment operation, prompt language adjustment operation and reply update operation until it is judged that the attributes of the newly generated reply are consistent with the predefined attributes.
[0066] Optionally, due to the lack of domain-specific knowledge and specialized optimization of downstream task objectives, the performance of large language models in downstream tasks such as sentiment analysis is weaker than that of dedicated sentiment analysis models. Therefore, in order to give full play to the general text understanding and generation capabilities of large language models and the excellent performance of task-specific models on downstream tasks, an advanced sentiment analysis model RoBERTa-Senti is used to provide feedback to the large language model to improve the attribute control accuracy of the large language model. The RoBERTa-Senti model is based on the RoBERTa architecture, trained on a large amount of data, and fine-tuned for sentiment analysis based on the TweetEval benchmark. It is a widely used and competitive sentiment analysis model.
[0067] For example, the sentiment analysis model RoBERTa-Senti is used to perform sentiment analysis on the generated responses, and the analysis results are fed back to the multi-round dialogue prompt adjustment module to adjust the dialogue prompts in a timely manner to improve the attribute accuracy of the responses generated by the large language model. The feedback-based prompt adjustment module compares the analysis results of the RoBERTa-Senti sentiment analysis model with the given sentiment attribute constraints to determine whether the sentiment attribute of the generated response is consistent with the given sentiment attribute. If not, the prompt is adjusted for multiple rounds of dialogue until the attribute constraints are met.
[0068] The controllable reply generation method based on enhanced prompts provided in the embodiment of the present application determines whether the attributes of the generated reply are consistent with the predefined attributes and provides feedback prompts. For replies that are inconsistent with the predefined control attributes, the prompt words are modified based on the feedback results. The modified prompt words prompt the large language model to generate replies that meet the requirements of the predefined control attributes, thereby further improving the accuracy of attribute control and improving the user experience.
[0069] Figure 2 is a schematic diagram of the structure of a controllable reply generation device based on enhanced prompts provided by the present invention, such as Figure 2 As shown, the present invention provides a controllable reply generation device based on enhanced prompts, including an acquisition module 201, a feature extraction module 202 and a reply generation module 203.
[0070] The acquisition module 201 is used to acquire multi-round dialogue history texts.
[0071] The feature extraction module 202 is used to extract word-level text features from the multi-round dialogue history texts to obtain word-level text features.
[0072] The reply generation module 203 is used to generate a reply based on the word-level text features and the large language model.
[0073] In some embodiments, the feature extraction module includes: A word-level text feature acquisition unit is used to acquire word-level text features according to the part of speech, syllable words, modal particles and / or idioms of the words in the multi-round dialogue history text; the word-level text features include one or more of the following: A first text feature; the first text feature is used to characterize the part-of-speech information in the multi-round dialogue history text; A second text feature; the second text feature is used to characterize the syllable information in the multi-round dialogue history text; The third text feature: The third text feature is used to characterize the modal particle information and idiom information in the multi-round dialogue history text.
[0074] In some embodiments, the word level text feature acquisition unit includes: A part-of-speech classification subunit is used to perform part-of-speech classification on words in the multi-round dialogue history text to obtain a part-of-speech distribution corresponding to the multi-round dialogue history text; The first text feature determination subunit is configured to use the part-of-speech category with the highest part-of-speech probability in the part-of-speech distribution as the first text feature.
[0075] In some embodiments, the word level text feature acquisition unit further includes: A syllable classification subunit, used for syllable classification of words in the multi-round dialogue history text; the types of syllables include monosyllables and polysyllables; The second text feature determination subunit is used to use the most frequently appearing monosyllabic words and the most frequently appearing polysyllabic words in the multi-round dialogue history text as the second text feature.
[0076] In some embodiments, the word level text feature acquisition unit further includes: A regular matching subunit, used to perform regular matching on words in the multi-round dialogue history texts using a modal particle library and an idiom library, to obtain the modal particles and idioms that appear most frequently in the multi-round dialogue history texts; The third text feature determination subunit is used to take the modal particles and idioms that appear most frequently in the multi-round dialogue history texts as the third text feature.
[0077] In some embodiments, the reply generation module includes: A prompt acquisition unit, used for converting the word-level text features into a natural language form to obtain a prompt; The response generation unit is used to generate a response based on the prompt and using a large language model.
[0078] In some embodiments, the reply generation module further includes: The reply adjustment unit is used to modify the prompt language when the attributes of the reply are inconsistent with the predefined attributes, and update the reply using the large language model based on the modified prompt language until the attributes of the updated reply meet the predefined attributes.
[0079] Specifically, the above-mentioned controllable response generation device based on enhanced prompts provided by the present invention can implement all the method steps implemented by the above-mentioned controllable response generation method embodiment based on enhanced prompts, and can achieve the same technical effect. The parts and beneficial effects that are the same as the method embodiment in this embodiment will not be described in detail here.
[0080] It should be noted that the division of units / modules in the above-mentioned embodiments of the present invention is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional units in the various embodiments of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software functional units.
[0081] Figure 3 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 3 As shown, the electronic device may include: a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302 and the memory 303 communicate with each other through the communication bus 304. The processor 301 may call the logic instructions in the memory 303 to execute a controllable reply generation method based on enhanced prompts, the method comprising: Get multi-round conversation history text; Extracting word-level text features from the multiple rounds of conversation history texts to obtain word-level text features; A response is generated based on the word-level text features and the large language model.
[0082] Specifically, the processor 301 can be a central processing unit (CPU), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or a complex programmable logic device (CPLD), and the processor can also adopt a multi-core architecture.
[0083] The logic instructions in the memory 303 can be implemented in the form of software functional units and can be stored in a processor-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0084] In some embodiments, a computer program product is further provided, the computer program product comprising a computer program, the computer program may be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer can execute the controllable response generation method based on enhanced prompts provided in the above-mentioned method embodiments, the method comprising: Get multi-round conversation history text; Extracting word-level text features from the multiple rounds of conversation history texts to obtain word-level text features; A response is generated based on the word-level text features and the large language model.
[0085] Specifically, the above-mentioned computer program product provided in the embodiment of the present application can implement all the method steps implemented by the above-mentioned method embodiments, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.
[0086] In some embodiments, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program is used to enable a computer to execute the controllable response generation method based on enhanced prompts provided in the above-mentioned method embodiments, the method comprising: Get multi-round conversation history text; Extracting word-level text features from the multiple rounds of conversation history texts to obtain word-level text features; A response is generated based on the word-level text features and the large language model.
[0087] Specifically, the above-mentioned computer-readable storage medium provided by the present invention can implement all the method steps implemented by the above-mentioned method embodiments, and can achieve the same technical effects. The parts and beneficial effects that are the same as the method embodiments in this embodiment will not be described in detail here.
[0088] It should be noted that the computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.
[0089] It should also be noted that the terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first" and "second" are usually of the same type, and the number of objects is not limited. For example, the first object can be one or more.
[0090] In the present invention, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0091] In the present invention, the term "plurality" refers to two or more than two, and other quantifiers are similar to them.
[0092] In the present invention, "determine B based on A" means that the factor A should be considered when determining B. It is not limited to "B can be determined based on A alone", but should also include: "determine B based on A and C", "determine B based on A, C and E", "determine C based on A, and further determine B based on C", etc. In addition, it can also include taking A as a condition for determining B, for example, "when A meets the first condition, use the first method to determine B"; for another example, "when A meets the second condition, determine B", etc.; for another example, "when A meets the third condition, determine B based on the first parameter", etc. Of course, it can also be a condition that takes A as a factor for determining B, for example, "when A meets the first condition, use the first method to determine C, and further determine B based on C", etc.
[0093] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0094] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer executable instructions. These computer executable instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0095] These processor executable instructions may also be stored in a processor readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the processor readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0096] These processor-executable instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0097] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A controllable response generation method based on enhanced prompts, characterized in that: include: Get multi-round conversation history text; Extracting word-level text features from the multiple rounds of conversation history texts to obtain word-level text features; A response is generated based on the word-level text features and the large language model.
2. The controllable response generation method based on enhanced prompts according to claim 1 is characterized in that: The extracting word-level text features of the multi-round dialogue history texts to obtain word-level text features includes: Acquire word-level text features according to the parts of speech, syllable words, modal particles and / or idioms of the words in the multi-round dialogue history text; the word-level text features include one or more of the following: A first text feature; the first text feature is used to characterize the part-of-speech information in the multi-round dialogue history text; A second text feature; the second text feature is used to characterize the syllable information in the multi-round dialogue history text; The third text feature: The third text feature is used to characterize the modal particle information and idiom information in the multi-round dialogue history text.
3. The controllable reply generation method based on enhanced prompts according to claim 2 is characterized in that: The acquiring word-level text features according to the parts of speech of the words in the multi-round dialogue history texts includes: Performing part-of-speech classification on words in the multi-round dialogue history texts to obtain part-of-speech distribution corresponding to the multi-round dialogue history texts; The part-of-speech category with the highest part-of-speech probability in the part-of-speech distribution is used as the first text feature.
4. The controllable response generation method based on enhanced prompts according to claim 2 is characterized in that: The acquiring word-level text features according to the syllable words in the multi-round dialogue history texts includes: The words in the multi-round dialogue history text are classified into syllable types; the types of syllables include monosyllables and polysyllables; and the most frequently appearing monosyllable words and the most frequently appearing polysyllable words in the multi-round dialogue history text are used as second text features.
5. The controllable response generation method based on enhanced prompts according to claim 2 is characterized in that: The acquiring word-level text features according to the modal particles and idioms in the multi-round dialogue history texts includes: Using a modal particle library and an idiom library to perform regular matching on words in the multi-round dialogue history texts, to obtain the modal particles and idioms that appear most frequently in the multi-round dialogue history texts; The modal particles and idioms that appear most frequently in the multi-round dialogue history texts are used as the third text features.
6. The controllable reply generation method based on enhanced prompting according to claim 1, characterized in that: The generating a response based on the word-level text features and the large language model comprises: Convert the word-level text features into natural language form to obtain prompts; A response is generated based on the prompt and utilizing a large language model.
7. The controllable reply generation method based on enhanced prompts according to claim 6 is characterized in that: The method further comprises: In the case that the attributes of the reply are inconsistent with the predefined attributes, the prompt is modified, and the reply is updated using the large language model based on the modified prompt until the attributes of the updated reply meet the predefined attributes.
8. A controllable reply generation device based on enhanced prompts, characterized in that: include: The acquisition module is used to obtain the historical text of multiple rounds of dialogues; A feature extraction module, used to extract word-level text features from the multi-round dialogue history texts to obtain word-level text features; A reply generation module is used to generate a reply based on the word-level text features and the large language model.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the controllable response generation method based on enhanced prompts as described in any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the controllable response generation method based on enhanced prompts as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Emotion-based multi-round dialogue model and dialogue method
CN116701566A
Anthropomorphic dialogue method and device based on natural language model and electronic equipment
CN117493529A
