Question and answer pair generation method and device, electronic equipment and storage medium
By obtaining chat data from the chat interface, performing intent recognition and clustering, and generating question-answer pairs, the problem of low efficiency in manually writing question-answer pairs is solved, and automated and efficient question-answer pair generation is achieved.
Patent Information
- Application Number
- CN202510537550.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-09-16
AI Technical Summary
In the existing technology, manual writing of question and answer pairs is inefficient and requires high experience of technical personnel, resulting in low generation efficiency.
By obtaining chat data from the chat interface, performing intent recognition and clustering, and generating question-answer pairs, including invalid word filtering, non-text dialogue conversion, intent vector recognition and clustering, using text intent recognition model and rule template matching, combined with historical question-answer database and value assessment.
It realizes the automatic extraction of conversation text from chat data and the automatic generation of question-answer pairs, which improves the generation efficiency, reduces the manual workload, and improves the accuracy and efficiency of question-answer pairs.
Smart Images

Figure CN120653726A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for generating question and answer pairs. Background Art
[0002] In recent years, large language models have received widespread attention and application in the field of natural language processing. The application of intelligent question-answering systems using large model languages has also become increasingly widespread. Intelligent question-answering systems give corresponding answers to questions raised by users in the form of questions and answers.
[0003] Intelligent question-answering systems require a large number of question-answer pairs for training. Currently, most question-answer pairs are manually written. Different fields require technical personnel from different fields to write question-answer pairs. Moreover, the accuracy of the technical personnel's writing of question-answer pairs directly affects the accuracy of the intelligent question-answering system's answers. This requires a high level of experience for technical personnel in a single field and may even increase the manual calibration process, which consumes a lot of manual workload and leads to low efficiency in question-answer pair generation. Summary of the Invention
[0004] The present invention provides a question-answer pair generation method, device, electronic device and storage medium to solve the problem of low efficiency of manually writing question-answer pairs in the prior art.
[0005] The present invention provides a question-answer pair generation method, comprising the following steps: Acquire chat data from the chat interface, wherein the chat data includes multiple conversation texts; Performing intent recognition on each conversation text in the chat data to obtain an intent vector corresponding to each conversation text, wherein the intent vector is used to characterize the conversation content and text type of each conversation text, wherein the text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text; The conversation content and text type of each of the intent vectors are clustered to generate question-answer pairs.
[0006] According to a question-answer pair generation method provided by the present invention, chat data is obtained from a chat interface, comprising: Each conversation text in the chat interface is traversed, the currently traversed conversation text is matched with invalid words in the invalid word database, and the conversation text that fails to match is retained to form the chat data.
[0007] According to a question-answer pair generation method provided by the present invention, before traversing each dialogue text in the chat interface, the method further includes: Extracting non-text conversations in the chat interface, wherein the non-text conversations include at least one of voice, pictures, and web page references; The voice, picture and web page reference are converted into a conversation text, and the converted conversation text is assigned a timestamp corresponding to the voice, picture and web page reference.
[0008] According to a question-answer pair generation method provided by the present invention, a web page reference is converted into a conversation text, comprising: Acquire at least one conversation text before the web page references it in descending order of the timestamps; Using entity recognition technology to extract entity keywords from at least one conversation text before the webpage reference; The text content containing the entity keyword in the page corresponding to the web page reference is used as the dialogue text after the web page reference is converted.
[0009] According to a question-answer pair generation method provided by the present invention, intent recognition is performed on each dialogue text in the chat data to obtain an intent vector corresponding to each dialogue text, including: Each dialogue text is input into a text intent recognition model to obtain an intent vector corresponding to each dialogue text output by the text intent recognition model, wherein the text intent recognition model is trained based on sample dialogue texts and corresponding intent vector labels, and the intent vector labels are used to characterize the dialogue content and text type of the sample dialogue text, and are used to determine the sample question type of the question text when the text type is a question text.
[0010] According to a question-answer pair generation method provided by the present invention, intent recognition is performed on each dialogue text in the chat data to obtain an intent vector corresponding to each dialogue text, including: Matching each dialogue text with a rule template representing an intent vector, wherein the rule template defines the text type of the dialogue text template and the corresponding question type when the dialogue text template is a question text template; If the match is successful, the text type of the text template is assigned to the text type of the successfully matched dialogue text, and if the text type is a question text, the question type of the question text template is assigned to the question type of the successfully matched dialogue text; In the event of a match failure, each conversation text is input into a text intent recognition model to obtain an intent vector corresponding to each conversation text output by the text intent recognition model; Among them, the text intent recognition model is trained based on sample conversation text and corresponding intent vector labels. The intent vector labels are used to characterize the conversation content and text type of the sample conversation text, and are used to determine the sample question type of the question text when the text type is question text.
[0011] According to a question-answer pair generation method provided by the present invention, after clustering the conversation content and text type of each intention vector to generate a question-answer pair, the method further includes: For any question-answer pair, the question text of the question-answer pair is compared with the historical question-answer pairs in the historical question-answer database for similarity. If the similarity is greater than the similarity threshold, the number of occurrences of the historical question-answer pair is increased by 1; otherwise, the question-answer pair is added to the historical question-answer database.
[0012] According to a question-answer pair generation method provided by the present invention, after clustering the conversation content and text type of each intention vector to generate a question-answer pair, the method further includes: For any question-answer pair, obtain a frequency index of any question-answer pair, wherein the frequency index includes the frequency of occurrence of the question-answer pair in the historical question-answer database and the conversation repetition rate of the question text of the question-answer pair in the chat interface; For any question-answer pair, obtain user evaluation indicators for the question-answer pair, wherein the user evaluation indicators include satisfaction and conversion rate of user evaluations of the question-answer pair in a historical question-answer database; The value assessment score of any question-answer pair is calculated based on the frequency index, user evaluation index and their respective index weights.
[0013] The present invention also provides a question-answer pair generating device, comprising: A chat data acquisition module, configured to acquire chat data from a chat interface, wherein the chat data includes a plurality of conversation texts; an intent recognition module, configured to perform intent recognition on each conversation text in the chat data and obtain an intent vector corresponding to each conversation text, wherein the intent vector is used to characterize the conversation content and text type of each conversation text, wherein the text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text; A clustering module is used to cluster the conversation content and text type of each of the intent vectors to generate question-answer pairs.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the program, the question-answer pair generation method as described above is implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the question-answer pair generation methods described above.
[0016] The question-answer pair generation method, device, electronic device, and storage medium provided by the present invention, because chat data itself contains a large amount of dialogue text, obtain chat data from a chat interface, perform intent recognition on each dialogue text in the chat data, obtain the intention vector corresponding to each dialogue text, cluster the dialogue content and text type of each intention vector after intent recognition to generate question-answer pairs, thereby realizing automatic extraction of dialogue text from chat data and automatic generation of question-answer pairs based on the intent clustering of the dialogue text, thereby improving the efficiency of question-answer pair generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to 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 any creative work.
[0018] Figure 1 It is a flowchart of the question-answer pair generation method provided by the present invention.
[0019] Figure 2 This is a schematic diagram of original chat information obtained in the question-answer pair generation method provided by the present invention.
[0020] Figure 3 This is a schematic diagram of chat data after removing invalid dialogue text in the question-answer pair generation method provided by the present invention.
[0021] Figure 4 This is a schematic diagram of chat data after converting non-text conversations into text in the question-answer pair generation method provided by the present invention.
[0022] Figure 5 This is a schematic diagram of chat data after intent recognition in the question-answer pair generation method provided by the present invention.
[0023] Figure 6 2 is a schematic diagram of two question-answer pairs extracted from the question-answer pair generation method provided by the present invention.
[0024] Figure 7 This is a schematic diagram of chat data after intent recognition and slot filling in the question-answer pair generation method provided by the present invention.
[0025] Figure 8 It is a structural diagram of the question-answer pair generating device provided by the present invention.
[0026] Figure 9 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0027] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0028] The question-answer pair generation method of the embodiment of the present invention is as follows: Figure 1 As shown, the process includes the following steps S110 to S130.
[0029] Step S110: Acquire chat data from a chat interface, wherein the chat data includes multiple conversation texts. The chat interface here can be a chat interface between two people in an instant messaging software, a chat interface in a multi-person conversation group, or a question-and-answer message interface in a web forum.
[0030] Specifically, robotic process automation (RPA) tools such as Auto.js can be used to collect conversation texts from instant messaging software and other platforms, and store them as structured chat data through remote API calls.
[0031] Step S120: Perform intent recognition on each dialogue text in the chat data to obtain an intent vector corresponding to each dialogue text, wherein the intent vector is used to characterize the dialogue content and text type of each dialogue text, and the text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text.
[0032] Specifically, intent recognition is performed on each conversation text in the chat data to obtain an intent vector indicating whether the conversation text is a question or an answer, as well as the question type if the text is a question. Question types vary depending on the application domain. For example, in the field of equipment operation and maintenance, questions in chat data are often related to equipment failures, so the question type includes different types of equipment failures.
[0033] Step S130: Cluster the conversation content and text type of each intent vector to generate question-answer pairs. For example, BERT (Bidirectional Encoder Representations from Transformers) can be used to convert the conversation text into intent vectors. The K-means algorithm is then used to cluster the conversation content and text type of each intent vector. Specifically, during the K-means clustering process, the cosine distance between the conversation contents can be used for clustering. Conversation texts clustered into the same category are then distinguished by text type to determine whether they are questions or answers, thereby generating question-answer pairs.
[0034] In the question-answer pair generation method of this embodiment, since the chat data itself contains a large amount of dialogue text, the chat data is obtained from the chat interface, the intent of each dialogue text in the chat data is identified, and the intention vector corresponding to each dialogue text is obtained. The dialogue content and text type of each intention vector after intent identification are clustered to generate question-answer pairs, thereby realizing automatic extraction of dialogue text from the chat data and automatic generation of question-answer pairs based on the intent clustering of the dialogue text, thereby improving the efficiency of question-answer pair generation.
[0035] In some embodiments, step S110 specifically includes: traversing each conversation text in the chat interface, matching the currently traversed conversation text with invalid words in the invalid word library, and retaining the conversation text that fails to match to form the chat data.
[0036] Specifically, chat data often contains invalid text with little relevance to specific domains or businesses, such as "OK," "Hehe," "Thank you," and "You're welcome." These invalid texts cannot clearly identify intent during intent recognition and can interfere with the automatic generation of question-answer pairs. Therefore, in this embodiment, after all conversation text is acquired, invalid text is removed from the chat data using a predefined invalid word library. This is done by calculating the similarity between the current conversation text and each invalid word defined in the invalid word library (for example, by calculating the cosine distance to obtain cosine similarity). If the similarity exceeds an invalid similarity threshold (for example, 70%), the current conversation text is determined to be invalid and removed from the chat data. The remaining conversation text ultimately forms the chat data.
[0037] Take the chat interface in the field of equipment operation and maintenance as an example, for example: Figure 2 The chat data shown is the original data obtained from the group chat interface in the field of equipment operation and maintenance. After removing invalid words, the chat data obtained is as follows Figure 3 As shown, the invalid dialogue text has been deleted.
[0038] In some embodiments, before traversing each conversation text in the chat interface, the method further includes: Extract non-text conversations from a chat interface, where the non-text conversations include at least one of voice, images, and web page references. During a chat, voice conversations are often used, such as voice questions and voice answers. Questions can also be answered using screenshots containing the text of the answer to the question. Questions can also be answered using web page references (i.e., links to web pages containing the text of the answer to the question).
[0039] The voice, picture and web page reference are converted into a conversation text, and the converted conversation text is assigned a timestamp corresponding to the voice, picture and web page reference.
[0040] Specifically, the speech is converted into dialogue text through speech recognition, the text in the picture is identified as dialogue text through OCR, and the web page reference is directly jumped to the page corresponding to the web page reference, and the text in the page is obtained as dialogue text. Then, the converted dialogue text is assigned the timestamp of the corresponding speech, picture and web page reference, that is, the dialogue text converted from each non-text dialogue is aligned with the timestamp of the corresponding speech, picture and web page reference. Figure 4 As shown, this is the chat data after the pictures are unified into conversation text.
[0041] In this embodiment, by unifying non-text conversations into conversation text, it not only facilitates subsequent intent recognition, but also avoids missing questions and answers contained in the non-text conversations, so that the question and answer matching degree of the final generated question and answer pairs is higher, and the answers are more detailed and complete.
[0042] In some embodiments, converting the webpage reference into conversation text specifically includes: At least one conversation text before the web page reference is obtained in the order of the timestamps from recent to far, for example, obtaining the previous conversation text before the web page reference, which is usually a question raised.
[0043] Entity recognition (Named Entity Recognition, NER) technology is used to extract entity keywords in at least one conversation text before the web page is cited.
[0044] The text content containing the entity keyword in the page corresponding to the web page reference is used as the conversation text converted from the web page reference. For example, the text content containing the entity keyword can be obtained from the page through a web crawler.
[0045] In this embodiment, based on the entity keywords in at least one conversation text before the web page reference, the corresponding text content is selected from the page corresponding to the web page reference as the conversation text, and the content in the web page that is irrelevant to the at least one previous conversation text is filtered out, thereby further improving the matching degree of questions and answers in the question and answer pair.
[0046] In some embodiments, step S120 specifically includes: inputting each dialogue text into a text intent recognition model, and obtaining the intent vector corresponding to each dialogue text output by the text intent recognition model, wherein the text intent recognition model is trained based on the sample dialogue text and the corresponding intent vector label, and the intent vector label is used to characterize the dialogue content and text type of the sample dialogue text, and is used to determine the sample question type of the question text when the text type is a question text.
[0047] Specifically, the text intent recognition model can be a model such as BERT that is specifically designed to process complex semantics. Before the text intent recognition model is used, it is trained with manually annotated sample conversation texts and corresponding intent vector labels in a certain application field to obtain a text intent recognition model suitable for the application field.
[0048] Still taking the chat interface in the field of equipment operation and maintenance as an example, based on Figure 4 The results of intent recognition for each conversation text in the chat data after converting each non-text conversation into a conversation text are as follows: Figure 5 As shown in the figure, in the field of equipment operation and maintenance, all questions are related to faults. Intent recognition identifies the first conversation text as describing a fault. Therefore, the first conversation text is identified as question text, with the question type being "system inaccessible." The subsequent conversation text is also identified as not describing a fault. Therefore, the subsequent conversation text is identified as answer text, which can be expressed in various forms, such as suggestions and action results.
[0049] In this embodiment, identifying the intent vector of the conversation text through the text intent recognition model can quickly and accurately identify the intent of the conversation text, thereby improving the efficiency of the entire question-answer pair generation process.
[0050] In some embodiments, step S120 specifically includes: Each conversation text is matched with a rule template representing an intent vector. The rule template defines the text type of the conversation text template and the corresponding question type when the conversation text template is a question text template. For some frequently asked questions and their corresponding answer texts, a rule template representing the intent vector is pre-generated. The question text template and the answer text template are respectively the frequently asked questions and their corresponding answer texts. In other words, the frequently asked questions and their answer texts are directly used as templates. For example, the frequently asked question "The intelligent agent platform cannot be accessed normally" corresponds to the template "Intelligent agent cannot be accessed", the text type is question text, and the question type is "The system cannot be accessed".
[0051] If a match is successful, the text type of the text template is assigned to the text type of the matched conversation text. If the text type is a question text, the question type of the question text template is assigned to the question type of the matched conversation text. Specifically, the matching method can be to calculate cosine similarity. If the cosine similarity is greater than a threshold (for example, 0.7), the match is considered successful.
[0052] If a match fails, each conversation text is input into a text intent recognition model to obtain the intent vector corresponding to each conversation text output by the text intent recognition model. The text intent recognition model is trained based on sample conversation texts and corresponding intent vector labels. The intent vector labels characterize the conversation content and text type of the sample conversation texts and, if the text type is question text, determine the sample question type of the question text.
[0053] In this embodiment, the intention vector recognition of dialogue texts containing high-frequency questions and their answers can be achieved quickly and accurately through rule template matching. The intention vector recognition of other dialogue texts can also be achieved accurately through the text intention recognition model, which speeds up the intention vector recognition while ensuring the accuracy of the intention recognition of each dialogue text.
[0054] like Figure 6 As shown, it is based on Figure 1 Two question-answer pairs are obtained by extracting each conversation text from the chat data after intent recognition, where the two question-answer pairs have the same questions but different answers.
[0055] In some embodiments, after clustering the conversation content and text type of each intention vector to generate question-answer pairs, it also includes: for any question-answer pair, comparing the question text of any question-answer pair with the historical question-answer pairs in the historical question-answer database for similarity; if the similarity is greater than a similarity threshold, adding 1 to the number of occurrences of the historical question-answer pair; otherwise, adding any question-answer pair to the historical question-answer database.
[0056] Specifically, the question text of any question and answer pair is compared with the historical question text of the historical question and answer pair, and the answer text of any question and answer pair is compared with the historical answer text of the historical question and answer pair. If the similarity of the two comparisons is greater than the similarity threshold, the number of occurrences of the historical question and answer pair is increased by 1; otherwise, the any question and answer pair is added to the historical question and answer database.
[0057] In this embodiment, by querying the historical question and answer database for similar question and answer pairs to the question and answer pairs extracted from the chat data and counting the number of occurrences of similar question and answer pairs, the frequency of occurrence of question and answer pairs in the historical question and answer database can be counted more effectively and accurately.
[0058] In some embodiments, after clustering the conversation content and text type of each of the intent vectors to generate question-answer pairs, the method further includes: For each question-and-answer pair, obtain a frequency index for that pair. This index includes two indicators: the frequency of occurrence of that pair in the historical question-and-answer database (the ratio of the number of times that pair appears to the total number of pairs) and the conversation repetition rate of the question text in the chat interface. The conversation repetition rate can be obtained by analyzing historical chat data. A higher frequency index for a question-and-answer pair indicates a higher value for that pair.
[0059] For any question-and-answer pair, obtain user evaluation indicators for that question-and-answer pair. The user evaluation indicators include the satisfaction and conversion rate of user evaluations of the question-and-answer pair in the historical question-and-answer database, i.e., they include two indicators: satisfaction and conversion rate. The conversion rate is a statistical indicator that represents whether the question-and-answer pair successfully solves the user's problem. For a user, if a question-and-answer pair is used to solve the actual problem, a conversion score of 1 is recorded; otherwise, a conversion score of 0 is recorded. Finally, the average of all conversion scores for the question-and-answer pair is calculated (i.e., the total conversion score divided by the number of users who used the question-and-answer pair to solve the actual problem), to obtain the conversion rate. Satisfaction is the user's subjective satisfaction with the process of using the question-and-answer pair to solve the problem. For example, a score of 0-1 indicates different levels of satisfaction.
[0060] The value assessment score for each question-answer pair is calculated based on the frequency index, user evaluation index, and their respective index weights. The index weights are pre-set and reflect the degree of influence of each index on the value assessment score. The specific calculation method is to weight the sum of each index and its corresponding index weight.
[0061] In this embodiment, the value assessment score of the question-answer pair can represent the value of the question-answer pair at two levels: frequency of use and user experience. When subsequently training the intelligent question-answering system, question-answer pairs with higher value can be selected as samples for fine-tuning training to improve the accuracy of the intelligent question-answering system in answering questions.
[0062] In some embodiments, when performing intent recognition on each conversation text in the chat data, not only the intent vector of each conversation text is output, but also the confidence of the intent vector is output. Specifically, for a text intent recognition model, the text intent recognition model can simultaneously output the confidence of the intent vector. For conversation texts matched using a rule template that represents the intent vector, the confidence of the intent vector can be set to be above 0.7. At the same time, after intent recognition and before clustering, the question text is slot-filled by extracting key parameters representing the problem from the chatter information, chat group information, and question text in the chat interface. For example, in the field of equipment operation and maintenance, key parameters include: system name, operation name, time, and fault information.
[0063] like Figure 7 As shown, it is based on Figure 1 The chat data after each dialogue text has undergone intent recognition and slot filling, and the semantic information of the question text is enhanced through slot filling.
[0064] To assess the value of a question-answer pair, we can expand upon the frequency and user evaluation metrics with a semantic metric, including the confidence of the intent vector and slot completeness. We then assign weights to the semantic metric accordingly. The value assessment score for a question-answer pair is calculated by taking the weighted sum of the frequency, user evaluation, and semantic metrics.
[0065] For example: Figure 6 For question and answer pair 2, or QA2, the values of the various indicators are as follows: Word frequency: 0.85; Session repetition rate: 0.7; Intent vector confidence: 0.95; Slot completeness: 1.0; User satisfaction score: 4.5 / 5 = 0.9 (5 users scored 4.5, average 0.9); Conversion rate: 0.15; Comprehensive score: (0.85 / 2+0.7 / 2)×0.3 + (0.95 / 2+1.0 / 2)×0.4 + (0.9 / 2+0.15 / 2)×0.3.
[0066] In this embodiment, by adding semantic indicators, the value of the question-answer pair can be evaluated more accurately and realistically.
[0067] The question-answer pair generation device provided by the present invention is described below. The question-answer pair generation device described below and the question-answer pair generation method described above can be referenced to each other.
[0068] The question-answer pair generating device of the embodiment of the present invention is as follows: Figure 8As shown, it includes the following modules: The chat data acquisition module 810 is used to acquire chat data from the chat interface, where the chat data includes multiple conversation texts.
[0069] The intention recognition module 820 is used to perform intent recognition on each dialogue text in the chat data to obtain an intention vector corresponding to each dialogue text. The intention vector is used to characterize the dialogue content and text type of each dialogue text. The text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text.
[0070] The clustering module 830 is used to cluster the conversation content and text type of each of the intention vectors to generate question-answer pairs.
[0071] In the question-answer pair generation device of the embodiment of the present invention, since the chat data itself contains a large amount of dialogue text, the chat data is obtained from the chat interface, the intent of each dialogue text in the chat data is identified, and the intention vector corresponding to each dialogue text is obtained. The dialogue content and text type of each intention vector after intent identification are clustered to generate question-answer pairs, thereby realizing automatic extraction of dialogue text from the chat data and automatic generation of question-answer pairs based on the intent clustering of the dialogue text, thereby improving the efficiency of question-answer pair generation.
[0072] In some embodiments, the chat data acquisition module 810 is specifically used to traverse each conversation text in the chat interface, match the currently traversed conversation text with invalid words in the invalid word library, and retain the conversation text that fails to match to form the chat data.
[0073] In some embodiments, the question-answer pair generating device further comprises: The non-text conversation extraction module is used to extract the non-text conversation in the chat interface before traversing each conversation text in the chat interface, wherein the non-text conversation includes at least one of voice, picture and web page reference.
[0074] The text conversion module is used to convert the voice, picture and web page reference into a conversation text, and assign a time stamp corresponding to the voice, picture and web page reference to the converted conversation text.
[0075] In some embodiments, the text conversion module includes a web page reference conversion module, which is specifically configured to: At least one conversation text before the web page reference is obtained in descending order of the timestamps.
[0076] Entity recognition technology is used to extract entity keywords from at least one conversation text before the web page reference.
[0077] The text content containing the entity keyword in the page corresponding to the web page reference is used as the dialogue text after the web page reference is converted.
[0078] In some embodiments, the intention recognition module 820 is specifically used to input each dialogue text into a text intention recognition model to obtain the intention vector corresponding to each dialogue text output by the text intention recognition model, wherein the text intention recognition model is trained based on the sample dialogue text and the corresponding intention vector label, and the intention vector label is used to characterize the dialogue content and text type of the sample dialogue text, and is used to determine the sample question type of the question text when the text type is a question text.
[0079] In some embodiments, the intent recognition module 820 is specifically configured to: Each dialogue text is matched with a rule template representing an intention vector, wherein the rule template defines a text type of the dialogue text template and a corresponding question type when the dialogue text template is a question text template.
[0080] If the match is successful, the text type of the text template is assigned to the text type of the successfully matched dialogue text, and if the text type is question text, the question type of the question text template is assigned to the question type of the successfully matched dialogue text.
[0081] In the case of matching failure, each dialogue text is input into the text intention recognition model to obtain the intention vector corresponding to each dialogue text output by the text intention recognition model.
[0082] Among them, the text intent recognition model is trained based on sample conversation text and corresponding intent vector labels. The intent vector labels are used to characterize the conversation content and text type of the sample conversation text, and are used to determine the sample question type of the question text when the text type is question text.
[0083] In some embodiments, the question-answer pair generation device also includes: a question-answer pair statistics module, which is used to cluster the conversation content and text type of each intention vector to generate a question-answer pair. For any question-answer pair, the question text of the any question-answer pair is compared with the historical question-answer pairs in the historical question-answer database for similarity. If the similarity is greater than the similarity threshold, the number of occurrences of the historical question-answer pair is increased by 1; otherwise, the any question-answer pair is added to the historical question-answer database.
[0084] In some embodiments, the question-answer pair generation device also includes: a question-answer pair evaluation module, which is used to obtain a frequency index of any question-answer pair for any question-answer pair after clustering the conversation content and text type of each intention vector to generate a question-answer pair, the frequency index including the frequency of occurrence of any question-answer pair in the historical question-answer database and the conversation repetition rate of the question text of any question-answer pair in the chat interface; for any question-answer pair, obtain a user evaluation index of any question-answer pair, the user evaluation index including the satisfaction and conversion rate of user evaluation of any question-answer pair in the historical question-answer database; calculate the value assessment score of any question-answer pair based on the frequency index, user evaluation index and their respective index weights.
[0085] Figure 9 An example of a physical structure diagram of an electronic device is shown below. Figure 9 As shown, the electronic device may include: a processor 910, a communication interface 920, a memory 930, and a communication bus 940, wherein the processor 910, the communication interface 920, and the memory 930 communicate with each other via the communication bus 940. The processor 910 may call the logic instructions in the memory 930 to execute the question-answer pair generation method, which includes: Chat data is acquired from a chat interface, where the chat data includes a plurality of conversation texts.
[0086] Intent recognition is performed on each dialogue text in the chat data to obtain an intention vector corresponding to each dialogue text. The intention vector is used to characterize the dialogue content and text type of each dialogue text. The text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text.
[0087] The conversation content and text type of each of the intent vectors are clustered to generate question-answer pairs.
[0088] Furthermore, the logic instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0089] In another aspect, the present invention further provides a computer program product, comprising a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the question-answer pair generation method provided by each of the above methods, the method comprising: Chat data is acquired from a chat interface, where the chat data includes a plurality of conversation texts.
[0090] Intent recognition is performed on each dialogue text in the chat data to obtain an intention vector corresponding to each dialogue text. The intention vector is used to characterize the dialogue content and text type of each dialogue text. The text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text.
[0091] The conversation content and text type of each of the intent vectors are clustered to generate question-answer pairs.
[0092] In another 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, is implemented to perform the question-answer pair generation method provided by the above methods, the method comprising: Chat data is acquired from a chat interface, where the chat data includes a plurality of conversation texts.
[0093] Intent recognition is performed on each dialogue text in the chat data to obtain an intention vector corresponding to each dialogue text. The intention vector is used to characterize the dialogue content and text type of each dialogue text. The text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text.
[0094] The conversation content and text type of each of the intent vectors are clustered to generate question-answer pairs.
[0095] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0096] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion 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, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A question-answer pair generation method, characterized in that: include: Acquire chat data from the chat interface, wherein the chat data includes multiple conversation texts; Performing intent recognition on each conversation text in the chat data to obtain an intent vector corresponding to each conversation text, wherein the intent vector is used to characterize the conversation content and text type of each conversation text, wherein the text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text; The conversation content and text type of each of the intent vectors are clustered to generate question-answer pairs.
2. The question-answer pair generation method according to claim 1, wherein: Get chat data from the chat interface, including: Each conversation text in the chat interface is traversed, the currently traversed conversation text is matched with invalid words in the invalid word database, and the conversation text that fails to match is retained to form the chat data.
3. The question-answer pair generation method according to claim 2, characterized in that: Before traversing each dialogue text in the chat interface, it also includes: Extracting non-text conversations in the chat interface, wherein the non-text conversations include at least one of voice, pictures, and web page references; The voice, picture and web page reference are converted into a conversation text, and the converted conversation text is assigned a timestamp corresponding to the voice, picture and web page reference.
4. The question-answer pair generation method according to claim 3, wherein: Convert web page quotes into conversational text, including: Acquire at least one conversation text before the web page references it in descending order of the timestamps; Using entity recognition technology to extract entity keywords from at least one conversation text before the webpage reference; The text content containing the entity keyword in the page corresponding to the web page reference is used as the dialogue text after the web page reference is converted.
5. The question-answer pair generation method according to claim 1, wherein: Performing intent recognition on each conversation text in the chat data to obtain an intent vector corresponding to each conversation text includes: Each dialogue text is input into a text intent recognition model to obtain an intent vector corresponding to each dialogue text output by the text intent recognition model, wherein the text intent recognition model is trained based on sample dialogue texts and corresponding intent vector labels, and the intent vector labels are used to characterize the dialogue content and text type of the sample dialogue text, and are used to determine the sample question type of the question text when the text type is a question text.
6. The question-answer pair generation method according to claim 1, wherein: Performing intent recognition on each conversation text in the chat data to obtain an intent vector corresponding to each conversation text includes: Matching each dialogue text with a rule template representing an intent vector, wherein the rule template defines the text type of the dialogue text template and the corresponding question type when the dialogue text template is a question text template; If the match is successful, the text type of the text template is assigned to the text type of the successfully matched dialogue text, and if the text type is a question text, the question type of the question text template is assigned to the question type of the successfully matched dialogue text; In the event of a match failure, each conversation text is input into a text intent recognition model to obtain an intent vector corresponding to each conversation text output by the text intent recognition model; Among them, the text intent recognition model is trained based on sample conversation text and corresponding intent vector labels. The intent vector labels are used to characterize the conversation content and text type of the sample conversation text, and are used to determine the sample question type of the question text when the text type is question text.
7. The question-answer pair generation method according to any one of claims 1 to 6, characterized in that: After clustering the conversation content and text type of each intent vector to generate question-answer pairs, the method further includes: For any question-answer pair, the question text of the question-answer pair is compared with the historical question-answer pairs in the historical question-answer database for similarity. If the similarity is greater than the similarity threshold, the number of occurrences of the historical question-answer pair is increased by 1; otherwise, the question-answer pair is added to the historical question-answer database.
8. The question-answer pair generation method according to claim 7, characterized in that: After clustering the conversation content and text type of each intent vector to generate question-answer pairs, the method further includes: For any question-answer pair, obtain a frequency index of any question-answer pair, wherein the frequency index includes the frequency of occurrence of the question-answer pair in the historical question-answer database and the conversation repetition rate of the question text of the question-answer pair in the chat interface; For any question-answer pair, obtain user evaluation indicators for the question-answer pair, wherein the user evaluation indicators include satisfaction and conversion rate of user evaluations of the question-answer pair in a historical question-answer database; The value assessment score of any question-answer pair is calculated based on the frequency index, user evaluation index and their respective index weights.
9. A question-answer pair generation device, characterized in that: include: A chat data acquisition module, configured to acquire chat data from a chat interface, wherein the chat data includes a plurality of conversation texts; an intent recognition module, configured to perform intent recognition on each conversation text in the chat data and obtain an intent vector corresponding to each conversation text, wherein the intent vector is used to characterize the conversation content and text type of each conversation text, wherein the text type includes: question text or answer text, and is used to determine the question type of the question text when the text type is question text; A clustering module is used to cluster the conversation content and text type of each of the intent vectors to generate question-answer pairs.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the question-answer pair generating method according to any one of claims 1 to 8 is implemented.
11. 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 question-answer pair generating method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Intelligent dialogue method, robot dialogue system, server and storage medium
CN109885664A
Method for obtaining question and answer pairs from unstructured text based on deep learning
CN110110054A
Question and answer pair generation method and device
CN111897934A
Question and answer pair generation method and device, electronic equipment and computer storage medium
CN115114416A
Method and device for constructing question and answer system
CN118708691A