A method and device for question and answer recognition, an electronic device and a readable storage medium

By constructing a small-scale student model and utilizing the knowledge distillation technique of the teacher model, the problems of high computational complexity and high resource consumption in question-answering recognition of the BERT model were solved, achieving faster response speed and lower resource consumption, and reducing project costs.

CN114357138BActive Publication Date: 2026-03-31阳光保险集团股份有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-07
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In existing technologies, the BERT model has high computational complexity, slow response speed and high resource consumption in question answering recognition, resulting in low efficiency in answering questions.

Method used

A knowledge distillation-based approach is adopted, in which a small-scale student model is trained using a teacher model, and a teacher model is constructed using a bidirectional encoding representation model of the converter. The knowledge in the teacher model is then transferred to the student model, thereby achieving model compression and quantization, and reducing the latency and resource consumption of model invocation.

Benefits of technology

It improves the response speed of question-answering recognition, reduces training complexity and resource consumption, and saves project costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114357138B_ABST
    Figure CN114357138B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of artificial intelligence, and discloses a question and answer identification method and device, electronic equipment and readable storage medium, the method comprises the following steps: receiving a question and answer request for a target question; based on the question and answer request for the target question, a pre-trained question and answer model is used to determine the answer corresponding to the target question; wherein the question and answer model is a student model obtained based on a second sample data set and a teacher model, and the teacher model is constructed based on a first sample data set and a transformer-based bidirectional encoding representation model. In this way, when question and answer identification is performed, the response speed of question answering can be improved and resource consumption can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a method, apparatus, electronic device, and readable storage medium for question-and-answer recognition. Background Technology

[0002] With the development of artificial intelligence, there are more and more scenarios for human-computer interaction applications, which requires dialogue systems to recognize and answer users' questions.

[0003] In the current technology, pre-trained language representation models (Bidirectional Encoder Representation from Transformers, BERT) are usually used to identify questions and answer the corresponding questions, thereby realizing human-computer interaction.

[0004] However, the BERT model is large, requiring a large amount of sample data to train, and is highly complex. When answering questions, it requires a lot of data computation, resulting in a slow response speed and a large amount of resources being consumed.

[0005] Therefore, improving the response speed and reducing resource consumption in question-answering recognition is a technical problem that needs to be solved. Summary of the Invention

[0006] The purpose of this application is to provide a question-and-answer recognition method, apparatus, electronic device, and readable storage medium to improve the response speed of question answers and reduce resource consumption during question-and-answer recognition.

[0007] On the one hand, a question-answering recognition method is provided, including:

[0008] Receive question-and-answer requests for the target question;

[0009] Based on the question-and-answer request for the target question, a pre-trained question-and-answer model is used to determine the answer to the target question.

[0010] The question-answering model is a student model trained on the second sample data set and the teacher model, while the teacher model is constructed based on the first sample data set and a bidirectional encoding representation model based on the converter.

[0011] In the above implementation process, a teacher model is constructed based on the first sample data set and the bidirectional encoding representation model based on the converter. The student model is trained using the teacher model through knowledge distillation, and the knowledge in the teacher model is transferred to the student model, thereby obtaining a trained small-scale student model. This achieves model compression and quantization, reduces the latency of model invocation, improves response speed, and the training of small-scale student models does not require a large amount of data and resources. The training complexity is reduced, the resources consumed are reduced, and the project cost is saved.

[0012] In one implementation, based on a question-and-answer request for a target question, a pre-trained question-and-answer model is used to determine the answer corresponding to the target question, including:

[0013] Extract vector features of the target problem;

[0014] Input the vector features into the question answering model to obtain the answer output by the question answering model.

[0015] In the above implementation process, the vector features of the target question are input into the question answering model to obtain the answer output by the question answering model. By using the trained question answering model, question answer recognition is performed, which improves the response speed.

[0016] In one implementation, before determining the answer to the target question using a pre-trained question-answering model based on a question-answering request for the target question, the method further includes:

[0017] Obtain the first sample data set, which contains positive sample data, negative sample data, extended data, and negative extended data. Both the positive and negative sample data contain multiple question-answer combination samples and corresponding question-answer matching degrees. Both the extended and negative extended data contain multiple question-answer combination samples.

[0018] Based on question-answer combination samples in positive and negative sample data and the corresponding question-answer matching degree, the initial teacher model is trained to obtain a trained teacher model. The initial teacher model is obtained through a bidirectional encoding representation model based on a converter.

[0019] Based on the teacher model and extended data, the question-answer matching degree of each question-answer combination sample in the extended data is obtained;

[0020] Based on the teacher model and negative extended data, the question-answer matching degree of each question-answer combination sample in the negative extended data is obtained;

[0021] Based on the first sample data set, the question-answer matching degree of each question-answer combination sample in the extended data, and the question-answer matching degree of each question-answer combination sample in the extended data, a second sample data set is obtained.

[0022] Based on the second sample dataset, the initial student model is trained to obtain a well-trained student model, which is a question-answering model.

[0023] In the above implementation process, by training a small-scale student model using a well-trained teacher model, model compression and quantization are achieved. Training a small-scale student model does not require a large amount of data and resources, reducing training complexity, reducing resource consumption, and saving project costs.

[0024] In one implementation, before obtaining the first sample data set, the method further includes:

[0025] Obtain positive sample data. Each question-answer combination sample in the positive sample data includes a question sample and the corresponding answer.

[0026] The questions and answers in each question-answer combination sample in the positive sample data are randomly swapped to obtain the negative sample data. The negative sample data contains multiple swapped question-answer combination samples and the corresponding question-answer matching degree.

[0027] Based on the question samples and corresponding answers in the positive sample data, as well as the discriminative model in the data expansion model, the initial generative model in the data expansion model is trained to obtain the trained generative model. The data expansion model is built based on a generative adversarial network.

[0028] Based on the generative model and positive sample data, extended data is generated.

[0029] In the above implementation process, positive sample data is used to obtain extended data based on the generative model, and negative extended data is obtained based on the extended data, which expands the training data required for training the question answering model and improves the accuracy of question answering model training.

[0030] In one implementation, an initial teacher model is trained based on question-answer combination samples from positive and negative sample data and the corresponding question-answer matching degrees to obtain a trained teacher model, including:

[0031] Extract the vector features of each question-and-answer combination sample from both the positive and negative sample data.

