Man-machine conversation system training method and device and electronic equipment
By using JSA method to perform semi-supervised training in the RAG human-computer dialogue system, using MIS sampling and high-quality sample screening, and optimizing the search and generation module, the problem of insufficient label data is solved, and the system performance and generation quality are improved.
Patent Information
- Application Number
- CN202510599589.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-15
AI Technical Summary
The existing human-computer dialogue system based on search enhanced generation (RAG) is difficult to generate high-quality due to lack of label data guidance, and requires a large amount of labeled data to improve performance, which limits its application and development.
Semi-supervised training is carried out using joint random approximation (JSA) method, through MIS sampling and high-quality sample screening, combined with prior and posterior search models, optimize the search and generation modules, build hidden variable relationships, and realize end-to-end training.
It improves the utilization rate of labelless data, improves the performance of human-computer dialogue systems, enhances the credibility of generating answers and the overall effect of the system.
Smart Images

Figure CN120492584A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of human-computer dialogue, and in particular to a training method, device and electronic equipment for a human-computer dialogue system. Background Art
[0002] A human-machine dialogue system (HMS), also known as a dialogue system or chatbot, is a computer program designed to interact with human users through natural language. Such a system can simulate human-to-human conversations, understand user input (usually text or speech), and generate appropriate responses.
[0003] Retrieval-Augmented Generation (RAG) technology, used in human-computer dialogue systems, can effectively improve the accuracy of question-answering. RAG is a deep learning model that combines retrieval and generation. RAG generally consists of two core modules: a retrieval module and a generation module. After accepting natural language input, the retrieval module first encodes the natural language into a vector space. It then searches a vector database for the most relevant text based on similarity in the vector space and returns it as a database query result. The generation module then generates the corresponding natural language based on the input and the query result.
[0004] like Figure 1 As shown, the working process of a RAG-based human-computer dialogue system generally includes the following steps: 1. Given a database, the original document data (such as Wikipedia) is cleaned and sliced; 2. The sliced documents are encoded using a document encoder, mapped to a vector space, and the corresponding vector index is constructed; 3. The user-input question is indexed, and the user's question text is encoded into a vector using the question encoder. This vector is then placed in the vector space of the entire document set to query the vector most similar to and most relevant to the question vector. The corresponding text fragment is returned as the "relevant text" retrieved based on the question; 4. Generation. With the user input and relevant text from the above steps, they can be fed into a generative model for generation, and the generated text is used as the answer, completing the entire human-computer dialogue process. However, RAG-based human-computer dialogue systems have a drawback: since RAG modeling generally involves a knowledge base or database, there is no labeled data to guide the search, making high-quality generation difficult. Therefore, a large amount of annotation is required to improve the performance of human-computer question answering, which greatly limits the application and further development of RAG-based human-computer dialogue systems. Summary of the Invention
[0005] In order to solve the problems existing in the prior art, the present invention provides the following technical solutions.
[0006] A first aspect of the present invention provides a training method for a human-computer dialogue system, wherein the human-computer dialogue system includes a language model, a priori retrieval model, and a posteriori retrieval model;
[0007] The training method comprises:
[0008] Acquire training data, wherein the training data includes questions and answers;
[0009] Input the question and answer into the posterior retrieval model and output several related texts;
[0010] Filter out multiple samples that meet the probability requirements of the posterior retrieval model from a number of relevant texts;
[0011] Perform MIS sampling in multiple samples with acceptance and rejection probability to obtain the high-quality sample of the t-th sampling, t = 1 ~ N, N is the number of sampling times;
[0012] The prior retrieval model is trained using questions so that the prior retrieval model outputs high-quality samples obtained from the current sampling; the language model is trained using the high-quality samples obtained from the current sampling and questions so that the language model outputs answers; the posterior retrieval model is trained using questions and answers so that the posterior retrieval model outputs high-quality samples obtained from the current sampling; the trained language model, prior retrieval model and posterior retrieval model constitute a trained human-computer dialogue system.
[0013] Preferably, the MIS sampling is performed among multiple samples with acceptance and rejection probabilities to obtain a high-quality sample of the t-th sampling, where t=1 to N, and N is the number of sampling times, including:
[0014] Acceptance and rejection probability Determine whether to accept, if accepted then z t = z′, otherwise z t =z t-1 ;
[0015] Among them, z t is the high-quality sample obtained by sampling for the tth time, z t-1 is the high-quality sample obtained by the t-1th sampling, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the related text, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model.
[0016] Preferably, the probability of the posterior retrieval model is calculated using the following formula:
[0017]
[0018] in, is the probability of the posterior retrieval model, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the relevant text, and E ξ is the question encoder of the posterior retrieval model, E λ is the text encoder of the posterior retrieval model, z′ m Indicates the number of high-quality samples z′ obtained in the current sampling.
[0019] Preferably, the trained human-computer dialogue system uses the following formula to calculate the loss L:
[0020]
[0021] Among them, z t is the high-quality sample obtained by sampling for the tth time, x is the question, y is the answer, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model, t = 1~N, N is the number of sampling times.
[0022] A second aspect of the present invention provides a human-computer dialogue method, comprising:
[0023] The question to be queried is input into the trained human-computer dialogue system to generate a corresponding answer; wherein the trained human-computer dialogue system is pre-trained according to the training method of the human-computer dialogue system as described in the first aspect.
[0024] A third aspect of the present invention provides a training device for a human-computer dialogue system, wherein the human-computer dialogue system includes a language model, a priori retrieval model, and a posteriori retrieval model;
[0025] The training device comprises:
[0026] A training data acquisition module, configured to acquire training data, wherein the training data includes questions and answers;
[0027] The retrieval module is used to input questions and answers into the posterior retrieval model and output several related texts;
[0028] A screening module is used to screen out multiple samples that meet the probability requirements of the posterior retrieval model from a number of relevant texts;
[0029] The sampling module is used to perform MIS sampling in multiple samples with acceptance and rejection probabilities to obtain high-quality samples for the t-th sampling, where t = 1 to N, and N is the number of sampling times;
[0030] The training module is used to train the prior retrieval model using questions so that the prior retrieval model outputs high-quality samples obtained from the current sampling; to train the language model using the high-quality samples obtained from the current sampling and questions so that the language model outputs answers; to train the posterior retrieval model using questions and answers so that the posterior retrieval model outputs high-quality samples obtained from the current sampling; the trained language model, prior retrieval model and posterior retrieval model constitute a trained human-computer dialogue system.
[0031] Preferably, in the sampling module, performing MIS sampling among multiple samples with acceptance and rejection probabilities to obtain a high-quality sample of the t-th sampling, where t=1 to N, and N is the number of sampling times, includes:
[0032] Acceptance and rejection probability Determine whether to accept, if accepted then z t = z′, otherwise z t =z t-1 ;
[0033] Among them, z t is the high-quality sample obtained by sampling for the tth time, z t-1 is the high-quality sample obtained by the t-1th sampling, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the related text, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model.
[0034] Preferably, in the screening module, the probability of the posterior retrieval model is calculated using the following formula:
[0035]
[0036] in, is the probability of the posterior retrieval model, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the relevant text, and E ξ is the question encoder of the posterior retrieval model, E λ is the text encoder of the posterior retrieval model, z′ m Indicates the number of high-quality samples z′ obtained in the current sampling.
[0037] Preferably, in the training module, the trained human-computer dialogue system uses the following formula to calculate the loss L:
[0038]
[0039]
[0040] Among them, z tis the high-quality sample obtained by sampling for the tth time, x is the question, y is the answer, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model, t = 1~N, N is the number of sampling times.
[0041] The present invention also provides an electronic device comprising a processor and a memory connected to the processor, wherein the memory stores a plurality of instructions that can be loaded and executed by the processor so that the processor can execute the training method of the human-computer dialogue system as described in the first aspect, and the human-computer dialogue method as described in the second aspect.
[0042] The beneficial effects of the present invention include at least the following: the training method, device, and electronic device for the human-computer dialogue system provided by the embodiments of the present invention improve the utilization of unlabeled data and thus improve the performance of the human-computer dialogue system by adopting the joint random approximation method for semi-supervised training in the RAG human-computer dialogue system. At the same time, compared with systems constructed using existing technical methods, the human-computer dialogue system trained by the present invention can better construct the relationship between latent variables (text knowledge base) and generated results, and can train the entire RAG system end-to-end using the JSA algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 Schematic diagram of the implementation process of the RAG human-computer dialogue system in the prior art;
[0044] Figure 2 Schematic diagram of the flow of the training method of the human-computer dialogue system of the present invention;
[0045] Figure 3 This is a flowchart of the implementation process of the training method for the human-computer dialogue system of the present invention;
[0046] Figure 4 This is an example of a RAG system question and answer according to an embodiment of the present invention;
[0047] Figure 5 This is a functional structure diagram of the training device of the human-computer dialogue system of the present invention. DETAILED DESCRIPTION
[0048] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0049] The method provided by the present invention can be implemented in the following terminal environment, which may include one or more of the following components: a processor, a memory, and a display screen. The memory stores at least one instruction, which is loaded and executed by the processor to implement the method described in the following embodiments.
[0050] A processor can include one or more processing cores. It connects various components within the terminal using various interfaces and circuits. It executes instructions, programs, code sets, or instruction sets stored in memory, and accesses data stored in memory to perform various terminal functions and process data.
[0051] The memory may include random access memory (RAM) or read-only memory (ROM). The memory may be used to store instructions, programs, codes, code sets, or instructions.
[0052] The display is used to show the user interface of each application.
[0053] In addition, those skilled in the art will appreciate that the structure of the terminal described above does not limit the terminal. The terminal may include more or fewer components, or a combination of certain components, or a different arrangement of components. For example, the terminal may also include a radio frequency circuit, an input unit, a sensor, an audio circuit, a power supply, and other components, which will not be described in detail here.
[0054] In response to the problem that the RAG-based human-computer dialogue system in the existing technology requires a large amount of labeled data to improve the performance of the human-computer dialogue, the present invention found in research that a large amount of unlabeled data can be used to improve the performance of the human-computer dialogue system through semi-supervised learning.
[0055] Currently, semi-supervised methods can be divided into several categories: 1. Consistency regularization methods. This method assumes that for unlabeled data, even if a certain amount of noise is added, the output distribution after feeding it into the model should remain unchanged. Therefore, the optimization goal of this method is to make the output of unlabeled data and noisy unlabeled data converge to be consistent. 2. Pseudo-labeling methods. For unlabeled samples, the model is used to predict pseudo-labels. This model for pseudo-label prediction can be trained in advance on a small amount of labeled data. Pseudo-labeling methods include self-training and multi-view training. 3. Latent variable modeling methods. This category of methods assumes that each data sample corresponds to a low-dimensional latent variable. In semi-supervised learning, the model first learns the mapping from the low-dimensional latent variable distribution to the data distribution on labeled data. When faced with unlabeled data, the model can either directly map the data to a low-dimensional distribution and then perform clustering, or it can directly treat the data label as a low-dimensional latent variable and then learn it using some specific algorithms. Typical algorithms in this category include variational autoencoders, generative adversarial networks (GANs), and joint stochastic approximation (JSA). This paper, after studying and exploring the JSA method, discovered its advantages in end-to-end training. Therefore, we chose the JSA method in combination with RAG to improve the performance of human-computer dialogue systems.
[0056] Example 1
[0057] like Figure 2 、 Figure 3 As shown, an embodiment of the present invention provides a training method for a human-computer dialogue system, wherein the human-computer dialogue system includes a language model, a priori retrieval model, and a posterior retrieval model. The training method includes: S101, obtaining training data, wherein the training data includes questions and answers; S102, inputting the questions and answers into the posterior retrieval model and outputting a plurality of related texts; S103, screening multiple samples that meet the probability requirements of the posterior retrieval model from the plurality of related texts; S104, performing MIS sampling among the multiple samples with acceptance and rejection probabilities to obtain a high-quality sample for the t-th sampling, where t = 1 to N, and N is the number of samplings; S105, using the question to train the priori retrieval model so that the priori retrieval model outputs a high-quality sample obtained from the current sampling; using the high-quality sample obtained from the current sampling and the question to train the language model so that the language model outputs an answer; using the question and answer to train the posterior retrieval model so that the posterior retrieval model outputs a high-quality sample obtained from the current sampling; the trained language model, priori retrieval model, and posterior retrieval model constitute a trained human-computer dialogue system.
[0058] In a preferred embodiment of the present invention, performing MIS sampling among multiple samples with acceptance and rejection probabilities to obtain a high-quality sample of the t-th sampling, where t=1 to N, and N is the number of sampling times, includes:
[0059] Acceptance and rejection probability Determine whether to accept, if accepted then z t = z′, otherwise z t =z t-1 ;
[0060] Among them, z t is the high-quality sample obtained by sampling for the tth time, z t-1 is the high-quality sample obtained by the t-1th sampling, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the related text, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model.
[0061] Furthermore, the probability of the posterior retrieval model is calculated using the following formula:
[0062]
[0063] in, is the probability of the posterior retrieval model, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the relevant text, and E ξ is the question encoder of the posterior retrieval model, E λ is the text encoder of the posterior retrieval model, z′ m Indicates the number of high-quality samples z′ obtained in the current sampling.
[0064] In a preferred embodiment of the present invention, the trained human-computer dialogue system uses the following formula to calculate the loss:
[0065]
[0066] Among them, z t is the high-quality sample obtained by sampling for the tth time, x is the question, y is the answer, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model, t = 1~N, N is the number of sampling times.
[0067] The present invention mainly includes three aspects.
[0068] (1) Generative human-computer dialogue system with retrieval enhancement:
[0069] For the knowledge-based task dialogue system, since the semi-supervised factor is considered in this invention, the problem is modeled as a retrieval-enhanced generative dialogue system (hereinafter referred to as RAG system) with the following overall structure: Figure 1 As shown in Figure 2. The RAG system consists of two main modules: the retriever and the generator. When a user enters a query question, the retriever retrieves multiple texts that are most relevant to the question, and then the generator generates a response based on the question and the relevant text. A typical RAG question answering example is shown in Figure 2. Figure 4 As shown. RAG dialogue can be either a single-round dialogue or a multi-round dialogue. For a multi-round dialogue, we only need to concatenate the dialogue history and the question input by the user in the current round and treat it as a text. The subsequent process is exactly the same as that of a single-round dialogue. The question can be represented by x, the retrieved relevant text by z, and the generated answer by y. Then the distribution that the retrieval model needs to learn is p R (z|x). Generally, the retrieval model contains two encoding models, one encoding the question input by the user and the other encoding the text to be queried. In this invention, E η and E λ In other words, these two encoders can encode the sentences input into semantic models, and the product of the vectors can represent the similarity between the two sentences. Then the distribution learned by the retrieval model can be written as follows:
[0070]
[0071] The denominator of formula (1) is the sum of the entire text database, where z′ represents the high-quality sample obtained by the current sampling, and z′ m Indicates the number of high-quality samples z' obtained in the current sampling. In general, the retrieval model only needs to retrieve the most relevant K texts (hereinafter referred to as top-K), that is, to find the K z that maximize the above probability value. Furthermore, in fact, only the K z with the largest vector product (numerator) are needed. After finding the top-K relevant texts, the next task is to hand it over to the generative model to generate. The generative model takes the question x and the relevant text z as input and the corresponding answer y as the target, so p is used. LM (y|x, z) is used to represent the probability of the language model. In fact, there are already many works that can realize the training of retrieval models on unlabeled datasets. For example, the end-to-end RAG system jointly trains the retrieval model and the generation model in an end-to-end manner. Its training loss is as follows:
[0072]
[0073] This training method essentially leverages the signals from a pre-trained language model to perform weighted training on the top-K texts retrieved by the retrieval model. This allows the retrieval model to break free from its reliance on manual annotation and fully leverage the signals from the pre-trained language model to improve its performance. Compared to a direct human-computer dialogue language model, the RAG system incorporates relevant retrieved text, enriching the basis for the generative model and making the generated answers more credible.
[0074] (2) Human-computer dialogue system based on RAG method and JSA principle of latent variable modeling:
[0075] The JSA method is used for semi-supervised learning based on latent variable modeling. Latent variable learning is generally as follows: suppose there is a batch of data, where a single data sample is represented by a. Each data sample corresponds to a latent variable h. The latent variable is generally in a lower dimension, and its distribution determines the distribution of the data sample. This latent variable can be an unknown variable. Usually, the modeling goal is the joint probability p of the two. θ (a,h). Usually the above joint probability is not parameterized directly, but it is decomposed into: p θ (a,h)=p θ (a|h)p θ (h). Where the conditional distribution p θ (a|h) can represent a generative model in a human-computer dialogue system, generating data samples from latent variables, and the prior distribution p θ (h) It can be generally assumed that it is either the output distribution of a neural network or that it conforms to a Gaussian distribution, which is independent of the parameter θ. Since the latent variable is unobservable, it is possible to choose to marginalize the latent variable. The final conditional latent variable modeling can be expressed as
[0076] The JSA algorithm aims to learn latent variable modeling to marginalize the probability p of latent variables. θ (a) The optimization objective is transformed into logp θ (a) is the optimization objective, and the optimization problem can be transformed into a first-order derivative root-finding problem:
[0077]
[0078] The left side of formula (3) can be converted into the desired form:
[0079]
[0080] The derivation of formula (4) uses And Fisher's inequality, so the root-finding problem is transformed into: For this kind of gradient expectation problem, the Stochastic Approximation (SA) method can be used to solve it. Specifically, it is necessary to start from p θ Only by sampling in (h||a) can we obtain the expectation, and then use the expectation to perform gradient descent on the parameters. In JSA, the MIS (Metropolis independence sampler) method is used for sampling. Specifically, the MIS method requires a proposed distribution to approximate the true posterior distribution (because the true posterior distribution is difficult to obtain), denoted as q φ (h|x), this method samples from the proposed distribution, then accepts or rejects the sample with a certain probability, and iterates for a certain number of steps to obtain a Markov chain. As long as the chain is long enough, the sampled sample is considered to come from the target distribution. The specific steps are as follows:
[0081] From the proposed distribution q φ Sampling (h|a) yields h~q φ (h|a);
[0082] By probability Accept h s =h, otherwise h s =h s-1 ;
[0083] The core of the joint random approximation is that it uses the samples of latent variables obtained by MIS sampling not only to update the parameters θ, but also to update the proposed distribution φ. Therefore, the actual loss function is as follows:
[0084]
[0085] (3) Human-computer dialogue system based on JSA-RAG method:
[0086] The work of integrating the joint random approximation method into the RAG system can be named JSA-RAG. From the above JSA principle, we can find that the JSA algorithm can not only model the latent variables during optimization, but also simultaneously optimize the target model and the proposal model, which corresponds exactly to the retrieval and generation models in the RAG system. However, in practice, the retriever is not used as the proposal distribution, but the retriever is used as the target distribution. Conversely, the target distribution is used to approximate the proposal distribution. The reason is that the proposal distribution is the posterior distribution, and the latent variables retrieved by the posterior distribution are more credible. At this time, the loss formula can be rewritten as:
[0087]
[0088] The training process of JSA-RAG is as follows:
[0089] Input the questions and answers in the training data into the posterior retrieval model and output several related texts; select multiple samples that meet the probability requirements of the posterior retrieval model from the several related texts; perform MIS sampling in multiple samples with acceptance and rejection probabilities to obtain multiple high-quality samples, specifically, with acceptance and rejection probabilities. Accept if z t = z′, otherwise z t =z t-1 ; Among them, z t is the high-quality sample obtained by sampling for the tth time, z t-1 is the high-quality sample obtained by the t-1th sampling, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the related text, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model, t = 1 to N, where N is the number of sampling times. The language model, prior retrieval model, and posterior retrieval model are trained using high-quality samples and training data to obtain a trained human-computer dialogue system. The prior retrieval model is trained using questions so that it outputs high-quality samples. The language model is trained using high-quality samples and questions so that it outputs answers. The posterior retrieval model is trained using questions and answers so that it outputs high-quality samples. Formula (6) is used to calculate and perform gradient backpropagation to update the parameters.
[0090] Example 2
[0091] An embodiment of the present invention provides a human-computer dialogue method, comprising:
[0092] The question to be queried is input into the trained human-computer dialogue system to generate a corresponding answer; wherein the trained human-computer dialogue system is pre-trained according to the training method of the human-computer dialogue system as described in Example 1.
[0093] Example 3
[0094] like Figure 5 As shown, another aspect of the present invention also includes a functional module architecture that is completely consistent with the aforementioned method process, that is, an embodiment of the present invention also provides a training device for a human-computer dialogue system, which includes a language model, a priori retrieval model and a posteriori retrieval model.
[0095] The training device includes: a training data acquisition module 501 for acquiring training data, wherein the training data includes questions and answers; a retrieval module 502 for inputting questions and answers into a posterior retrieval model and outputting a plurality of related texts; a screening module 503 for screening out a plurality of samples that meet the probability requirements of the posterior retrieval model from the plurality of related texts; a sampling module 504 for performing MIS sampling in a plurality of samples with an acceptance / rejection probability to obtain a high-quality sample of the t-th sampling, where t=1~N, and N is the number of samplings; a training module 505 for training the a priori retrieval model using questions so that the a priori retrieval model outputs a high-quality sample obtained by the current sampling; training a language model using the high-quality sample obtained by the current sampling and questions so that the language model outputs an answer; training a posterior retrieval model using questions and answers so that the posterior retrieval model outputs a high-quality sample obtained by the current sampling; the trained language model, the a priori retrieval model, and the posterior retrieval model constitute a trained human-computer dialogue system.
[0096] Furthermore, in the sampling module, MIS sampling is performed in multiple samples with acceptance and rejection probability to obtain high-quality samples of the t-th sampling, t = 1 to N, N is the number of sampling times, including:
[0097] Acceptance and rejection probability Accept if z t = z′, otherwise z t =z t-1 .
[0098] Among them, z t is the high-quality sample obtained by sampling for the tth time, z t-1 is the high-quality sample obtained by the t-1th sampling, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the related text, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model.
[0099] Furthermore, in the screening module, the probability of the posterior retrieval model is calculated using the following formula:
[0100]
[0101] in, is the probability of the posterior retrieval model, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the relevant text, and E ξ is the question encoder of the posterior retrieval model, E λ is the text encoder of the posterior retrieval model, z′ m Indicates the number of high-quality samples z′ obtained in the current sampling.
[0102] Furthermore, in the training module, the trained human-computer dialogue system uses the following formula to calculate the loss:
[0103]
[0104] Among them, z t is the high-quality sample obtained by sampling for the tth time, x is the question, y is the answer, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model, t = 1~N, N is the number of sampling times.
[0105] The device can be implemented by the training method of the human-computer dialogue system provided in the above-mentioned embodiment 1. The specific implementation method can be found in the description of embodiment 1 and will not be repeated here.
[0106] The present invention also provides a memory storing a plurality of instructions, wherein the instructions are used to implement the training method of the human-computer dialogue system as described in the first embodiment and the human-computer dialogue method as described in the second embodiment.
[0107] The present invention also provides an electronic device, comprising a processor and a memory connected to the processor, wherein the memory stores a plurality of instructions, which can be loaded and executed by the processor so that the processor can execute the training method of the human-computer dialogue system as described in Example 1 and the human-computer dialogue method as described in Example 2.
[0108] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the invention. Thus, the present invention is intended to include such changes and modifications as fall within the scope of the claims and their equivalents.
Claims
1. A training method for a human-computer dialogue system, characterized in that: The human-computer dialogue system includes a language model, a priori retrieval model and a posteriori retrieval model; The training method comprises: Acquire training data, wherein the training data includes questions and answers; Input the question and answer into the posterior retrieval model and output several related texts; Filter out multiple samples that meet the probability requirements of the posterior retrieval model from a number of relevant texts; Perform MIS sampling in multiple samples with acceptance and rejection probability to obtain the high-quality sample of the t-th sampling, t = 1 ~ N, N is the number of sampling times; The prior retrieval model is trained using questions so that the prior retrieval model outputs high-quality samples obtained from the current sampling; the language model is trained using the high-quality samples obtained from the current sampling and questions so that the language model outputs answers; the posterior retrieval model is trained using questions and answers so that the posterior retrieval model outputs high-quality samples obtained from the current sampling; the trained language model, prior retrieval model and posterior retrieval model constitute a trained human-computer dialogue system.
2. The training method for a human-computer dialogue system according to claim 1, wherein: The method of performing MIS sampling among multiple samples with acceptance and rejection probability to obtain a high-quality sample of the t-th sampling, where t=1 to N, and N is the number of sampling times, includes: Acceptance and rejection probability Determine whether to accept, if accepted then z t = z′, otherwise z t =z t-1 ; Among them, z t is the high-quality sample obtained by sampling for the tth time, z t-1 is the high-quality sample obtained by the t-1th sampling, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the related text, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model.
3. The training method for a human-computer dialogue system according to claim 1, wherein: The probability of the posterior retrieval model is calculated using the following formula: in, is the probability of the posterior retrieval model, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the relevant text, and E ξ is the question encoder of the posterior retrieval model, E λ is the text encoder of the posterior retrieval model, z′ m Indicates the number of high-quality samples z′ obtained in the current sampling.
4. The training method for a human-computer dialogue system according to claim 1, wherein: The trained human-computer dialogue system uses the following formula to calculate the loss L: Among them, z t is the high-quality sample obtained by sampling for the tth time, x is the question, y is the answer, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model, t = 1~N, N is the number of sampling times.
5. A human-computer dialogue method, characterized in that: include: The question to be queried is input into the trained human-computer dialogue system to generate a corresponding answer; wherein the trained human-computer dialogue system is pre-trained according to the training method for the human-computer dialogue system according to any one of claims 1-4.
6. A training device for a human-computer dialogue system, characterized in that: The human-computer dialogue system includes a language model, a priori retrieval model and a posteriori retrieval model; The training device comprises: A training data acquisition module, configured to acquire training data, wherein the training data includes questions and answers; The retrieval module is used to input questions and answers into the posterior retrieval model and output several related texts; A screening module is used to screen out multiple samples that meet the probability requirements of the posterior retrieval model from a number of relevant texts; The sampling module is used to perform MIS sampling in multiple samples with acceptance and rejection probabilities to obtain high-quality samples for the t-th sampling, where t = 1 to N, and N is the number of sampling times; The training module is used to train the prior retrieval model using questions so that the prior retrieval model outputs high-quality samples obtained from the current sampling; to train the language model using the high-quality samples obtained from the current sampling and questions so that the language model outputs answers; to train the posterior retrieval model using questions and answers so that the posterior retrieval model outputs high-quality samples obtained from the current sampling; the trained language model, prior retrieval model and posterior retrieval model constitute a trained human-computer dialogue system.
7. The training device for a human-computer dialogue system according to claim 6, wherein: In the sampling module, MIS sampling is performed among multiple samples with acceptance and rejection probabilities to obtain a high-quality sample of the t-th sampling, where t=1 to N, and N is the number of sampling times, including: Acceptance and rejection probability Determine whether to accept, if accepted then z t = z′, otherwise z t =z t-1 ; Among them, z t is the high-quality sample obtained by sampling for the tth time, z t-1 is the high-quality sample obtained by the t-1th sampling, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the related text, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model.
8. The training device for a human-computer dialogue system according to claim 6, wherein: In the screening module, the probability of the posterior retrieval model is calculated using the following formula: in, is the probability of the posterior retrieval model, z′ is the high-quality sample obtained by the current sampling, x is the question, y is the answer, z is the relevant text, and E ξ is the question encoder of the posterior retrieval model, E λ is the text encoder of the posterior retrieval model, z′ m Indicates the number of high-quality samples z′ obtained in the current sampling.
9. The training device for a human-computer dialogue system according to claim 6, wherein: In the training module, the trained human-computer dialogue system uses the following formula to calculate the loss L: Among them, z t is the high-quality sample obtained by sampling for the tth time, x is the question, y is the answer, P ret is the probability of the prior retrieval model, P LM is the probability of the language model, is the probability of the posterior retrieval model, t = 1~N, N is the number of sampling times.
10. An electronic device, characterized in that: It includes a processor and a memory connected to the processor, the memory stores a plurality of instructions, and the instructions can be loaded and executed by the processor to enable the processor to execute the training method of the human-computer dialogue system as described in any one of claims 1 to 4, and the human-computer dialogue method as described in claim 5.