A method and device for determining loss parameters of a dialogue generation model
By combining virtual adversarial training with part-of-speech and syntactic tagging, the contradiction between robustness and generalization of dialogue generation models is resolved, improving the accuracy and generalization ability of generated dialogues and achieving efficient dialogue generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GLOBAL TONE COMM TECH
- Filing Date
- 2022-08-10
- Publication Date
- 2026-07-10
AI Technical Summary
Existing dialogue generation models present a trade-off between robustness and generalization; as robustness increases, generalization decreases, resulting in insufficient accuracy in generated dialogues.
A virtual adversarial training method is adopted to train the dialogue generation model through labeled samples of dialogue data. The overall loss parameters are obtained by combining part-of-speech and syntactic annotations, and then combined with the virtual adversarial loss parameters to form the final loss parameters. This reduces the dependence on manual annotation and enhances the generalization ability and accuracy of the model.
Without sacrificing model robustness, the generalization ability and accuracy of the dialogue generation model are improved, the dependence on manually labeled samples is reduced, and the quality of generated dialogues is enhanced.
Smart Images

Figure CN115357684B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a method and apparatus for determining loss parameters of a dialogue generation model. Background Technology
[0002] Dialogue generation is a subtask of natural language processing and information extraction, and it plays an important role in fields such as intelligent question answering, multi-turn dialogue, human-computer interaction, and intelligent customer service.
[0003] Currently, dialogue generation methods primarily rely on generative models, which employ natural language processing algorithms and utilize encoder-decoder structures for responses. Generative models more closely resemble the process of human conversation, automatically learning how to generate text from existing dialogue texts, offering high flexibility.
[0004] However, generative models often suffer from poor robustness and generalization. While adding traditional adversarial training (such as FGM, PGD, etc.) can enhance robustness, it will also impair the model's generalization, resulting in poor generalization. Summary of the Invention
[0005] The purpose of this application is to provide a method and apparatus for determining the loss parameters of a dialogue generation model, so as to solve the problem of insufficient accuracy in generated dialogue. The specific technical solution is as follows:
[0006] Firstly, a method for determining the loss parameters of a dialogue generation model is provided, the method comprising:
[0007] The overall loss parameters of the dialogue generation model are obtained by training a dialogue generation model using labeled samples of dialogue data.
[0008] Virtual adversarial training is performed using the labeled samples to obtain virtual adversarial loss parameters;
[0009] The final loss parameters of the dialogue generation model are obtained by summing the overall loss parameters and the virtual adversarial loss parameters.
[0010] Optionally, the overall loss parameters of the dialogue generation model are obtained by training a dialogue generation model using labeled samples of the dialogue data, including:
[0011] The dialogue data is tagged with part-of-speech tags and syntactic tags to obtain tagged samples, wherein the dialogue data includes first and second statements belonging to different dialogue objects;
[0012] The first statement is input into the dialogue generation model to obtain the prediction result output by the dialogue generation model, wherein the prediction result includes the content, part of speech, and syntax of the predicted second statement;
[0013] The prediction result is compared with the second statement to obtain the first loss parameter of the dialogue generation model for the dialogue generation task, the second loss parameter for the part-of-speech prediction task, and the third loss parameter for the syntax prediction task.
[0014] The overall loss parameter is obtained based on the first loss parameter, the second loss parameter, and the third loss parameter.
[0015] Optionally, performing part-of-speech tagging and syntactic tagging on the dialogue data includes:
[0016] The dialogue data was segmented using a word segmentation tool;
[0017] The word segmentation is tagged with part-of-speech tags using a part-of-speech recognition scheme.
[0018] A syntactic recognition scheme is used to perform syntactic annotation on the word segments, wherein the syntactic annotation indicates the sentence components or sentence relationships of the word segments in the dialogue data.
[0019] Optionally, obtaining the first loss parameter of the dialogue generation model for the dialogue generation task, the second loss parameter for the part-of-speech prediction task, and the third loss parameter for the syntactic prediction task includes:
[0020] The first loss parameter for the dialogue generation task is obtained through the hidden state layer of the decoder of the dialogue generation model, wherein the dialogue generation model adopts an encoder-decoder structure;
[0021] The second loss parameter for the part-of-speech prediction task is obtained through the decoder shared layer of the dialogue generation model;
[0022] The third loss parameter for the syntactic prediction task is obtained through the decoder shared layer of the dialogue generation model.
[0023] Optionally, the step of performing virtual adversarial training using the labeled samples to obtain virtual adversarial loss parameters includes:
[0024] The first statement of the labeled sample is used as the non-perturbative input;
[0025] By adding a perturbation to the unperturbed input, a perturbed input is obtained;
[0026] The KL difference is obtained based on the perturbation output of the dialogue generation model for the perturbation input and the non-perturbation output for the non-perturbation input;
[0027] By updating the weights of the dialogue generation model and minimizing the KL discrepancy, the virtual adversarial loss parameters are obtained.
[0028] Optionally, after obtaining the final loss parameters of the dialogue generation model, the method further includes:
[0029] For the first half of the dialogue data, semantic retrieval is performed using a question-and-answer database;
[0030] When the second half of the sentence corresponding to the first half cannot be retrieved, the dialogue generation model with the final loss parameter is used to predict the second half of the sentence.
[0031] Optionally, the dialogue generation model is a seq2seq model.
[0032] Secondly, an apparatus for determining the loss parameters of a dialogue generation model is provided, the apparatus comprising:
[0033] The training module is used to train the dialogue generation model using labeled samples of dialogue data, and to obtain the overall loss parameters of the dialogue generation model.
[0034] The virtual adversarial training module is used to perform virtual adversarial training using the labeled samples to obtain virtual adversarial loss parameters.
[0035] The update module is used to obtain the final loss parameters of the dialogue generation model based on the sum of the overall loss parameters and the virtual adversarial loss parameters.
[0036] Thirdly, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0037] Memory, used to store computer programs;
[0038] When a processor executes a program stored in memory, it implements the steps of determining the loss parameters of any of the aforementioned dialogue generation models.
[0039] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements the steps of the method for determining the loss parameters of any of the aforementioned dialogue generation models.
[0040] Beneficial effects of the embodiments in this application:
[0041] This application provides a method for determining the loss parameters of a dialogue generation model. Because it uses virtual adversarial training and does not use label information, it reduces the excessive reliance on manually labeled samples. It adopts a semi-supervised learning approach and obtains the joint loss of the overall loss parameters and the virtual adversarial loss parameters based on virtual adversarial training. Without sacrificing the robustness of the model, it enhances the generalization ability and accuracy of the dialogue generation model.
[0042] Of course, implementing any product or method of this application does not necessarily require achieving all of the above advantages at the same time. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 A flowchart illustrating a method for determining loss parameters of a dialogue generation model, provided in an embodiment of this application;
[0045] Figure 2 A flowchart illustrating the method for obtaining overall loss parameters provided in this application embodiment;
[0046] Figure 3 A schematic diagram illustrating the framework for determining the loss parameters of the dialogue generation model provided in this application embodiment;
[0047] Figure 4 A schematic diagram of a device for determining loss parameters of a dialogue generation model provided in an embodiment of this application;
[0048] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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 some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0050] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustration and has no specific meaning in itself. Therefore, "module" and "part" may be used interchangeably.
[0051] The method for determining the loss parameters of a dialogue generation model in this embodiment can be executed by a server to enhance the generalization ability and accuracy of the dialogue generation model.
[0052] The following will describe in detail, with reference to specific implementation methods, a method for determining the loss parameters of a dialogue generation model provided in this application, such as... Figure 1 As shown, the specific steps are as follows:
[0053] Step 101: Train the dialogue generation model using labeled samples of the dialogue data to obtain the overall loss parameters of the dialogue generation model.
[0054] In this embodiment, the server performs part-of-speech tagging and syntactic annotation on the dialogue data to obtain labeled samples. The server then trains the dialogue generation model using the labeled samples to obtain the overall loss parameters of the dialogue generation model.
[0055] Step 102: Perform virtual adversarial training using labeled samples to obtain virtual adversarial loss parameters.
[0056] In this embodiment, virtual adversarial training is a data augmentation technique that does not require prior domain knowledge. In virtual adversarial training, label information is not used; only the model output is used to generate perturbations, causing the output of the perturbated input to differ from the model output of the original input.
[0057] The server performs virtual adversarial training using labeled samples to obtain virtual adversarial loss parameters.
[0058] Step 103: Obtain the final loss parameters of the dialogue generation model based on the sum of the overall loss parameters and the virtual adversarial loss parameters.
[0059] In this embodiment, the server calculates the sum of the overall loss parameter and the virtual adversarial loss parameter to obtain the final loss parameter of the dialogue generation model. Thus, the final loss parameter of the dialogue generation model includes both its own overall loss parameter and the virtual adversarial loss parameter obtained from virtual adversarial training.
[0060] The formula for calculating the final loss parameter is as follows:
[0061] total_loss=Model_loss+vat_loss
[0062] Where total_loss is the final loss parameter, Model_loss is the overall loss parameter, and vat_loss is the virtual adversarial loss parameter.
[0063] This application employs virtual adversarial training, which eliminates the use of label information and reduces excessive reliance on manually labeled samples. It adopts a semi-supervised learning approach, training VAT based on virtual adversarial training to obtain the joint loss of the overall loss parameters and the virtual adversarial loss parameters. This enhances the generalization ability and accuracy of the dialogue generation model without sacrificing its robustness.
[0064] As an optional implementation method, such as Figure 2 As shown, the dialogue generation model is trained using labeled samples of dialogue data, and the overall loss parameters of the dialogue generation model include:
[0065] Step 201: Perform part-of-speech tagging and syntactic tagging on the dialogue data to obtain tagged samples.
[0066] The dialogue data includes the first and second statements belonging to different dialogue partners.
[0067] In this embodiment, the dialogue data includes a first statement and a second statement belonging to different dialogue partners. The first and second statements can be obtained through semantic segmentation. After the server segments the dialogue data, it performs part-of-speech tagging and syntactic annotation to obtain annotated samples.
[0068] Optionally, part-of-speech tagging and syntactic annotation of the dialogue data include: segmenting the dialogue data into words using a word segmentation tool; performing part-of-speech tagging on the segmented words using a part-of-speech recognition scheme; and performing syntactic annotation on the segmented words using a syntactic recognition scheme, wherein the syntactic annotation indicates the sentence components or sentence relationships of the segmented words in the dialogue data.
[0069] The server uses a word segmentation tool to segment the dialogue data, and then uses a part-of-speech tagging scheme to tag the segmented words. The part-of-speech tagging indicates the part of speech of the segmented words, such as nouns, pronouns, conjunctions, etc. Figure 3 This is a part-of-speech tag.
[0070] r n wp u c v p d m a pronoun noun punctuation particle conjunction verb preposition adverb numeral adjective
[0071] The server uses a syntactic recognition scheme to perform syntactic annotation on word segments. The syntactic annotation indicates the sentence components or sentence relationships of the word segments in the dialogue data, such as prepositional objects, subject-verb relationships, or verb-object relationships. Figure 4 This is a syntax comparison table.
[0072] SBV VOB IOB FOB DBL ATT ADV Subject-verb relationship Verb-object relationship Indirect Relationship Prepositional object Conjunction Fixed relationship Mid-structure
[0073] This application does not limit the word segmentation tool, part-of-speech tagging scheme, and syntactic tagging scheme. For example, this application can use other natural language processing tools such as LTP, Stanza, and Jieba for word segmentation, part-of-speech tagging, and syntactic tagging.
[0074] Step 202: Input the first statement into the dialogue generation model and obtain the prediction result output by the dialogue generation model.
[0075] The prediction results include the content, part of speech, and syntax of the predicted second statement.
[0076] In this embodiment, the server constructs a dialogue generation model based on an encoder-decoder structure. For example, the dialogue generation model is a seq2seq model. The server inputs a first statement into the dialogue generation model and obtains the prediction result output by the model. The prediction result includes the content, part-of-speech tag, and syntax of the predicted second statement.
[0077] Step 203: Compare the prediction results with the second sentence to obtain the first loss parameter of the dialogue generation model for the dialogue generation task, the second loss parameter for the part-of-speech prediction task, and the third loss parameter for the syntax prediction task.
[0078] In this embodiment, the server compares the prediction result with the second statement. Based on the comparison result, the server obtains the first loss parameter model_loss1 for the dialogue generation task through the hidden state layer of the decoder of the dialogue generation model, the second loss parameter model_loss2 for the part-of-speech prediction task through the decoder shared layer, and the third loss parameter model_loss3 for the syntax prediction task through the decoder shared layer.
[0079] Step 204: Obtain the overall loss parameter based on the first loss parameter, the second loss parameter, and the third loss parameter.
[0080] In this embodiment of the application, the server obtains three preset hyperparameters and, based on each loss parameter and its corresponding hyperparameter, obtains the overall loss parameter.
[0081] Model_loss=a*model_loss1+b*model_loss2+c*model_loss3
[0082] Where Model_loss is the overall loss parameter, and a, b, and c are hyperparameters.
[0083] In this application, the server incorporates part-of-speech prediction and syntactic prediction tasks into the model, and calculates the overall loss parameters of the multi-task constraints, which strengthens the syntactic constraints of the dialogue output sentences. Compared with the generative model, this improves the problems of incomplete output sentences, continuous repetition of words, and incoherent sentences.
[0084] Furthermore, compared to existing technologies that use rule templates for responses, this application does not require setting a large number of templates and can automatically respond using a dialogue generation model. Compared to existing technologies that use retrieval models that cannot capture the true meaning of semantics, this application can effectively capture the true meaning of semantics and improve response accuracy by strengthening the grammatical constraints of dialogue output statements.
[0085] As an optional implementation method, virtual adversarial training using labeled samples yields virtual adversarial loss parameters by: taking the first sentence of the labeled sample as an unperturbed input; transforming the unperturbed input by adding perturbations; obtaining the KL difference based on the perturbed output of the dialogue generation model for the perturbed input and the unperturbed output for the unperturbed input; and minimizing the KL difference by updating the weights of the dialogue generation model to obtain the virtual adversarial loss parameters.
[0086] 1) Take the first sentence of the labeled sample as the unperturbed input. Starting from the unperturbed input x, transform x by adding a small perturbation r. The perturbation input of the transformation is T(x) = X + r.
[0087] 2) The model output of the perturbation input T(x) should be different from the output of the unperturbation input, and the KL difference between the two outputs should be maximized, while ensuring that the L2 norm of r is small. From all perturbations r, let rv-adv be the perturbation in the adversarial direction.
[0088] Δ KL (r, x (n) ,θ)≡KL[p(y|x (n) ,θ)||p(y|x (n) +r,θ)] Formula (1)
[0089] Where, Δ KL (r, x (n) θ) represents the KL difference between the perturbed and undisturbed outputs, p(y|x) (n) θ) represents the non-perturbative output, p(y|x) (n) +r,θ) is the perturbation output, x(n) represents a certain input (or sample point), θ is the model parameter, and r is a perturbation for the input.
[0090] Formula (1) uses x (n) With x (n) The KL divergence of the output distribution +r represents the difference between the two distributions.
[0091]
[0092] in, It is about counteracting perturbations. Formula (2) finds the r that maximizes Formula (1) when the L2 norm of r is less than a certain value, that is, finds the perturbation direction that maximizes the difference between the two distributions, which is to find the training model with input x. (n) The direction in which the local distribution is least smooth.
[0093] 3) After identifying the adversarial perturbation and its input, update the weights of the dialogue generation model to minimize the KL divergence. This will make the dialogue generation model robust to different perturbations. The virtual adversarial loss parameters are obtained by minimizing the following loss using gradient descent.
[0094]
[0095] Formula (3) is the definition of x (n) The Local Distribution Smoothness (LDS) is: x (n) Maximum perturbation direction after perturbation x (n) The input-output distribution and x (n) The negative of the KL divergence between the input and output distributions.
[0096] As an optional implementation, after obtaining the final loss parameters of the dialogue generation model, the method further includes: performing semantic retrieval on the first half of the dialogue data using a question-and-answer database; and when the second half of the first half cannot be retrieved, using the dialogue generation model with the final loss parameters to predict the second half of the first half.
[0097] In the multilingual pre-training project, for the first half of the dialogue data, the server first uses a question-and-answer database to perform semantic retrieval and select a suitable response from the database; if no corresponding response is found in the database, the dialogue generation model is called to predict the second half of the sentence.
[0098] The traditional seq2seq generative dialogue algorithm has a rogue-L value of approximately 33.5%. Using the dialogue generation method based on improved semi-supervised learning proposed in this application, the rogue-L value is approximately 34.7%, and the fluctuation of the loss value during training is reduced within a certain range.
[0099] Figure 3 This diagram illustrates the framework for determining the loss parameters of a dialogue generation model. It shows that by supplementing the dialogue data with part-of-speech and syntactic annotations, then applying multi-task constraints, conducting virtual adversarial training, and finally calculating the joint loss, the final model parameters can be obtained.
[0100] Based on the same technical concept, embodiments of this application also provide a device for determining the loss parameters of a dialogue generation model, such as... Figure 4 As shown, the device includes:
[0101] Training module 401 is used to train the dialogue generation model using labeled samples of dialogue data to obtain the overall loss parameters of the dialogue generation model.
[0102] The virtual adversarial training module 402 is used to perform virtual adversarial training using labeled samples to obtain virtual adversarial loss parameters.
[0103] The update module 403 is used to obtain the final loss parameters of the dialogue generation model based on the sum of the overall loss parameters and the virtual adversarial loss parameters.
[0104] Optionally, the training module 401 includes:
[0105] The annotation unit is used to perform part-of-speech tagging and syntactic tagging on the dialogue data to obtain annotated samples. The dialogue data includes the first and second statements belonging to different dialogue objects.
[0106] The input / output unit is used to input the first statement into the dialogue generation model and obtain the prediction result output by the dialogue generation model. The prediction result includes the content, part of speech, and syntax of the predicted second statement.
[0107] The comparison unit is used to compare the prediction result with the second sentence to obtain the first loss parameter of the dialogue generation model for the dialogue generation task, the second loss parameter for the part-of-speech prediction task, and the third loss parameter for the syntax prediction task.
[0108] The obtained unit is used to obtain the overall loss parameters based on the first loss parameter, the second loss parameter, and the third loss parameter.
[0109] Optionally, the annotation unit is used for:
[0110] The dialogue data was segmented using a word segmentation tool;
[0111] A part-of-speech tagging scheme is used to perform part-of-speech tagging on the segmented words;
[0112] A syntactic recognition scheme is used to perform syntactic annotation on word segments, where the syntactic annotation indicates the sentence components or sentence relationships of the word segments in the dialogue data.
[0113] Optionally, the comparison unit is used for:
[0114] The first loss parameter for the dialogue generation task is obtained through the hidden state layer of the decoder of the dialogue generation model, where the dialogue generation model adopts an encoder-decoder structure;
[0115] The second loss parameter for the part-of-speech prediction task is obtained through the decoder shared layer of the dialogue generation model;
[0116] The third loss parameter for the syntactic prediction task is obtained through the decoder shared layer of the dialogue generation model.
[0117] Optionally, the virtual adversarial training module 402 is used for:
[0118] Use the first statement of the labeled sample as the non-perturbative input;
[0119] By adding a perturbation to the unperturbed input, a perturbed input is obtained through transformation.
[0120] The KL difference is obtained by comparing the perturbation output of the dialogue generation model for perturbation input with the non-perturbation output for non-perturbation input.
[0121] By updating the weights of the dialogue generation model and minimizing the KL discrepancy, the virtual adversarial loss parameters are obtained.
[0122] Optionally, the device is also used for:
[0123] For the first half of the dialogue data, semantic retrieval is performed using a question-and-answer database;
[0124] When the second half of the first half cannot be retrieved, a dialogue generation model with a final loss parameter is used to predict the second half of the first half.
[0125] Optionally, the dialogue generation model is a seq2seq model.
[0126] According to another aspect of the embodiments of this application, this application provides an electronic device, such as... Figure 5 As shown, the system includes a memory 503, a processor 501, a communication interface 502, and a communication bus 504. The memory 503 stores a computer program that can run on the processor 501. The memory 503 and the processor 501 communicate through the communication interface 502 and the communication bus 504. When the processor 501 executes the computer program, it implements the steps of the above method.
[0127] The memory and processor in the aforementioned electronic devices communicate with each other via a communication bus and a communication interface. The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0128] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0129] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0130] According to another aspect of the embodiments of this application, a computer-readable medium having processor-executable non-volatile program code is also provided.
[0131] Optionally, in embodiments of this application, the computer-readable medium is configured to store program code for the processor to execute the above-described method.
[0132] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.
[0133] In specific implementation, the embodiments of this application can be referred to the above embodiments and have corresponding technical effects.
[0134] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.
[0135] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0136] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0137] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0138] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0139] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0140] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0141] If the aforementioned function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks. It should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. In the absence of further restrictions, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0142] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for determining the loss parameters of a dialogue generation model, characterized in that, The method includes: The overall loss parameters of the dialogue generation model are obtained by training a dialogue generation model using labeled samples of dialogue data. Virtual adversarial training is performed using the labeled samples to obtain virtual adversarial loss parameters; The final loss parameters of the dialogue generation model are obtained based on the sum of the overall loss parameters and the virtual adversarial loss parameters. The overall loss parameters of the dialogue generation model, obtained by training a dialogue generation model using labeled samples of dialogue data, include: The dialogue data is tagged with part-of-speech tags and syntactic tags to obtain tagged samples, wherein the dialogue data includes first and second statements belonging to different dialogue objects; The first statement is input into the dialogue generation model to obtain the prediction result output by the dialogue generation model, wherein the prediction result includes the content, part of speech, and syntax of the predicted second statement; The prediction result is compared with the second statement to obtain the first loss parameter of the dialogue generation model for the dialogue generation task, the second loss parameter for the part-of-speech prediction task, and the third loss parameter for the syntax prediction task. The overall loss parameter is obtained based on the first loss parameter, the second loss parameter, and the third loss parameter; The first loss parameter of the dialogue generation model for the dialogue generation task, the second loss parameter for the part-of-speech prediction task, and the third loss parameter for the syntactic prediction task are obtained as follows: The first loss parameter for the dialogue generation task is obtained through the hidden state layer of the decoder of the dialogue generation model, wherein the dialogue generation model adopts an encoder-decoder structure; The second loss parameter for the part-of-speech prediction task is obtained through the decoder shared layer of the dialogue generation model; The third loss parameter for the syntactic prediction task is obtained through the decoder shared layer of the dialogue generation model.
2. The method according to claim 1, characterized in that, Part-of-speech tagging and syntactic tagging of the dialogue data include: The dialogue data was segmented using a word segmentation tool; The word segmentation is tagged with part-of-speech tags using a part-of-speech recognition scheme. A syntactic recognition scheme is used to perform syntactic annotation on the word segments, wherein the syntactic annotation indicates the sentence components or sentence relationships of the word segments in the dialogue data.
3. The method according to claim 1, characterized in that, The virtual adversarial training performed using the labeled samples to obtain the virtual adversarial loss parameters includes: The first statement of the labeled sample is used as the non-perturbative input; By adding a perturbation to the unperturbed input, a perturbed input is obtained; The KL difference is obtained based on the perturbation output of the dialogue generation model for the perturbation input and the non-perturbation output for the non-perturbation input; By updating the weights of the dialogue generation model and minimizing the KL discrepancy, the virtual adversarial loss parameters are obtained.
4. The method according to claim 1, characterized in that, After obtaining the final loss parameters of the dialogue generation model, the method further includes: For the first half of the dialogue data, semantic retrieval is performed using a question-and-answer database; When the second half of the sentence corresponding to the first half cannot be retrieved, the dialogue generation model with the final loss parameter is used to predict the second half of the sentence.
5. The method according to claim 1, characterized in that, The dialogue generation model is a seq2seq model.
6. A device for determining loss parameters of a dialogue generation model, characterized in that, The device includes: The training module is used to train the dialogue generation model using labeled samples of dialogue data, and to obtain the overall loss parameters of the dialogue generation model. The virtual adversarial training module is used to perform virtual adversarial training using the labeled samples to obtain virtual adversarial loss parameters. The update module is used to obtain the final loss parameters of the dialogue generation model based on the sum of the overall loss parameters and the virtual adversarial loss parameters. The training module includes: The annotation unit is used to perform part-of-speech tagging and syntactic tagging on the dialogue data to obtain annotated samples. The dialogue data includes the first and second statements belonging to different dialogue objects. The input / output unit is used to input the first statement into the dialogue generation model and obtain the prediction result output by the dialogue generation model. The prediction result includes the content, part of speech, and syntax of the predicted second statement. The comparison unit is used to compare the prediction result with the second sentence to obtain the first loss parameter of the dialogue generation model for the dialogue generation task, the second loss parameter for the part-of-speech prediction task, and the third loss parameter for the syntax prediction task. The unit is used to obtain the overall loss parameters based on the first loss parameter, the second loss parameter, and the third loss parameter; The comparison unit is used for: The first loss parameter for the dialogue generation task is obtained through the hidden state layer of the decoder of the dialogue generation model, where the dialogue generation model adopts an encoder-decoder structure; The second loss parameter for the part-of-speech prediction task is obtained through the decoder shared layer of the dialogue generation model; The third loss parameter for the syntactic prediction task is obtained through the decoder shared layer of the dialogue generation model.
7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-5.