[0032] Based on the vector features of each question-answer combination sample and the corresponding question-answer matching degree, the initial teacher model is trained to obtain a well-trained teacher model.

[0033] In the above implementation process, the teacher model is trained by using the vector features of positive and negative sample data and the corresponding question-answer matching degree. In subsequent steps, the teacher model can be directly used to train the student model.

[0034] In one implementation, after generating extended data based on the generative model and positive sample data, the method further includes:

[0035] Set the question-answer matching degree of each question-answer combination sample in the positive sample data to the first preset matching degree;

[0036] Set the question-answer matching degree of each question-answer combination sample in the negative sample data to the second preset matching degree;

[0037] Randomly swap the questions and answers in each question-and-answer combination sample in the extended data to obtain negative extended data, which contains multiple swapped question-and-answer combination samples.

[0038] Based on the extended data, negative extended data, and teacher model, the question-answer matching degree of each question-answer combination sample in the extended data and the question-answer matching degree of each question-answer combination sample in the negative extended data are obtained respectively.

[0039] In the above implementation process, the question-answer matching degree of each question-answer combination sample in the extended data and negative extended data is obtained through the teacher model, which is then used when training the student model.

[0040] In one implementation, an initial student model is trained based on a second sample dataset to obtain a trained student model, which is a question-answering model, including:

[0041] Extract the vector features of each question-and-answer combination sample from the second sample dataset;

[0042] The vector features of each question-and-answer combination sample are input into the initial student model to obtain the predicted matching degree of each question-and-answer combination sample.

[0043] Based on the set weights for the student model and the set weights for the teacher model, the prediction matching degree and question-answer matching degree of each question-answer combination sample in the second sample dataset are weighted and summed to obtain the comprehensive matching degree.

[0044] Based on the overall matching degree and the set matching degree, determine the matching degree loss;

[0045] If the matching loss is less than the set loss value, a well-trained student model is obtained; otherwise, the model parameters of the initial student model are adjusted based on the matching loss until the matching loss determined based on the adjusted initial student model is less than the set loss value.

[0046] In the above implementation process, based on the second sample dataset, the matching degree loss is obtained by using the predicted matching degree and question-answer matching degree of each question-answer combination sample. Based on the matching degree loss, the parameters of the student model are adjusted until the student model training is completed, which improves the model response speed. Small-scale student model training does not require a large amount of data and resources, reducing resource consumption and saving project costs.

[0047] On the one hand, a question-and-answer recognition device is provided, comprising:

[0048] The receiving unit is used to receive question-and-answer requests for the target question.

[0049] The determination unit is used to determine the answer to the target question based on a question-and-answer request for the target question, using a pre-trained question-and-answer model.

[0050] The question-answering model is a student model trained on the second sample data set and the teacher model, while the teacher model is constructed based on the first sample data set and a bidirectional encoding representation model based on the converter.

[0051] In one implementation, the determining unit is specifically used for:

[0052] Extract vector features of the target problem;

[0053] Input the vector features into the question answering model to obtain the answer output by the question answering model.

[0054] In one embodiment, the receiving unit is further configured to:

[0055] Obtain the first sample data set, which contains positive sample data, negative sample data, extended data, and negative extended data. Both the positive and negative sample data contain multiple question-answer combination samples and corresponding question-answer matching degrees. Both the extended and negative extended data contain multiple question-answer combination samples.

[0056] Based on question-answer combination samples in positive and negative sample data and the corresponding question-answer matching degree, the initial teacher model is trained to obtain a trained teacher model. The initial teacher model is obtained through a bidirectional encoding representation model based on a converter.

[0057] Based on the teacher model and extended data, the question-answer matching degree of each question-answer combination sample in the extended data is obtained;

[0058] Based on the teacher model and negative extended data, the question-answer matching degree of each question-answer combination sample in the negative extended data is obtained;

[0059] Based on the first sample data set, the question-answer matching degree of each question-answer combination sample in the extended data, and the question-answer matching degree of each question-answer combination sample in the extended data, a second sample data set is obtained.

[0060] Based on the second sample dataset, the initial student model is trained to obtain a well-trained student model, which is a question-answering model.

[0061] In one embodiment, the receiving unit is further configured to:

[0062] Obtain positive sample data. Each question-answer combination sample in the positive sample data includes a question sample and the corresponding answer.

[0063] The questions and answers in each question-answer combination sample in the positive sample data are randomly swapped to obtain the negative sample data. The negative sample data contains multiple swapped question-answer combination samples and the corresponding question-answer matching degree.

[0064] Based on the question samples and corresponding answers in the positive sample data, as well as the discriminative model in the data expansion model, the initial generative model in the data expansion model is trained to obtain the trained generative model. The data expansion model is built based on a generative adversarial network.

[0065] Based on the generative model and positive sample data, extended data is generated.

[0066] In one embodiment, the determining unit is further configured to:

[0067] Extract the vector features of each question-and-answer combination sample from both the positive and negative sample data.

[0068] Based on the vector features of each question-answer combination sample and the corresponding question-answer matching degree, the initial teacher model is trained to obtain the trained teacher model.

[0069] In one embodiment, the determining unit is further configured to:

[0070] Set the question-answer matching degree of each question-answer combination sample in the positive sample data to the first preset matching degree;

[0071] Set the question-answer matching degree of each question-answer combination sample in the negative sample data to the second preset matching degree;

[0072] Randomly swap the questions and answers in each question-and-answer combination sample in the extended data to obtain negative extended data, which contains multiple swapped question-and-answer combination samples.

[0073] Based on the extended data, negative extended data, and teacher model, the question-answer matching degree of each question-answer combination sample in the extended data and the question-answer matching degree of each question-answer combination sample in the negative extended data are obtained respectively.

[0074] In one embodiment, the determining unit is further configured to:

[0075] Extract the vector features of each question-and-answer combination sample from the second sample dataset;

[0076] The vector features of each question-and-answer combination sample are input into the initial student model to obtain the predicted matching degree of each question-and-answer combination sample.

[0077] Based on the set weights for the student model and the set weights for the teacher model, the prediction matching degree and question-answer matching degree of each question-answer combination sample in the second sample dataset are weighted and summed to obtain the comprehensive matching degree.

[0078] Based on the overall matching degree and the set matching degree, determine the matching degree loss;

