Artificial intelligence-based dialogue model training method, device, equipment and medium
By using a dialogue model training method, the initial question and answer texts are concatenated with category hints, and the data is augmented using a text back-translation model to extract keywords and add question and answer category information. This solves the problem of low accuracy in dialogue models and improves the dialogue accuracy and business efficiency of customer service robots in the fintech field.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PING AN TECH (SHENZHEN) CO LTD
- Filing Date
- 2023-05-19
- Publication Date
- 2026-05-12
AI Technical Summary
Existing dialogue models have low accuracy in the financial field, are prone to semantic understanding due to confusion between question and answer text in the concatenated results, and learn complex and redundant information.
The initial question text, answer text, and preset category hints are concatenated to form the first sample. The text data is then augmented using a text back-translation model. Keywords are extracted and question-and-answer category information is added as training samples and labels to train the dialogue model.
It improved the accuracy of the dialogue model, enhanced response performance on different types of questions, and improved the service efficiency and quality of financial services.
Smart Images

Figure CN116483979B_ABST
Abstract
Description
Technical Field
[0001] This invention is applicable to the field of financial technology, and in particular relates to a method, apparatus, device and medium for training a dialogue model based on artificial intelligence. Background Technology
[0002] Dialogue models can identify semantics based on user input and then generate corresponding responses based on the user's semantic information. With the development of artificial intelligence technology, the usage of dialogue models in virtual assistants, smart speakers, and casual conversations is gradually increasing. For example, in the financial field, virtual customer service robots can communicate with customers based on dialogue models, making outstanding contributions in resolving customer questions, guiding customer transactions, and providing after-sales service, effectively improving service efficiency in the financial field.
[0003] Currently, dialogue models tend to directly concatenate dialogue questions and answers into input content. The dialogue model generates corresponding responses by extracting semantic features from the input content. This method may reduce the dialogue model's semantic understanding of the input content due to confusion between the dialogue questions and answers in the concatenation result. At the same time, it may learn complex and redundant information in the dialogue answers, further reducing the accuracy of the dialogue model.
[0004] Therefore, improving the accuracy of dialogue models in financial scenarios has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide a method, apparatus, device and medium for training dialogue models based on artificial intelligence, in order to solve the problem of low accuracy of existing dialogue models.
[0006] In a first aspect, embodiments of the present invention provide a dialogue model training method based on artificial intelligence, the dialogue model training method comprising:
[0007] The initial question text, initial answer text, and preset category prompts are concatenated, and the corresponding concatenation result is determined as the first sample.
[0008] Extract initial answer keywords from the initial answer text, input the initial answer keywords into a pre-trained question-answering classification model to obtain a first question-answering category, and concatenate the initial answer keywords and the first question-answering category to determine the concatenation result as the label of the first sample;
[0009] The initial question text, the initial answer text, and the initial answer keywords are respectively input into the trained text back translation model to obtain the augmented question text, the augmented answer text, and the augmented answer keywords. The augmented question text, the augmented answer text, and the preset category prompt words are concatenated to determine the corresponding concatenation result as the second sample.
[0010] The augmented answer keywords are input into the pre-trained question-answer classification model to obtain a second question-answer category. The augmented answer keywords and the second question-answer category are then concatenated to determine the concatenation result as the label of the second sample.
[0011] Using the first sample and the second sample as training samples, and the labels of the first sample and the second sample as training labels, a preset dialogue model is trained to obtain a trained dialogue model.
[0012] Secondly, embodiments of the present invention provide an artificial intelligence-based dialogue model training device, the dialogue model training device comprising:
[0013] The first sample splicing module is used to splice the acquired initial question text, initial answer text, and preset category prompt words, and determine the corresponding splicing result as the first sample;
[0014] The first tag splicing module is used to extract initial answer keywords from the initial answer text, input the initial answer keywords into a pre-trained question-answer classification model to obtain a first question-answer category, and splice the initial answer keywords and the first question-answer category to determine the splicing result as the tag of the first sample;
[0015] The second sample splicing module is used to input the initial question text, the initial answer text, and the initial answer keywords into the trained text back translation model to obtain the augmented question text, the augmented answer text, and the augmented answer keywords. The module then splices the augmented question text, the augmented answer text, and the preset category prompt words to determine the corresponding splicing result as the second sample.
[0016] The second label splicing module is used to input the augmented answer keywords into the pre-trained question-answer classification model to obtain a second question-answer category, and to splice the augmented answer keywords and the second question-answer category to determine the splicing result as the label of the second sample;
[0017] The dialogue model training module is used to train a preset dialogue model using the first sample and the second sample as training samples and the labels of the first sample and the second sample as training labels, so as to obtain a trained dialogue model.
[0018] Thirdly, embodiments of the present invention provide a computer device, the computer device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the dialogue model training method as described in the first aspect.
[0019] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the dialogue model training method as described in the first aspect.
[0020] The beneficial effects of this invention compared to existing technologies are as follows: By concatenating the initial question text, initial answer text, and preset category hints into a first sample, and obtaining amplified question text, amplified answer text, and amplified answer keywords through a text back-translation model, and then concatenating the amplified question text, amplified answer text, and preset category hints into a second sample, not only is the text data expanded, but the question text and answer text are also distinguished by setting category hints, thus solving the problem of confusion between the question text and answer text in the concatenated result. Furthermore, by obtaining the first question-and-answer category of the initial answer keywords and concatenating it into the label of the first sample, and obtaining the second question-and-answer category of the amplified answer keywords and concatenating it into the label of the second sample, the response performance of the dialogue model on different categories of questions is improved by adding question-and-answer category information to the labels. Finally, using the first and second samples as training samples, and using the labels of the first and second samples as training labels, the preset dialogue model is trained, effectively improving the accuracy of the trained dialogue model, improving the dialogue accuracy of customer service robots in the fintech field, and thus improving the service efficiency and quality of financial services. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a schematic diagram of an application environment for an artificial intelligence-based dialogue model training method provided in Embodiment 1 of the present invention;
[0023] Figure 2 This is a flowchart illustrating a dialogue model training method based on artificial intelligence provided in Embodiment 1 of the present invention.
[0024] Figure 3This is a schematic diagram of the structure of an artificial intelligence-based dialogue model training device provided in Embodiment 2 of the present invention;
[0025] Figure 4 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Detailed Implementation
[0026] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.
[0027] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0028] It should also be understood that the term “and / or” as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0029] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."
[0030] Furthermore, in the description of this invention and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0031] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of the invention include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0032] The embodiments of this invention can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that utilize digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0033] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0034] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0035] To illustrate the technical solution of the present invention, specific embodiments are described below.
[0036] The first embodiment of this invention provides a dialogue model training method based on artificial intelligence, which can be applied to, for example... Figure 1 In this application environment, the client communicates with the server. Clients include, but are not limited to, handheld computers, desktop computers, laptops, ultra-mobile personal computers (UMPCs), netbooks, cloud computing devices, and personal digital assistants (PDAs). The server can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0037] This method can be widely applied in fields such as fintech, internet technology, digital healthcare, and education. For example, customer service robots in the fintech field can communicate with customers based on the dialogue model trained by this dialogue model training method, and complete tasks such as resolving customer questions, guiding customers in transactions, and providing after-sales service, thereby improving service efficiency in the financial field.
[0038] See Figure 2 This is a flowchart illustrating an artificial intelligence-based dialogue model training method provided in Embodiment 1 of the present invention. The above-described dialogue model training method can be applied to... Figure 1 For clients in the context of dialogue, the training method for this dialogue model may include the following steps:
[0039] Step S201: The obtained initial question text, initial answer text, and preset category prompt words are concatenated to determine the corresponding concatenation result as the first sample.
[0040] In this system, the initial question text and initial answer text are one-to-one correspondences. During dialogue model training, these initial question texts and initial answer texts serve as the foundation for training. Semantic analysis of these initial question texts is performed to obtain question-and-answer features. Correspondingly, for customer service robots in the financial sector, the initial question text and initial answer text can be based on questions asked by customers and answers given by human customer service representatives during interactions. This human-based question-and-answer experience is used to train the corresponding question-and-answer model for the customer service robot, enabling the model to provide fluent and natural responses and improving its accuracy.
[0041] Preset category hint terms are terms that provide category hint information. They are used to concatenate with the initial question text and the initial answer text to simultaneously indicate the text category of both the initial question text and the initial answer text. For example, the preset category hint term could be "question," indicating that the corresponding initial question text is categorized as "question," or it could be "answer," indicating that the corresponding initial answer text is categorized as "answer."
[0042] When the concatenated initial question text and initial answer text are directly used as input to the dialogue model, the initial question text and initial answer text in the concatenated result are easily confused. When the semantic features of such input content are extracted to generate the corresponding response, the dialogue model’s semantic understanding of the input content will be reduced, thereby reducing the accuracy of the dialogue model.
[0043] Therefore, in this embodiment, in order to improve the accuracy of the dialogue model, the initial question text, the initial answer text, and the preset category prompt words with text category prompt information are concatenated, and the concatenation result is used as the first sample in the training process of the dialogue model. This solves the problem that the initial question text and the initial answer text are easily confused in the concatenation result, thereby improving the semantic understanding of the input content of the dialogue model and thus improving the accuracy of the dialogue model.
[0044] Optionally, the acquired initial question text, initial answer text, and preset category hint terms are concatenated to determine the corresponding concatenated result as the first sample, including:
[0045] The preset category prompt terms include a first sub-term and a second sub-term. The initial question text and the first sub-term are concatenated to obtain the question prompt text.
[0046] The initial answer text and the second sub-item are concatenated to obtain the answer hint text;
[0047] The question prompt text and the answer prompt text are concatenated, and the corresponding concatenated result is determined as the first sample.
[0048] The text input to the model includes two types of text: initial question text and initial answer text. Therefore, corresponding preset category prompt terms are set, including a first sub-term and a second sub-term. The first sub-term is used to indicate the text category of the corresponding initial question text, for example, the first sub-term is "question". The second sub-term is used to indicate the text category of the corresponding initial answer text, for example, the second sub-term is "answer".
[0049] The question prompt text is obtained by concatenating the initial question text and the first sub-item. The answer prompt text is obtained by concatenating the initial answer text and the second sub-item. The question prompt text and the answer prompt text are then concatenated to determine the corresponding concatenation result as the first sample.
[0050] In one implementation, a first sub-word term is concatenated with the initial question text as a prefix, and a second sub-word term is concatenated with the initial answer text as a prefix. This not only indicates the text category of the initial question text and the text category of the initial answer text, but also separates the initial question text and the initial answer text, further improving the semantic understanding of the input content by the dialogue model.
[0051] In another implementation, the first sub-term is concatenated with the initial question text as a suffix, and the second sub-term is concatenated with the initial answer text as a suffix. This not only indicates the text category of the initial question text and the text category of the initial answer text, but also separates the initial question text and the initial answer text, further improving the semantic understanding of the input content by the dialogue model.
[0052] The above-mentioned steps of concatenating the initial question text, initial answer text, and preset category prompt words to determine the corresponding concatenation result as the first sample solve the problem of confusion between the initial question text and the initial answer text in the concatenation result. This improves the semantic understanding of the input content by the dialogue model and thus improves the accuracy of the dialogue model.
[0053] Step S202: Extract initial answer keywords from the initial answer text, input the initial answer keywords into the pre-trained question-answer classification model to obtain the first question-answer category, and concatenate the initial answer keywords and the first question-answer category to determine the concatenation result as the label of the first sample.
[0054] In this context, initial answer keywords are extracted from the initial answer text. Compared to the initial answer keywords, the initial answer text contains complex and redundant information. Directly using the initial answer text as the labeling basis for the dialogue model can reduce the accuracy of the dialogue model due to this complexity and redundancy. Therefore, in this embodiment, the initial answer keywords extracted from the initial answer text are used as the labeling basis for the dialogue model to improve its accuracy.
[0055] Simultaneously, the extracted initial answer keywords are input into a pre-trained question-answering classification model to obtain the first question-answering category. The initial answer keywords and the first question-answering category are then concatenated to determine the label for the first sample. Since this label forms the basis for training the parameters of the dialogue model, incorporating question-answering category information into the label can improve the response performance of the dialogue model on different categories of questions. The first question-answering category can be any of the following: address question-answering, name question-answering, time question-answering, occupation question-answering, etc.
[0056] In one implementation, a keyword extraction algorithm can be used to extract initial answer keywords from the initial answer text.
[0057] The steps described above—extracting initial answer keywords from the initial answer text, inputting these keywords into a pre-trained question-answering classification model to obtain the first question-answer category, concatenating the initial answer keywords and the first question-answer category to determine the label of the first sample—reduce the complexity and redundancy of the labels by using the initial answer keywords extracted from the initial answer text as the label basis for the dialogue model, thereby improving the accuracy of the dialogue model. Furthermore, by incorporating question-answering category information into the labels, the response performance of the dialogue model on different categories of questions is improved.
[0058] Step S203: Input the initial question text, initial answer text, and initial answer keywords into the trained text back translation model to obtain the amplified question text, amplified answer text, and amplified answer keywords. Then, concatenate the amplified question text, amplified answer text, and preset category prompts to determine the corresponding concatenation result as the second sample.
[0059] In training the dialogue model, the larger the amount of data used, the better the dialogue response performance of the dialogue model on different data. Therefore, in this embodiment, in order to enable the dialogue model to learn more fully the distribution characteristics of different data to improve the model's response performance, a text back-translation model is used to perform language conversion on the initial question text, initial answer text, and initial answer keywords to achieve text amplification and obtain richer text corpus.
[0060] Specifically, the initial question text, initial answer text, and initial answer keywords are input into the trained text back-translation model to obtain augmented question text, augmented answer text, and augmented answer keywords. The augmented question text, augmented answer text, and preset category prompts are then concatenated to determine the corresponding concatenated result as the second sample. This addresses the issue of confusion between the augmented question text and augmented answer text in the concatenated result, thereby improving the dialogue model's semantic understanding of the input content and reducing complex redundant information in the labels. Simultaneously, question-answer category information is added to the labels to improve the dialogue model's response performance on different question categories, thus enhancing the accuracy of the dialogue model.
[0061] Optionally, the initial question text, initial answer text, and initial answer keywords are input into a trained text back-translation model to obtain augmented question text, augmented answer text, and augmented answer keywords, including:
[0062] The text back-translation model includes a first language conversion sub-model and a second language conversion sub-model;
[0063] The initial question text, initial answer text, and initial answer keywords are input into the first language conversion sub-model to obtain the first initial question text, the first initial answer text, and the first initial answer keywords.
[0064] The first initial question text, the first initial answer text, and the first initial answer keywords are respectively input into the second language conversion sub-model to obtain the second initial question text, the second initial answer text, and the second initial answer keywords.
[0065] The initial question text, initial answer text, initial answer keywords, second initial question text, second initial answer text, and second initial answer keywords are deduplicated to obtain the expanded question text, expanded answer text, and expanded answer keywords.
[0066] The text back-translation model includes a first language conversion sub-model and a second language conversion sub-model. The first language conversion sub-model is used to convert the initial question text, initial answer text, and initial answer keywords from language A to language B. The second language conversion sub-model is used to convert the initial question text, initial answer text, and initial answer keywords, which have been converted to language B, back to language A. That is, by performing two language conversions on the initial question text, initial answer text, and initial answer keywords respectively, the back-translation is completed to obtain the second initial question text, the second initial answer text, and the second initial answer keywords.
[0067] Since the text back-translation model performs language conversion on the initial question text, initial answer text, and initial answer keywords to achieve text augmentation, there may be cases where the text before and after language conversion is very similar, resulting in redundancy of text data in the second sample and thus reducing the training efficiency of the dialogue model.
[0068] Therefore, in order to improve the quality of the second sample, this embodiment further performs deduplication processing on the initial question text, initial answer text, initial answer keywords, second initial question text, second initial answer text, and second initial answer keywords to reduce the amount of redundant text obtained from back translation, and obtains amplified question text, amplified answer text, and amplified answer keywords as the basis for constructing the second text.
[0069] Optionally, the initial question text, initial answer text, initial answer keywords, second initial question text, second initial answer text, and second initial answer keywords are deduplicated to obtain expanded question text, expanded answer text, and expanded answer keywords, including:
[0070] Calculate the first similarity between the initial question text and the second initial question text, and use the second initial question text whose first similarity is not greater than a first preset threshold as the expanded question text;
[0071] Calculate the second similarity between the initial answer text and the second initial answer text, and use the second initial answer text whose second similarity is not greater than a second preset threshold as the amplified answer text;
[0072] Calculate the third similarity between the initial answer keywords and the second initial answer keywords, and use the second initial answer keywords whose third similarity is not greater than the third preset threshold as the expanded answer keywords.
[0073] The second initial question text, the second initial answer text, and the second initial answer keywords are obtained by back-translation based on the initial question text, the initial answer text, and the initial answer keywords. In this embodiment, deduplication is performed by filtering out the second initial question text, the second initial answer text, and the second initial answer keywords that are highly similar to the initial question text, the initial answer text, or the initial answer keywords.
[0074] Specifically, the first similarity between the initial question text and the second initial question text is calculated, and the second initial question text with a first similarity not greater than a first preset threshold is used as the expanded question text; the second similarity between the initial answer text and the second initial answer text is calculated, and the second initial answer text with a second similarity not greater than a second preset threshold is used as the expanded answer text; the third similarity between the initial answer keywords and the second initial answer keywords is calculated, and the second initial answer keywords with a third similarity not greater than a third preset threshold are used as the expanded answer keywords, thus completing the deduplication process for the initial question text, initial answer text, initial answer keywords, second initial question text, second initial answer text, and second initial answer keywords.
[0075] The specific values of the first preset threshold, the second preset threshold, and the third preset threshold can be set according to the actual situation.
[0076] The steps described above—inputting the initial question text, initial answer text, and initial answer keywords into a trained text back-translation model to obtain augmented question text, augmented answer text, and augmented answer keywords, and then concatenating the augmented question text, augmented answer text, and preset category prompts to form a second sample—obtain a richer text corpus through back-translation. Furthermore, deduplication of the back-translated text data reduces redundant text, improving the training efficiency of the dialogue model. Finally, concatenating the augmented question text, augmented answer text, and preset category prompts to form a second sample enhances the dialogue model's semantic understanding of the input content, thereby improving the model's accuracy.
[0077] Step S204: Input the amplified answer keywords into the pre-trained question-answer classification model to obtain the second question-answer category. Then, concatenate the amplified answer keywords and the second question-answer category to determine the concatenation result as the label of the second sample.
[0078] The process involves inputting amplified answer keywords into a pre-trained question-and-answer classification model to obtain a second question-and-answer category. The amplified answer keywords and the second question-and-answer category are then concatenated to determine the label for the second sample. Since this label forms the basis for training the dialogue model's parameters, incorporating question-and-answer category information into the label can improve the model's response performance across different question categories. The second question-and-answer category can be any of the following: address question-and-answer, name question-and-answer, time question-and-answer, occupation question-and-answer, etc.
[0079] Step S205: Using the first sample and the second sample as training samples, and the labels of the first sample and the second sample as training labels, train the preset dialogue model to obtain the trained dialogue model.
[0080] After the above steps, the first and second samples are question and answer texts with text category hints after text augmentation. The concatenation of pre-set category hint terms effectively solves the problem of confusion between question and answer texts in the concatenation result, and improves the semantic understanding of the input content by the dialogue model. The labels of the first and second samples are improved by adding question and answer category information to the labels to improve the response performance of the dialogue model on different categories of questions.
[0081] Therefore, in this embodiment, the first sample and the second sample are used as training samples, and the labels of the first sample and the second sample are used as training labels to train the preset dialogue model, which greatly improves the accuracy of the dialogue model.
[0082] Optionally, using the first and second samples as training samples, and the labels of the first and second samples as training labels, a pre-defined dialogue model is trained to obtain a trained dialogue model, including:
[0083] The dialogue model includes an encoder and a decoder. The first and second samples are used as training samples. The training samples are input into the encoder for feature extraction to obtain question-and-answer features.
[0084] The question-and-answer features are input into the decoder to obtain the sample answers;
[0085] The sample answers are input into a pre-trained question-answering classification model to obtain the sample question-answering category;
[0086] The first model loss is calculated based on the sample answers, sample question-answer categories, and corresponding training labels. The parameters of the encoder and decoder are then corrected in reverse using gradient descent until the first model loss converges, resulting in a trained dialogue model.
[0087] The encoder is used to extract features from the first and second samples to obtain question-and-answer features. The decoder is used to decode the question-and-answer features to output the sample answer. Since the training labels include question-and-answer category information, the output sample answer is input into the pre-trained question-and-answer classification model to obtain the sample question-and-answer category. The first model loss can be calculated using the sample answer, the sample question-and-answer category, and the corresponding training label to represent the degree of difference between the output of the dialogue model and the label.
[0088] The greater the loss of the first model, the lower the accuracy of the dialogue model. It is necessary to correct the parameters of the encoder and decoder in reverse according to the gradient descent method until the loss of the first model converges to obtain a well-trained dialogue model.
[0089] Optionally, the first model loss is calculated based on the sample answers, sample question-and-answer categories, and corresponding training labels, including:
[0090] Training labels include the corresponding initial answer keywords and the corresponding question and answer categories;
[0091] Calculate the first loss between the sample answer and the corresponding initial answer keywords, and calculate the second loss between the sample question-and-answer category and the first or second question-and-answer category;
[0092] Substitute the first loss and the second loss into the preset loss relationship model to calculate the first model loss.
[0093] The training labels include the corresponding initial answer keywords and the corresponding question-and-answer categories. The first loss between the sample answer and the initial answer keywords is calculated to represent the difference between the output sample answer and the initial answer keywords. The second loss between the sample question-and-answer category and the corresponding first or second question-and-answer category is calculated to represent the difference between the obtained sample question-and-answer category and the first or second question-and-answer category. The first and second losses are then substituted into the preset loss relationship model to calculate the first model loss.
[0094] For example, let N be the number of sample answers, the number of initial answer keywords, the number of sample question-and-answer categories, and the total number of the first and second question-and-answer categories, where N is a positive integer. First, the i-th (i = 1, 2, ..., N) sample answer is converted into a sample answer vector using word vector technology, and denoted as X. 1i Convert the i-th initial answer keyword into an initial answer keyword vector, and denote it as X. 2i Then the first loss between the keywords of the N sample answers and the N initial answers is:
[0095]
[0096] In the formula, L1 is the first loss, N is the number of sample answers and the number of keywords in the initial answer, and X is... 1i Let X be the answer vector for the i-th sample. 2i Let i be the keyword vector for the i-th initial answer, i = 1, 2, ..., N.
[0097] When the sample question-answer category is the same as the first question-answer category or the second question-answer category, the second loss is L2 = 0. When the sample question-answer category is different from both the first and second question-answer categories, the second loss is L2 = 1.
[0098] Then, the first loss and the second loss are substituted into the preset loss relationship model to calculate the first model loss. In this embodiment, the preset loss relationship model is the product of the first loss and the preset first loss weight, plus the product of the second loss and the preset second loss weight, so the first model loss is:
[0099] L=α1L1+α2L2
[0100] In the formula, L is the first model loss, α1 is the preset first loss weight, L1 is the first loss, α2 is the preset second loss weight, and L2 is the second loss.
[0101] The specific values of α1 and α2 can be set according to the actual situation. In this embodiment, α1 = 0.7 and α2 = 0.3 are set according to the actual situation.
[0102] Optionally, the question-answering classification model includes a classification encoder and a fully connected layer. It determines the sample answer keywords based on the sample answers, uses the sample answer keywords as training samples, and uses the actual question-answering category of the training samples as training labels.
[0103] The training process of a question-answering classification model includes:
[0104] The keywords of the sample answers are input into the classification encoder for feature extraction to obtain the sample category features;
[0105] The sample category features are input into the fully connected layer to obtain the sample question-answer category;
[0106] The second model loss is calculated based on the sample question-answer category and the corresponding actual question-answer category. The parameters of the classification encoder and the fully connected layer are then corrected in reverse using the gradient descent method until the second model loss converges, resulting in a trained question-answer classification model.
[0107] First, the keyword extraction algorithm is used to extract the sample answer keywords from the sample answers. Then, the sample answer keywords are used as training samples, and the actual question and answer categories of the training samples are used as training labels to train the question and answer classification model.
[0108] Specifically, the keywords of the sample answer are input into the classification encoder for feature extraction to obtain the sample category features. The sample category features are then input into the fully connected layer to obtain the sample question-and-answer category. The second model loss is calculated based on the sample question-and-answer category and the corresponding actual question-and-answer category. The larger the second model loss, the lower the classification accuracy of the question-and-answer classification model. Therefore, the parameters of the classification encoder and the fully connected layer need to be corrected in reverse using the gradient descent method until the second model loss converges, resulting in a trained question-and-answer classification model.
[0109] This invention, through its embodiments, concatenates an initial question text, an initial answer text, and preset category hints to form a first sample. Then, it uses a text back-translation model to obtain amplified question text, amplified answer text, and amplified answer keywords, which are then concatenated to form a second sample. This not only expands the text data but also distinguishes between the question and answer texts by setting category hints, thus solving the problem of confusion between the two texts in the concatenated result. Furthermore, by obtaining the first question-and-answer category of the initial answer keywords and concatenating it as the label of the first sample, and obtaining the second question-and-answer category of the amplified answer keywords and concatenating it as the label of the second sample, the response performance of the dialogue model on different question categories is improved by incorporating question-and-answer category information into the labels. Finally, using the first and second samples as training samples, and the labels of the first and second samples as training labels, the preset dialogue model is trained, effectively improving the accuracy of the trained dialogue model and enhancing the dialogue accuracy of customer service robots in the fintech field, thereby improving the service efficiency and quality of financial services.
[0110] Corresponding to the dialogue model training method in the above embodiment, Figure 3 A structural block diagram of the AI-based dialogue model training device provided in Embodiment 2 of the present invention is given. For ease of explanation, only the parts related to the embodiments of the present invention are shown.
[0111] See Figure 3 The dialogue model training device includes:
[0112] The first sample splicing module 31 is used to splice the acquired initial question text, initial answer text and preset category prompt words, and determine the corresponding splicing result as the first sample;
[0113] The first label splicing module 32 is used to extract the initial answer keywords from the initial answer text, input the initial answer keywords into the pre-trained question-answering classification model to obtain the first question-answering category, splice the initial answer keywords and the first question-answering category, and determine the splicing result as the label of the first sample;
[0114] The second sample splicing module 33 is used to input the initial question text, initial answer text and initial answer keywords into the trained text back translation model to obtain the amplified question text, amplified answer text and amplified answer keywords. The amplified question text, amplified answer text and preset category prompt words are spliced together to determine the corresponding splicing result as the second sample.
[0115] The second label splicing module 34 is used to input the augmented answer keywords into the pre-trained question-answer classification model to obtain the second question-answer category, splice the augmented answer keywords and the second question-answer category, and determine the splicing result as the label of the second sample;
[0116] The dialogue model training module 35 is used to train a preset dialogue model using the first sample and the second sample as training samples and the labels of the first sample and the second sample as training labels, so as to obtain a trained dialogue model.
[0117] Optionally, the first sample splicing module 31 mentioned above includes:
[0118] The first concatenation submodule is used to pre-define category prompt terms, including the first sub-term and the second sub-term. It concatenates the obtained initial question text and the first sub-term to obtain the question prompt text.
[0119] The second concatenation submodule is used to concatenate the obtained initial answer text and the second sub-item to obtain the answer hint text;
[0120] The third splicing submodule is used to splice the question prompt text and the answer prompt text, and determine the corresponding splicing result as the first sample.
[0121] Optionally, the second sample splicing module 33 mentioned above includes:
[0122] The text back translation model determination submodule is used to determine whether the text back translation model includes a first language conversion submodel and a second language conversion submodel.
[0123] The first language conversion submodule is used to input the initial question text, initial answer text, and initial answer keywords into the first language conversion submodel to obtain the first initial question text, the first initial answer text, and the first initial answer keywords.
[0124] The second language conversion submodule is used to input the first initial question text, the first initial answer text, and the first initial answer keywords into the second language conversion submodel to obtain the second initial question text, the second initial answer text, and the second initial answer keywords.
[0125] The augmented data determination submodule is used to deduplicatize the initial question text, initial answer text, initial answer keywords, second initial question text, second initial answer text, and second initial answer keywords to obtain augmented question text, augmented answer text, and augmented answer keywords.
[0126] Optionally, the above-mentioned amplified data determination submodule includes:
[0127] The first augmented data determination unit is used to calculate the first similarity between the initial question text and the second initial question text, and to use the second initial question text whose first similarity is not greater than a first preset threshold as the augmented question text.
[0128] The second amplified data determination unit is used to calculate the second similarity between the initial answer text and the second initial answer text, and to take the second initial answer text whose second similarity is not greater than the second preset threshold as the amplified answer text;
[0129] The third amplified data determination unit is used to calculate the third similarity between the initial answer keywords and the second initial answer keywords, and to use the second initial answer keywords whose third similarity is not greater than the third preset threshold as the amplified answer keywords.
[0130] Optionally, the dialogue model training module 35 mentioned above includes:
[0131] The question-answering feature extraction submodule is used in dialogue models, which include encoders and decoders. It uses the first and second samples as training samples, inputs the training samples into the encoder to extract features, and obtains question-answering features.
[0132] The question-and-answer feature decoding submodule is used to input question-and-answer features into the decoder to obtain sample answers;
[0133] The first question-and-answer classification submodule is used to input sample answers into a pre-trained question-and-answer classification model to obtain the sample question-and-answer category;
[0134] The first parameter correction submodule is used to calculate the first model loss based on the sample answer, sample question-answer category and corresponding training label, and then correct the parameters of the encoder and decoder in reverse according to the gradient descent method until the model loss converges, thus obtaining the trained dialogue model.
[0135] Optionally, the aforementioned first parameter correction submodule includes:
[0136] The training label determination unit is used to determine the training labels, including the corresponding initial answer keywords and the corresponding question and answer categories.
[0137] The first and second loss calculation units are used to calculate the first loss between the sample answer and the corresponding initial answer keywords, and to calculate the second loss between the sample question-and-answer category and the first question-and-answer category or the second question-and-answer category.
[0138] The model loss calculation unit is used to substitute the first loss and the second loss into a preset loss relationship model to calculate the first model loss.
[0139] Optionally, the first question-and-answer classification submodule mentioned above includes:
[0140] The first question-answer classification submodule is used to determine the question-answer classification model, which includes a classification encoder and a fully connected layer. It determines the sample answer keywords based on the sample answers, uses the sample answer keywords as training samples, and uses the actual question-answer category of the training samples as training labels.
[0141] The category feature extraction unit is used to input sample answer keywords into the classification encoder for feature extraction to obtain sample category features;
[0142] The question-answer category determination unit is used to input the sample category features into the fully connected layer to obtain the sample question-answer category.
[0143] The second parameter correction unit is used to calculate the second model loss based on the sample question-answer category and the corresponding actual question-answer category. It then uses gradient descent to back-correct the parameters of the classification encoder and the fully connected layer until the second model loss converges, thus obtaining the trained question-answer classification model.
[0144] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of the present invention. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.
[0145] Figure 4 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Figure 4 As shown, the computer device of this embodiment includes: at least one processor ( Figure 4 Only one is shown in the diagram), a memory, and a computer program stored in the memory and capable of running on at least one processor, which, when executed by the processor, implements the steps in any of the above-described embodiments of the dialogue model training methods.
[0146] This computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 4 The examples of computer devices are merely examples and do not constitute a limitation on computer devices. Computer devices may include more or fewer components than shown, or combinations of certain components, or different components, such as network interfaces, displays, and input devices.
[0147] The processor referred to can be a CPU, but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0148] Memory includes readable storage media, internal memory, etc., wherein internal memory can be the RAM of a computer device, providing an environment for the operation of the operating system and computer-readable instructions stored in the readable storage media. The readable storage media can be the hard drive of a computer device, or in other embodiments, it can be an external storage device of the computer device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, memory can include both internal storage units and external storage devices of a computer device. Memory is used to store the operating system, applications, bootloader, data, and other programs, such as program code for computer programs. Memory can also be used to temporarily store data that has been output or will be output.
[0149] Those skilled in the art will understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the functions described above can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this invention. The specific working process of the units and modules in the above device can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention can implement all or part of the processes in the methods of the above embodiments by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the above method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium can include at least: any entity or device capable of carrying computer program code, a recording medium, a computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0150] The present invention can implement all or part of the processes in the methods of the above embodiments, or it can be accomplished by a computer program product. When the computer program product is run on a computer device, the computer device executes the steps in the above method embodiments.
[0151] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0152] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0153] In the embodiments provided by this invention, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0154] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0155] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for training a dialogue model based on artificial intelligence, characterized in that, The dialogue model training method includes: The initial question text, initial answer text, and preset category prompts are concatenated, and the corresponding concatenation result is determined as the first sample. Extract initial answer keywords from the initial answer text, input the initial answer keywords into a pre-trained question-answering classification model to obtain a first question-answering category, and concatenate the initial answer keywords and the first question-answering category to determine the concatenation result as the label of the first sample; The initial question text, the initial answer text, and the initial answer keywords are respectively input into the trained text back translation model to obtain the augmented question text, the augmented answer text, and the augmented answer keywords. The augmented question text, the augmented answer text, and the preset category prompt words are concatenated to determine the corresponding concatenation result as the second sample. The augmented answer keywords are input into the pre-trained question-answer classification model to obtain a second question-answer category. The augmented answer keywords and the second question-answer category are then concatenated to determine the concatenation result as the label of the second sample. Using the first sample and the second sample as training samples, and the labels of the first sample and the second sample as training labels, a preset dialogue model is trained to obtain a trained dialogue model. The step of concatenating the acquired initial question text, initial answer text, and preset category prompt terms to determine the corresponding concatenation result as the first sample includes: The preset category prompt term includes a first sub-term and a second sub-term. The obtained initial question text and the first sub-term are concatenated to obtain the question prompt text. The initial answer text and the second sub-item are concatenated to obtain the answer hint text; The question prompt text and the answer prompt text are concatenated, and the corresponding concatenation result is determined as the first sample; The step of inputting the initial question text, the initial answer text, and the initial answer keywords into the trained text back translation model to obtain the augmented question text, the augmented answer text, and the augmented answer keywords includes: The text back translation model includes a first language conversion sub-model and a second language conversion sub-model; The initial question text, the initial answer text, and the initial answer keywords are respectively input into the first language conversion sub-model to obtain the first initial question text, the first initial answer text, and the first initial answer keywords; The first initial question text, the first initial answer text, and the first initial answer keywords are respectively input into the second language conversion sub-model to obtain the second initial question text, the second initial answer text, and the second initial answer keywords. The initial question text, the initial answer text, the initial answer keywords, the second initial question text, the second initial answer text, and the second initial answer keywords are deduplicated to obtain the expanded question text, the expanded answer text, and the expanded answer keywords.
2. The dialogue model training method according to claim 1, characterized in that, The process of deduplicating the initial question text, the initial answer text, the initial answer keywords, the second initial question text, the second initial answer text, and the second initial answer keywords to obtain the expanded question text, the expanded answer text, and the expanded answer keywords includes: Calculate the first similarity between the initial question text and the second initial question text, and use the second initial question text whose first similarity is not greater than a first preset threshold as the expanded question text; Calculate the second similarity between the initial answer text and the second initial answer text, and use the second initial answer text whose second similarity is not greater than a second preset threshold as the amplified answer text; Calculate the third similarity between the initial answer keywords and the second initial answer keywords, and use the second initial answer keywords whose third similarity is not greater than a third preset threshold as the amplified answer keywords.
3. The dialogue model training method according to claim 1, characterized in that, The step of training a preset dialogue model using the first sample and the second sample as training samples, and the labels of the first sample and the second sample as training labels, to obtain a trained dialogue model includes: The dialogue model includes an encoder and a decoder. The first sample and the second sample are used as training samples. The training samples are input into the encoder for feature extraction to obtain question-answering features. The question-and-answer features are input into the decoder to obtain sample answers; The sample answers are input into a pre-trained question-and-answer classification model to obtain the sample question-and-answer categories; The first model loss is calculated based on the sample answer, the sample question-answer category, and the corresponding training label. The parameters of the encoder and the decoder are then corrected in reverse using the gradient descent method until the first model loss converges, resulting in a trained dialogue model.
4. The dialogue model training method according to claim 3, characterized in that, The step of calculating the first model loss based on the sample answer, the sample question-answer category, and the corresponding training label includes: The training labels include the corresponding initial answer keywords and the corresponding question and answer categories; Calculate the first loss between the sample answer and the corresponding keywords of the initial answer, and calculate the second loss between the sample question-and-answer category and the first question-and-answer category or the second question-and-answer category; Substitute the first loss and the second loss into a preset loss relationship model to calculate the first model loss.
5. The dialogue model training method according to claim 3, characterized in that, The question-answering classification model includes a classification encoder and a fully connected layer. It determines sample answer keywords based on the sample answers, uses the sample answer keywords as training samples, and uses the actual question-answering categories of the training samples as training labels. The training process of the question-answering classification model includes: The keywords of the sample answer are input into the classification encoder for feature extraction to obtain the sample category features; The sample category features are input into the fully connected layer to obtain the sample question-answer category; The second model loss is calculated based on the sample question-answer category and the corresponding actual question-answer category. The parameters of the classification encoder and the fully connected layer are then corrected in reverse using the gradient descent method until the second model loss converges, resulting in a trained question-answer classification model.
6. A dialogue model training device based on artificial intelligence, characterized in that, The dialogue model training device includes: The first sample splicing module is used to splice the acquired initial question text, initial answer text, and preset category prompt words, and determine the corresponding splicing result as the first sample; The first tag splicing module is used to extract initial answer keywords from the initial answer text, input the initial answer keywords into a pre-trained question-answer classification model to obtain a first question-answer category, and splice the initial answer keywords and the first question-answer category to determine the splicing result as the tag of the first sample; The second sample splicing module is used to input the initial question text, the initial answer text, and the initial answer keywords into the trained text back translation model to obtain the augmented question text, the augmented answer text, and the augmented answer keywords. The module then splices the augmented question text, the augmented answer text, and the preset category prompt words to determine the corresponding splicing result as the second sample. The second label splicing module is used to input the augmented answer keywords into the pre-trained question-answer classification model to obtain a second question-answer category, and to splice the augmented answer keywords and the second question-answer category to determine the splicing result as the label of the second sample; The dialogue model training module is used to train a preset dialogue model using the first sample and the second sample as training samples and the labels of the first sample and the second sample as training labels, so as to obtain a trained dialogue model. The first sample stitching module includes: The first concatenation submodule is used to pre-define category prompt terms, including the first sub-term and the second sub-term. It concatenates the obtained initial question text and the first sub-term to obtain the question prompt text. The second concatenation submodule is used to concatenate the obtained initial answer text and the second sub-item to obtain the answer hint text; The third splicing submodule is used to splice the question prompt text and the answer prompt text, and determine the corresponding splicing result as the first sample; The second sample stitching module includes: The text back translation model determination submodule is used to determine whether the text back translation model includes a first language conversion submodel and a second language conversion submodel. The first language conversion submodule is used to input the initial question text, initial answer text, and initial answer keywords into the first language conversion submodel to obtain the first initial question text, the first initial answer text, and the first initial answer keywords. The second language conversion submodule is used to input the first initial question text, the first initial answer text, and the first initial answer keywords into the second language conversion submodel to obtain the second initial question text, the second initial answer text, and the second initial answer keywords. The augmented data determination submodule is used to deduplicatize the initial question text, initial answer text, initial answer keywords, second initial question text, second initial answer text, and second initial answer keywords to obtain augmented question text, augmented answer text, and augmented answer keywords.
7. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the dialogue model training method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the dialogue model training method as described in any one of claims 1 to 5.