[0079] If the matching loss is less than the set loss value, a well-trained student model is obtained; otherwise, the model parameters of the initial student model are adjusted based on the matching loss until the matching loss determined based on the adjusted initial student model is less than the set loss value.

[0080] On one hand, an electronic device is provided, including a processor and a memory storing computer-readable instructions that, when executed by the processor, perform the steps of the method provided in any of the above-described alternative implementations of question-and-answer recognition.

[0081] On the one hand, a readable storage medium is provided on which a computer program is stored, which, when executed by a processor, performs the steps of the methods provided in any of the various alternative implementations of the question-and-answer recognition described above.

[0082] On the one hand, a computer program product is provided that, when run on a computer, causes the computer to perform the steps of the methods provided in various alternative implementations of any of the above-described question-answering recognition methods.

[0083] This application provides a question-and-answer recognition method, apparatus, electronic device, and readable storage medium. The method receives a question-and-answer request for a target question. Based on the request, a pre-trained question-and-answer model is used to determine the answer to the target question. The question-and-answer model is a student model trained on a second sample dataset and a teacher model. The teacher model is constructed based on a first sample dataset and a bidirectional encoding representation model based on a converter. By constructing the teacher model based on the first sample dataset and the bidirectional encoding representation model based on the converter, and then training the student model using the teacher model through knowledge distillation, the knowledge from the teacher model is transferred to the student model, resulting in a trained small-scale student model. This achieves model compression and quantization, reduces model call latency, improves response speed, and the small-scale student model training does not require a large amount of data and resources, reducing training complexity, resource consumption, and project costs.

[0084] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0085] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0086] Figure 1 This application provides a schematic diagram of the architecture of a question-answering recognition system.

[0087] Figure 2 A flowchart illustrating the implementation of a question-and-answer recognition method provided in this application embodiment;

[0088] Figure 3 A detailed implementation flowchart of a method for constructing a student model provided in this application embodiment;

[0089] Figure 4 A structural block diagram of a question-and-answer recognition device provided in an embodiment of this application;

[0090] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0091] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0092] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0093] First, some of the terms used in the embodiments of this application will be explained to facilitate understanding by those skilled in the art.

[0094] Terminal devices can be mobile terminals, fixed terminals, or portable terminals, such as mobile phones, sites, units, devices, multimedia computers, multimedia tablets, internet nodes, communicators, desktop computers, laptop computers, notebook computers, netbook computers, tablet computers, personal communication system devices, personal navigation devices, personal digital assistants, audio / video players, digital cameras / camcorders, positioning devices, television receivers, radio broadcast receivers, e-book devices, gaming devices, or any combination thereof, including accessories and peripherals of these devices, or any combination thereof. It is also foreseeable that terminal devices can support any type of user-facing interface (e.g., wearable devices).

[0095] Servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and big data and artificial intelligence platforms.

[0096] Convolutional Neural Networks (CNNs) are a type of feedforward neural network that includes convolutional computations and has a deep structure. They have representation learning capabilities and can perform translation-invariant classification of input information according to their hierarchical structure.

[0097] Monte Carlo tree search is a search method based on probability and statistical theory.

[0098] Generative Adversarial Networks (GANs) are deep learning models that consist of two models: a generative model and a discriminative model. The generative and discriminative models learn from each other through a game and produce good outputs.

[0099] Generative model: refers to a model used to randomly generate observable data.

[0100] Discriminative Model: A model that models unknowns and knowns.

[0101] Loss function: A function that maps the values ​​of a random event or its related random variables to non-negative real numbers to represent the "risk" or "loss" of that random event.

[0102] Monte Carlo Tree Search (MCS): Also known as random sampling or statistical experimentation, this method realistically simulates actual physical processes and allows for random sampling or statistical experiments. It is a computational method based on probability and statistical theory, using random numbers to solve many computational problems.

[0103] In order to improve the response speed of question answering and reduce resource consumption during question answering, embodiments of this application provide a method, apparatus, electronic device and readable storage medium for question answering.

[0104] See Figure 1 The diagram shown is an architectural representation of a question-and-answer recognition system provided in an embodiment of this application. The system architecture includes a server configured with a discriminant model, a generator model, a student model, and a teacher model.

[0105] The discriminative model is used to train the generative model.

[0106] Generative models are used to generate extended data based on discriminative models and the obtained positive sample data.

[0107] The teacher model is used to: obtain the question-answer matching scores of positive sample data, negative sample data, extended data, and negative extended data, and to train the student model based on the question-answer matching scores of positive sample data, negative sample data, extended data, and negative extended data.

[0108] The student model is used to: input a target question and obtain the corresponding answer to the target question.

[0109] In one implementation, the server acquires positive sample data, wherein each question-answer combination sample in the positive sample data includes a question sample and a corresponding answer. The server then randomly swaps the questions and answers in each question-answer combination sample in the positive sample data to obtain negative sample data and the corresponding question-answer matching degree. Based on each question sample and corresponding answer in the positive sample data, and the discriminative model in the data expansion model, the server trains a generative model and obtains the trained generative model. The server then acquires the expanded data generated by the generative model and randomly swaps the questions and answers in each question-answer combination sample in the expanded data to obtain negative expanded data.

[0110] The server trains a teacher model based on question-answer combination samples and their corresponding question-answer matching scores from both positive and negative sample data. The server then inputs the expanded data and negative expanded data into the teacher model, obtaining the question-answer matching score for each question-answer combination sample in the expanded data and the question-answer matching score for each question-answer combination sample in the negative expanded data.

[0111] The server extracts vector features from each question-and-answer combination sample in the positive sample data, negative sample data, extended data, and negative extended data. These vector features are then input into the initial student model to obtain the predicted matching degree for each question-and-answer combination sample. Based on set weights for the student model and the teacher model, the server performs a weighted sum of the predicted and question-and-answer matching degrees from the positive, negative, extended, and negative extended data to obtain the overall matching degree. The server compares the overall matching degree with a set loss value. If the matching degree loss is less than the set loss value, the trained student model is obtained.

[0112] When the server determines that it has received a question-and-answer request for the target question, it uses a trained student model to determine the answer to the target question.

[0113] In this way, a teacher model is constructed based on question-and-answer combination samples from positive and negative sample data, the corresponding question-and-answer matching degree, and a bidirectional encoding representation model based on a converter. Through knowledge distillation, the student model is trained using the teacher model, and the knowledge in the teacher model is transferred to the student model, thereby obtaining a well-trained small-scale student model. This achieves model compression and quantization, reduces the latency of model invocation, improves response speed, and the training of small-scale student models does not require a large amount of data and resources, reducing training complexity, reducing resource consumption, and saving project costs.

[0114] In this embodiment, only the server is used as the execution subject for illustration. In actual applications, the execution subject can also be other electronic devices such as terminal devices, and there is no limitation here.

[0115] See Figure 2 The diagram shown is an implementation flowchart of a question-and-answer recognition method provided in this application embodiment. Figure 1 The specific implementation process of this method in the server of the question-answering recognition system is as follows:

[0116] Step 200: Receive a question-and-answer request for the target question.

[0117] Step 201: Based on the question-and-answer request for the target question, use a pre-trained question-and-answer model to determine the answer corresponding to the target question.

[0118] Specifically, to execute step 201, the following steps can be performed:

[0119] S2011: Extract vector features of the target problem.

[0120] Specifically, a vector transformation algorithm is used to convert the target question into a text vector, and a convolution kernel is used to extract the vector features of the target question.

[0121] Optionally, convolutional kernels of 2*2, 3*3, and 4*4 sizes can be used to extract vector features of the target problem. Alternatively, a Chinese Language Model (CLM) can be used to extract vector features of the target problem by taking 2, 3, and 4 characters to form words.

[0122] In practical applications, other sizes of convolution kernels can also be used, and no restrictions are imposed here.

[0123] Among them, vector transformation algorithms can be algorithms that convert text into text vectors.

[0124] Optionally, the vector transformation algorithm can be a text classification algorithm (TextCNN) or a fast text classifier (FastText).

[0125] In practical applications, other algorithms can also be used for vector transformation, which are not limited here.

[0126] S2012: Input the vector features into the question answering model to obtain the answer output by the question answering model.

[0127] Specifically, the vector features of the target question are input into the question-answering model to obtain the answer output by the question-answering model.

[0128] The question-answering model is a student model trained on the second sample data set and the teacher model, while the teacher model is constructed based on the first sample data set and a bidirectional encoding representation model based on the converter.

[0129] Furthermore, before performing step 200, the following steps may also be performed:

[0130] Step 1: Obtain the first sample data set.

[0131] The first sample dataset contains positive sample data, negative sample data, and extended data. Both the positive and negative sample data contain multiple question-answer combination samples and their corresponding question-answer matching degrees. The extended data contains multiple question-answer combination samples.

[0132] Before performing step one, the following steps can also be performed:

[0133] Step A: Obtain positive sample data.

[0134] Each question-and-answer combination sample in the positive sample data includes a question sample and the corresponding answer.

[0135] Optionally, questions and answers can be stored in the database in the form of "question_Sep_answer".

[0136] Furthermore, after obtaining the positive sample data, word segmentation can be performed to obtain the word vector text of the positive sample data. Then, stop words, spaces, and other meaningless words can be removed. Alternatively, similarity calculation methods can be used to obtain data with high similarity and remove them.

[0137] In one implementation, edit distance can be used to calculate the score of each data in the database, filter out data with a similarity higher than 98%, and delete duplicate data.

[0138] In this way, positive sample data can be obtained.

[0139] Step B: Randomly swap the questions and answers in each question-answer combination sample of the positive sample data to obtain the negative sample data.

[0140] Specifically, the questions and answers in each question-and-answer combination sample in the positive sample data are randomly swapped, and the swapped question-and-answer combination samples are used to form the negative sample data.

[0141] The negative sample data includes multiple swapped question-and-answer combination samples, as well as the corresponding question-and-answer matching scores.

[0142] In one implementation, the positive sample data contains two question-answer combination samples, “Question 1_Sep_Answer 1” and “Question 2_Sep_Answer 2”. The questions and answers in the two question-answer combination samples in the positive sample data are randomly swapped to obtain negative sample data, namely “Question 1_Sep_Answer 2” and “Question 2_Sep_Answer 1”.

[0143] In this way, negative sample data can be obtained.

[0144] Step C: Based on the question samples and corresponding answers in the positive sample data, as well as the discriminant model in the data expansion model, train the initial generative model in the data expansion model to obtain the trained generative model.

[0145] The data expansion model is built on generative adversarial networks.

[0146] Specifically, based on the question samples and corresponding answers in the positive sample data, as well as the discriminant model in the data expansion model, the maximum likelihood estimation (MLE) method is used to iteratively train the initial generative model in the data expansion model and update the policy gradient until the initial generative model converges, thus obtaining the trained generative model.

[0147] In practical applications, other methods can also be used to train the initial generative model, and no restrictions are imposed here.

[0148] Before obtaining a trained generative model, the initial generative model updates its own parameters cyclically based on the generated data until the generative model converges, thus obtaining a trained generative model.

[0149] Monte Carlo tree search can be used to update the policy gradient.

[0150] Furthermore, before obtaining a trained generative model, a loss function is set, and the loss function is optimized based on the loss function and the data generated by the initial generative model until a trained generative model is obtained.

[0151] In this way, the initial generative model in the data expansion model can be trained based on the question samples and corresponding answers in the positive sample data, as well as the discriminative model in the data expansion model, to obtain a trained generative model.

[0152] Step D: Generate extended data based on the generative model and positive sample data.

[0153] Specifically, based on the trained generative model and positive sample data, the generative model generates a preset number of extended data.

[0154] The preset number can be three times the number of positive sample data.

[0155] In practical applications, the preset number can also be other multiples of the positive sample data, and there is no restriction here.

[0156] The initial extended data generated by the initial generation model can be distributed using the Dirichlet function.

[0157] In one implementation, based on the trained generative model and positive sample data, the generative model generates extended data equivalent to 5 times the positive sample data, and extracts extended data equivalent to 3 times the positive sample data for subsequent operations.

[0158] In one implementation, if the positive sample data is "We've checked and found that you purchased our company's Whole Life Insurance Plan B. Could you please tell us why you no longer want this insurance? _Sep_ I wanted to buy the kind that covers both major and minor illnesses, but after looking at your contract, it's not what I expected.", then based on the trained generative model and the positive sample data, the extended data generated by the generative model for step 3 could be: "We've checked and found that you purchased our company's Whole Life Insurance Plan B. Could you please tell us why you no longer want this policy and want to cancel it? _Sep_ After reviewing the contract..." "I found it's not what I expected, because I wanted to buy an insurance product that covers both major and minor illnesses." "I checked and found that you purchased our company's Whole Life Insurance Plan B. What is the reason you don't want this insurance and want to cancel it? I wanted to buy an insurance product that covers both major and minor illnesses, but the terms in the contract are not what I wanted." And "What is the reason you don't want our company's Whole Life Insurance Plan B and want to cancel it? I originally wanted to buy an insurance product that covers both major and minor illnesses, but the terms in the contract are not what I wanted."

[0159] In this way, we can obtain the extended data generated by the generative model.

[0160] Furthermore, after performing step D, the following steps may also be performed:

[0161] Step a: Set the question-answer matching degree of each question-answer combination sample in the positive sample data to the first preset matching degree.

[0162] Specifically, the question-answer matching degree of each question-answer combination sample in the positive sample data is set as the first preset matching degree.

[0163] Optionally, the first preset matching degree can be 1.0.

[0164] In practical applications, the first preset matching degree can also be other than that, and no restrictions are imposed here.

[0165] Step b: Set the question-answer matching degree of each question-answer combination sample in the negative sample data to the second preset matching degree.

[0166] Specifically, the question-answer matching degree of each question-answer combination sample in the negative sample data is set as the second preset matching degree.

[0167] Optionally, the second preset matching degree can be 0.0.

[0168] In practical applications, the second preset matching degree can also be other than that, and no restrictions are imposed here.

[0169] Step c: Randomly swap the questions and answers in each question-answer combination sample in the extended data to obtain negative extended data.

[0170] The negative extended data contains multiple swapped question-and-answer combination samples.

[0171] In one implementation, half of the question-and-answer combination samples in the expanded data are selected, and the questions and answers of the selected half of the question-and-answer combination samples are randomly swapped to obtain negative expanded data.

[0172] Step d: Based on the extended data, negative extended data, and teacher model, obtain the question-answer matching degree of each question-answer combination sample in the extended data and the question-answer matching degree of each question-answer combination sample in the negative extended data.

[0173] Specifically, based on extended data, negative extended data, and the teacher model, the question-answer matching degree of each question-answer combination sample in the extended data and the question-answer matching degree of each question-answer combination sample in the negative extended data are obtained respectively.

[0174] In this way, we can obtain the question-answer matching degree of each question-answer combination sample in the positive sample data, negative sample data, extended data, and negative extended data.

[0175] Step 2: Based on the question-answer combination samples in the positive and negative sample data and the corresponding question-answer matching degree, train the initial teacher model to obtain a trained teacher model.

[0176] The initial teacher model was obtained through a converter-based bidirectional encoding representation model.

[0177] Specifically, step two can be performed by following these steps:

[0178] Step E: Extract the vector features of each question-and-answer combination sample from the positive and negative sample data respectively.

[0179] Specifically, a vector transformation algorithm is used to convert each question-and-answer combination sample in the positive and negative sample data into a text vector, and a convolution kernel is used to extract the vector features of each question-and-answer combination sample in the positive and negative sample data.

[0180] Furthermore, Google's open-source pre-trained language representation model BERT can be used to perform sentence vector representation, transforming text into text vectors.

[0181] In this way, we can obtain the vector features of each question-and-answer combination sample in both the positive and negative sample data.

[0182] Step F: Based on the vector features of each question-answer combination sample and the corresponding question-answer matching degree, train the initial teacher model to obtain a trained teacher model.

[0183] Specifically, based on the vector features of question-answer combination samples in positive and negative sample data and the corresponding question-answer matching degree, the initial teacher model is trained to obtain a well-trained teacher model.

[0184] Alternatively, a method based on fine-tuning a bidirectional encoding representation model using a converter can be employed to obtain the teacher model.

[0185] Furthermore, after obtaining the trained teacher model, the teacher model is saved.

[0186] In this way, a well-trained teacher model can be obtained.

[0187] Step 3: Based on the teacher model and the extended data, obtain the question-answer matching degree for each question-answer combination sample in the extended data.

[0188] Specifically, each question-answer combination sample in the extended data is input into the teacher model to obtain the question-answer matching degree for each question-answer combination sample in the extended data.

[0189] The output of the teacher model can be in the form of [score, question_Sep_answer].

[0190] In practical applications, the output of the teacher model can also take other forms, which are not restricted here.

[0191] Step 4: Based on the teacher model and the negative extended data, obtain the question-answer matching degree of each question-answer combination sample in the negative extended data.

[0192] Specifically, each question-answer combination sample in the negative extended data is input into the teacher model to obtain the question-answer matching degree of each question-answer combination sample in the negative extended data.

[0193] Step 5: Based on the question-answer matching degree of each question-answer combination sample in the first sample data set, the question-answer matching degree of each question-answer combination sample in the extended data, and the question-answer matching degree of each question-answer combination sample in the negative extended data, obtain the second sample data set.

[0194] Specifically, the question-answer matching degree of each question-answer combination sample in the extended data and the question-answer matching degree of each question-answer combination sample in the negative extended data are added to the first sample data set to obtain the second sample data set.

[0195] The second sample dataset can also be referred to as the full dataset.

[0196] Step 6: Based on the second sample dataset, train the initial student model to obtain a trained student model.

[0197] Among them, the trained student model is a question-answering model.

[0198] Specifically, to perform step six, you can follow these steps:

[0199] Step G: Extract the vector features of each question-and-answer combination sample in the second sample dataset.

[0200] Specifically, a vector transformation algorithm is used to convert each question-and-answer combination sample in the second sample dataset into a text vector, and a convolution kernel is used to extract the vector features of each question-and-answer combination sample in the second sample dataset.

[0201] Furthermore, the answer combination samples in the second sample dataset can be divided into a training set, a validation set, and a test set according to a preset ratio.

[0202] Among them, the answer combination samples in the second sample data set can be stored in the form of [score, question_Sep_answer].

[0203] In practical applications, other forms of storage can also be used, and no restrictions are imposed here.

[0204] The training set is used to train the student model, the validation set is used to validate the trained student model, and the test set is used to test the trained student model.

[0205] Optionally, a preset ratio of 7:2:1 can be used to divide the second sample data set into a training set, a validation set, and a test set.

[0206] In practical applications, other proportions can also be used for division, and no restrictions are imposed here.

[0207] In this way, the vector features of each question-and-answer combination sample in the second sample dataset can be extracted.

[0208] Step H: Input the vector features of each question-and-answer combination sample into the initial student model to obtain the predicted matching degree of each question-and-answer combination sample.

[0209] Specifically, the vector features of each question-and-answer combination sample are input into the initial student model to obtain the predicted matching degree of the question and answer for each question-and-answer combination sample.

[0210] The predicted matching degree can range from 0 to 1.

[0211] In practical applications, the range of predicted matching degree values ​​can also be other, and no restrictions are imposed here.

[0212] Step 1: Based on the set student model weights and the set teacher model weights, the predicted matching degree and question-answer matching degree of each question-answer combination sample in the second sample dataset are weighted and summed to obtain the comprehensive matching degree.

[0213] Specifically, based on the set weights for the student model and the teacher model, the predicted matching degree of each question-and-answer combination sample obtained from the student model and the question-and-answer matching degree of each question-and-answer combination sample obtained from the teacher model in the second sample dataset are weighted and summed to obtain the comprehensive matching degree of each question-and-answer combination sample.

[0214] In one implementation, the predicted matching degree of the question-and-answer combination sample obtained by the student model is S1, and the question-and-answer matching degree of the question-and-answer combination sample obtained by the teacher model is S2. The weight of the student model is set as α1, and the weight of the teacher model is set as α2. The predicted matching degree of S1 and the question-and-answer matching degree of S2 of the question-and-answer combination sample are weighted and summed, i.e., α1*S1+α2*S2, to obtain the comprehensive matching degree of the question-and-answer combination sample α1*S1+α2*S2.

[0215] The student model weights can be represented by α1, and the teacher model weights can be represented by α2.

[0216] In practical applications, the student model weights and teacher model weights can also be represented by other symbols, which are not restricted here.

[0217] The overall matching degree can range from 0 to 1.

[0218] Optionally, the student model weight can be 0.4 and the teacher model weight can be 0.6. In practical applications, the student model weight and the teacher model weight can also be other values, which are not restricted here.

[0219] In this way, the predicted matching degree of each question-answer combination sample obtained from the student model and the question-answer matching degree of each question-answer combination sample obtained from the teacher model can be weighted and summed to obtain the comprehensive matching degree of each question-answer combination sample.

[0220] Step J: Determine the matching loss based on the overall matching degree and the set matching degree.

[0221] Specifically, the matching loss is determined based on the obtained overall matching degree and the pre-set matching degree.

[0222] The matching degree is set in advance.

[0223] Optionally, the matching degree can be set to a value between 0 and 1, or other values; there are no restrictions here.

[0224] In this process, a loss function is pre-set, and the matching degree loss is determined based on the loss function.

[0225] Optionally, the loss function can be zero-one loss, absolute value loss, logarithmic loss, squared loss, exponential loss, perceptual loss, or cross-entropy loss, etc.

[0226] In practical applications, other loss functions can also be used, and no restrictions are imposed here.

[0227] In this way, the matching loss can be determined.

[0228] Step K: If the matching loss is less than the set loss value, the trained student model is obtained; otherwise, the model parameters of the initial student model are adjusted based on the matching loss until the matching loss determined based on the adjusted initial student model is less than the set loss value.

[0229] Specifically, if the matching loss is less than the set loss value, a well-trained student model is obtained; otherwise, the model parameters of the initial student model are adjusted based on the matching loss until the matching loss determined based on the adjusted initial student model is less than the set loss value, thus obtaining a well-trained student model.

[0230] Furthermore, after obtaining the trained question-answering model, the model is saved. When the question-answering model is used online, a search server (Elasticsearch) can be used to obtain the answer and question-answer matching degree corresponding to the target question. The answer and question-answer matching degree output by the student model for the target question, as well as the question-answer matching degree output by the search server and the question-answer matching degree output by the student model, are weighted and summed to obtain the final answer corresponding to the target question. Based on the final answer corresponding to the target question, the corresponding answer is stored, and the parameters of the student model are updated in real time or periodically.

[0231] In this way, a well-trained student model can be obtained.

[0232] See Figure 3 The diagram shown is a detailed implementation flowchart of a method for constructing a student model provided in this application embodiment. The specific implementation process of this method is as follows:

[0233] Step 300: Obtain positive sample data containing samples of each question-answer combination and the corresponding question-answer matching degree.

[0234] Step 301: Randomly swap the questions and answers in each question-answer combination sample in the positive sample data to obtain the negative sample data containing each question-answer combination sample and the corresponding question-answer matching degree.

[0235] Step 302: Based on the question samples and corresponding answers in the positive sample data, as well as the discriminant model in the data expansion model, train the initial generative model in the data expansion model to obtain the trained generative model.

[0236] Step 303: Generate extended data based on the generative model and positive sample data.

[0237] Step 304: Randomly swap the questions and answers in each question-answer combination sample in the extended data to obtain negative extended data.

[0238] Step 305: Obtain the first set of sample data containing positive sample data, negative sample data, extended data, and negative extended data.

[0239] Step 306: Based on the question-answer combination samples in the positive and negative sample data and the corresponding question-answer matching degree, train the initial teacher model to obtain the trained teacher model.

[0240] Step 307: Based on the teacher model and the extended data, obtain the question-answer matching degree of each question-answer combination sample in the extended data.

[0241] Step 308: Based on the teacher model and the negative extended data, obtain the question-answer matching degree of each question-answer combination sample in the negative extended data.

[0242] Step 309: Based on the first sample data set, the question-answer matching degree of each question-answer combination sample in the extended data, and the question-answer matching degree of each question-answer combination sample in the extended data, obtain the second sample data set.

[0243] Step 310: Extract the vector features of each question-and-answer combination sample in the second sample dataset.

[0244] Step 311: Input the vector features of each question-and-answer combination sample into the initial student model to obtain the predicted matching degree of each question-and-answer combination sample.

[0245] Step 312: Based on the set student model weights and the set teacher model weights, the prediction matching degree and question-answer matching degree of each question-answer combination sample in the second sample dataset are weighted and summed to obtain the comprehensive matching degree.

[0246] Step 313: Determine the matching degree loss based on the overall matching degree and the set matching degree.

[0247] Step 314: Determine whether the matching degree loss is less than the set loss value. If yes, proceed to step 315; otherwise, proceed to step 316.

[0248] Step 315: Obtain the trained student model.

[0249] Step 316: Adjust the model parameters of the initial student model based on the matching degree loss.

[0250] It should be noted that step 311 is performed.

[0251] Specifically, when performing steps 300-316, please refer to steps 200-201 above for the specific steps, which will not be repeated here.

[0252] In this embodiment, a teacher model is constructed based on a first sample dataset and a bidirectional encoding representation model based on a converter. The student model is trained using the teacher model through knowledge distillation, transferring the knowledge from the teacher model to the student model to obtain a trained small-scale student model. This achieves model compression and quantization, reduces model call latency, and improves response speed. Training a small-scale student model does not require a large amount of data and resources, reducing training complexity, resource consumption, and saving project costs.

[0253] like Figure 4 The diagram shown is a structural schematic of a question-and-answer recognition device provided in an embodiment of this application, comprising:

[0254] The receiving unit 400 is used to receive question-and-answer requests for the target question;

[0255] The determining unit 401 is used to determine the answer to the target question based on a question-answering request for the target question and using a pre-trained question-answering model.

[0256] The question-answering model is a student model trained on the second sample data set and the teacher model, while the teacher model is constructed based on the first sample data set and a bidirectional encoding representation model based on the converter.

[0257] In one embodiment, the determining unit 401 is specifically used for:

[0258] Extract vector features of the target problem;

[0259] Input the vector features into the question answering model to obtain the answer output by the question answering model.

[0260] In one embodiment, the receiving unit 400 is further configured to:

[0261] Obtain the first sample data set, which contains positive sample data, negative sample data, extended data, and negative extended data. Both the positive and negative sample data contain multiple question-answer combination samples and corresponding question-answer matching degrees. Both the extended and negative extended data contain multiple question-answer combination samples.

[0262] Based on question-answer combination samples in positive and negative sample data and the corresponding question-answer matching degree, the initial teacher model is trained to obtain a trained teacher model. The initial teacher model is obtained through a bidirectional encoding representation model based on a converter.

[0263] Based on the teacher model and extended data, the question-answer matching degree of each question-answer combination sample in the extended data is obtained;

[0264] Based on the teacher model and negative extended data, the question-answer matching degree of each question-answer combination sample in the negative extended data is obtained;

[0265] Based on the first sample data set, the question-answer matching degree of each question-answer combination sample in the extended data, and the question-answer matching degree of each question-answer combination sample in the extended data, a second sample data set is obtained.

[0266] Based on the second sample dataset, the initial student model is trained to obtain a well-trained student model, which is a question-answering model.

[0267] In one embodiment, the receiving unit 400 is further configured to:

[0268] Obtain positive sample data. Each question-answer combination sample in the positive sample data includes a question sample and the corresponding answer.

[0269] The questions and answers in each question-answer combination sample in the positive sample data are randomly swapped to obtain the negative sample data. The negative sample data contains multiple swapped question-answer combination samples and the corresponding question-answer matching degree.

[0270] Based on the question samples and corresponding answers in the positive sample data, as well as the discriminative model in the data expansion model, the initial generative model in the data expansion model is trained to obtain the trained generative model. The data expansion model is built based on a generative adversarial network.

[0271] Based on the generative model and positive sample data, extended data is generated.

[0272] In one embodiment, the determining unit 401 is further configured to:

[0273] Extract the vector features of each question-and-answer combination sample from both the positive and negative sample data.

[0274] Based on the vector features of each question-answer combination sample and the corresponding question-answer matching degree, the initial teacher model is trained to obtain the trained teacher model.

[0275] In one embodiment, the determining unit 401 is further configured to:

[0276] Set the question-answer matching degree of each question-answer combination sample in the positive sample data to the first preset matching degree;

[0277] Set the question-answer matching degree of each question-answer combination sample in the negative sample data to the second preset matching degree;

[0278] Randomly swap the questions and answers in each question-and-answer combination sample in the extended data to obtain negative extended data, which contains multiple swapped question-and-answer combination samples.

[0279] Based on the extended data, negative extended data, and teacher model, the question-answer matching degree of each question-answer combination sample in the extended data and the question-answer matching degree of each question-answer combination sample in the negative extended data are obtained respectively.

[0280] In one embodiment, the determining unit 401 is further configured to:

[0281] Extract the vector features of each question-and-answer combination sample from the second sample dataset;

[0282] The vector features of each question-and-answer combination sample are input into the initial student model to obtain the predicted matching degree of each question-and-answer combination sample.

[0283] Based on the set weights for the student model and the set weights for the teacher model, the prediction matching degree and question-answer matching degree of each question-answer combination sample in the second sample dataset are weighted and summed to obtain the comprehensive matching degree.

[0284] Based on the overall matching degree and the set matching degree, determine the matching degree loss;

[0285] If the matching loss is less than the set loss value, a well-trained student model is obtained; otherwise, the model parameters of the initial student model are adjusted based on the matching loss until the matching loss determined based on the adjusted initial student model is less than the set loss value.

[0286] Figure 5 A schematic diagram of the structure of an electronic device 5000 is shown. (See also...) Figure 5 As shown, the electronic device 5000 includes a processor 5010 and a memory 5020, and optionally may also include a power supply 5030, a display unit 5040, and an input unit 5050.

[0287] The processor 5010 is the control center of the electronic device 5000. It connects various components through various interfaces and lines, and performs various functions of the electronic device 5000 by running or executing software programs and / or data stored in the memory 5020, thereby performing overall monitoring of the electronic device 5000.

[0288] In this embodiment of the application, when the processor 5010 calls the computer program stored in the memory 5020, it executes, as follows: Figure 2 The embodiments shown provide a question-and-answer recognition method.

[0289] The display unit 5040 can be used to display information input by the user or information provided to the user, as well as various menus of the electronic device 5000. In this embodiment of the invention, it is mainly used to display the display interfaces of various applications in the electronic device 5000, as well as the data, pictures, and other objects displayed on the display interfaces. The display unit 5040 may include a display panel 5041. The display panel 5041 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0290] The input unit 5050 can be used to receive information such as numbers or characters input by the user. The input unit 5050 may include a touch panel 5051 and other input devices 5052. The touch panel 5051, also known as a touch screen, can collect touch operations on or near the user (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 5051).

[0291] Those skilled in the art will understand that Figure 5 This is merely an example of an electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than shown, or a combination of certain components, or different components.

[0292] In this embodiment of the application, a readable storage medium stores a computer program thereon. When the computer program is executed by a processor, it enables a communication device to perform the various steps in the above embodiments.

[0293] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0294] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0295] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0296] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1The steps of the function specified in one or more boxes.

[0297] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0298] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method of question-answer recognition, the method comprising: The method comprises the following steps: receiving a question and answer request for a target question; based on the question and answer request for the target question, using a pre-trained question and answer model to determine the answer corresponding to the target question; wherein the question and answer model is a student model trained based on a second sample data set and a teacher model, the teacher model is constructed based on a first sample data set and a transformer-based bidirectional encoding representation model; the student model is trained by the following steps: obtaining a first sample data set, the first sample data set contains positive sample data, negative sample data, expansion data and negative expansion data, the positive sample data and the negative sample data each contain a plurality of question and answer combination samples and corresponding question and answer matching degrees, the expansion data and the negative expansion data each contain a plurality of question and answer combination samples; the negative sample data is obtained by randomly exchanging the question and answer in each question and answer combination sample in the positive sample data; the negative sample data contains a plurality of exchanged question and answer combination samples and corresponding question and answer matching degrees; the negative expansion data is obtained by randomly exchanging the question and answer in each question and answer combination sample in the expansion data; the negative expansion data contains a plurality of exchanged question and answer combination samples; obtaining the teacher model trained by the question and answer combination samples and the corresponding question and answer matching degrees in the positive sample data and the negative sample data; based on the teacher model and the expansion data, obtaining the question and answer matching degree of each question and answer combination sample in the expansion data; based on the teacher model and the negative expansion data, obtaining the question and answer matching degree of each question and answer combination sample in the negative expansion data; based on the first sample data set, the question and answer matching degree of each question and answer combination sample in the expansion data, and the question and answer matching degree of each question and answer combination sample in the negative expansion data, obtaining the second sample data set; based on the second sample data set, training an initial student model to obtain the trained student model.

2. The method of claim 1, wherein, Based on the question and answer request for the target question, using a pre-trained question and answer model to determine the answer corresponding to the target question, comprising: extracting the vector features of the target question; inputting the vector features into the question and answer model to obtain the answer output by the question and answer model.

3. The method of claim 1, wherein, Before obtaining the first sample data set, further comprising: obtaining positive sample data, each question and answer combination sample in the positive sample data comprising a question sample and a corresponding answer; based on each question sample and the corresponding answer in the positive sample data and the discriminant model in the data expansion model, training the initial generation model in the data expansion model to obtain a trained generation model, wherein the data expansion model is constructed based on a generative adversarial network; based on the generation model and the positive sample data, generating expansion data.

4. The method of claim 3, wherein, The teacher model is trained by the following steps: extracting the vector features of each question and answer combination sample in the positive sample data and the negative sample data, respectively; The initial teacher model is trained based on the vector features of each question-answer combination sample and the corresponding question-answer matching degree, to obtain a trained teacher model.

5. The method of claim 3 or 4, wherein, After the generation of the extended data based on the generation model and the positive sample data, the method further includes: The question-answer matching degree of each question-answer combination sample in the positive sample data is set as a first preset matching degree, respectively. The question-answer matching degree of each question-answer combination sample in the negative sample data is set as a second preset matching degree, respectively. Based on the extended data, the negative extended data, and the teacher model, the question-answer matching degree of each question-answer combination sample in the extended data and the question-answer matching degree of each question-answer combination sample in the negative extended data are obtained, respectively.

6. The method of claim 5, wherein, The training of the initial student model based on the second sample data set to obtain the trained student model includes: The vector features of each question-answer combination sample in the second sample data set are extracted, respectively. The vector features of each question-answer combination sample are input into the initial student model, to obtain the predicted matching degree of each question-answer combination sample, respectively. The predicted matching degree and the question-answer matching degree of each question-answer combination sample in the second sample data set are weighted and summed according to a set student model weight and a set teacher model weight, to obtain a comprehensive matching degree. Based on the comprehensive matching degree and a set matching degree, a matching degree loss is determined. If the matching degree loss is less than a set loss value, the trained student model is obtained, otherwise, the model parameters of the initial student model are adjusted based on the matching degree loss, until the matching degree loss determined based on the adjusted initial student model is less than the set loss value.

7. An apparatus for question-answer identification, the apparatus comprising: The method includes: a receiving unit configured to receive a question-answer request for a target question; a determining unit configured to determine an answer corresponding to the target question based on the question-answer request for the target question by using a pre-trained question-answer model. The question and answer model is a student model obtained based on a second sample data set and a teacher model, and the teacher model is constructed based on a first sample data set and a transformer-based bidirectional encoding representation model; the student model is trained by the following steps: obtaining the first sample data set, the first sample data set containing positive sample data, negative sample data, expansion data and negative expansion data, the positive sample data and the negative sample data containing a plurality of question and answer combination samples and corresponding question and answer matching degrees, the expansion data and the negative expansion data containing a plurality of question and answer combination samples; the negative sample data is obtained by randomly exchanging the question and the answer in each question and answer combination sample in the positive sample data; the negative sample data contains a plurality of exchanged question and answer combination samples and corresponding question and answer matching degrees; the negative expansion data is obtained by randomly exchanging the question and the answer in each question and answer combination sample in the expansion data; the negative expansion data contains a plurality of exchanged question and answer combination samples; obtaining the teacher model trained by the question and answer combination samples and the corresponding question and answer matching degrees in the positive sample data and the negative sample data; obtaining the question and answer matching degree of each question and answer combination sample in the expansion data based on the teacher model and the expansion data; obtaining the question and answer matching degree of each question and answer combination sample in the negative expansion data based on the teacher model and the negative expansion data; obtaining the second sample data set based on the first sample data set, the question and answer matching degree of each question and answer combination sample in the expansion data and the question and answer matching degree of each question and answer combination sample in the negative expansion data; training the initial student model based on the second sample data set to obtain the trained student model.

8. An electronic device, comprising: The computer program is executed by the processor to run the method of any one of claims 1-6.

9. A readable storage medium, having stored thereon a computer program, characterized in that, The computer program is executed by the processor to run the method of any one of claims 1-6.

Citation Information

Patent Citations

  • Attribute recognition method based on knowledge distillation, terminal equipment and storage medium

    CN113515614A