A generative dialogue method, apparatus, and readable medium based on action tag retrieval
By constructing an encoding and soft-label generation model and utilizing action label retrieval technology, the limitations of the GPT dialogue generation system in terms of direction control, self-generated action labels, and high labor costs were solved, achieving controllability and diversity in dialogue generation and improving the system's efficiency and adaptability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIAMEN KUAISHANGTONG TECH CORP LTD
- Filing Date
- 2024-12-19
- Publication Date
- 2026-07-17
Smart Images

Figure CN119961391B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of dialogue generation, and more specifically to a generative dialogue method, apparatus, and readable medium based on action tag retrieval. Background Technology
[0002] Currently, the representative model in the field of generative dialogue technology is GPT (Generative Pre-trained Transformer). GPT adopts an autoregressive model architecture, with its core based on the decoder module of the Transformer. Trained through next token prediction, GPT can leverage a large-scale corpus and store a vast amount of domain-specific information with its massive parameter set, demonstrating the powerful potential of general AI intelligence. The emergence of GPT has had a disruptive impact on the basic architecture of traditional dialogue systems, showcasing extremely high application value and broad prospects.
[0003] Current dialogue generation systems based on GPT have the following drawbacks:
[0004] (1) Difficulty in controlling the direction of dialogue generation: GPT uses the next token format to generate text, and the generation result is highly dependent on its decoding strategy. However, neither the deterministic top-k algorithm nor the sampling-based top-p algorithm can guarantee that the direction of dialogue content generation is completely in line with expectations. Therefore, how to guide the model to generate target content through explicit action labels plays a key role in improving the relevance of dialogue and user retention rate. Due to its own architectural design and decoding strategy, it is obviously not a very good strategy to let the same GPT generate its own action labels.
[0005] (2) Limitations of Model-Generated Action Labels: Due to the limitations of the GPT model's architecture and decoding strategy, relying solely on GPT itself to generate action labels is clearly not an ideal solution. This approach not only makes it difficult to optimize dialogue quality but may also affect the consistency and diversity of generated content.
[0006] (3) Limited coverage: In real online dialogue environments, the diversity of user expressions, the complexity of questions, and the variety of scenarios makes it difficult for expert-specified action labeling strategies to cover all possible dialogue scenarios. This means that in some cases, the system may not be able to cope with sudden or atypical dialogue situations, leading to a decline in dialogue effectiveness.
[0007] (4) High labor costs and low efficiency: Relying on the experience of experts to specify action labels is very time-consuming and labor-intensive. The number of experts in each domain is limited, and a lot of time is required for design, adjustment and optimization. This not only reduces efficiency, but also makes it difficult for the model to be scalable and iterate quickly, especially when facing new dialogue scenarios or requirements.
[0008] In addition, different customers have different conversation habits with customer service robots. How to learn the distribution of action labels through the original dialogue to simulate human conversation habits and achieve command following is also one of the challenges. Summary of the Invention
[0009] The purpose of this application is to propose a generative dialogue method, apparatus, and readable medium based on action tag retrieval to address the aforementioned technical problems.
[0010] In a first aspect, the present invention provides a generative dialogue method based on action tag retrieval, comprising the following steps:
[0011] Construct and train an encoding model to obtain a trained encoding model. Input candidate historical dialogues into the trained encoding model to obtain candidate historical dialogue vectors. Store the candidate historical dialogue vectors and their corresponding answers in a vector library. The answers include the reply statement and the action label corresponding to the reply statement.
[0012] Acquire training data, where each sample includes historical dialogues and their corresponding answers; construct a soft-label generation model and a generative dialogue model, inputting the answers of each sample in the training data into the soft-label generation model, and using prompting engineering to guide the soft-label generation model to modify the action labels in each sample's answer into instruction statements based on the action labels and response statements in each sample's answer, and output soft-label data, which includes instruction statements and response statements;
[0013] The generative dialogue model is trained using the historical dialogue and soft-label data of each sample in the training data to obtain the trained generative dialogue model.
[0014] The system retrieves the historical dialogue to be replied to and inputs it into a trained encoding model to obtain the historical dialogue vector to be replied to. The system then retrieves the top N most similar candidate historical dialogue vectors from the vector library. Action labels are extracted from the answers corresponding to the top N most similar candidate historical dialogue vectors. The system then inputs the historical dialogue to be replied to and the action labels into a trained generative dialogue model to generate the corresponding reply statement.
[0015] Preferably, the encoding model includes a pre-trained BERT module or a pre-trained Roberta-wwm-base model.
[0016] As a preferred method, the training process for the encoding model is as follows:
[0017] Construct historical dialogues and their corresponding positive and negative samples;
[0018] The historical dialogues and their corresponding positive and negative samples are respectively input into the encoding model to obtain the historical dialogue vector, positive sample vector, and negative sample vector.
[0019] The contrastive learning loss function is constructed based on the historical dialogue vectors, positive sample vectors, and negative sample vectors, as shown in the following equation:
[0020] ;
[0021] Where L represents the contrastive learning loss function, Represents the historical dialogue vector. Represents a positive sample vector. This represents the i-th negative sample vector. {1, 2, ..., N}, where N is the number of negative samples; Represents cosine similarity. Indicates the temperature coefficient;
[0022] The coding model is trained using a contrastive learning loss function to obtain the trained coding model.
[0023] Preferably, the soft-label generation model, guided by prompting engineering, modifies the action labels in each sample's answer into instruction statements based on the action labels and response statements in each sample's answer, and outputs soft-label data, specifically including:
[0024] Construct prompt words. The prompt words require determining the separator between action tags and response statements in the given answer, modifying the content of the action tags to make them diverse, and at the same time, accurately describing the content of the response statements.
[0025] The soft tag generation model generates soft tag data based on prompt words and answers.
[0026] Preferably, the generative dialogue model is trained using the historical dialogues and soft-label data of each sample in the training data, resulting in a trained generative dialogue model, specifically including:
[0027] The historical dialogues of each sample in the training data and the instruction statements in the soft-label data are input into the generative dialogue model to obtain the generated response statements. A loss function is constructed based on the generated response statements and the response statements in the soft-label data. The generative dialogue model is then trained based on the loss function to obtain the trained generative dialogue model.
[0028] As preferred options, the soft tag generation model includes the qwen2-72b model, and the generative dialogue model includes the qwen2-7b model.
[0029] Secondly, the present invention provides a generative dialogue device based on action tag retrieval, comprising:
[0030] The vector library construction module is configured to build and train an encoding model to obtain a trained encoding model. Candidate historical dialogues are input into the trained encoding model to obtain candidate historical dialogue vectors. The candidate historical dialogue vectors and their corresponding answers are stored in the vector library. The answers include the reply statement and the action label corresponding to the reply statement.
[0031] The data augmentation module is configured to acquire training data, where each sample includes historical dialogues and their corresponding answers; construct a soft-label generation model and a generative dialogue model; input the answers of each sample in the training data into the soft-label generation model; guide the soft-label generation model through prompting engineering to modify the action labels in each sample's answer into instruction statements based on the action labels and response statements in each sample's answer; and output soft-label data, which includes instruction statements and response statements.
[0032] The model building module is configured to train the generative dialogue model using historical dialogue and soft-label data for each sample in the training data, resulting in a trained generative dialogue model.
[0033] The retrieval and generation module is configured to acquire the historical dialogue to be replied to and input it into the trained encoding model to obtain the historical dialogue vector to be replied to. The historical dialogue vector to be replied to is retrieved from the vector library to find the top N most similar candidate historical dialogue vectors. Action labels are extracted from the answers corresponding to the top N most similar candidate historical dialogue vectors. The historical dialogue to be replied to and the action labels are input into the trained generative dialogue model to generate the corresponding reply statement.
[0034] Thirdly, the present invention provides an electronic device including one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any implementation of the first aspect.
[0035] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the implementations of the first aspect.
[0036] Fifthly, the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the method as described in any of the implementations in the first aspect.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] (1) The generative dialogue method based on action tag retrieval proposed in this invention generates soft tag data on the basis of action tags and response statements through a soft tag generation model, thereby achieving the effect of data augmentation, reducing the cost of manually annotating a large number of action tags, and significantly improving efficiency.
[0039] (2) The generative dialogue method based on action tag retrieval proposed in this invention generates soft tag data through a soft tag generation model, avoiding the limitations of self-generated action tags, obtaining instruction statements that are closer to the response statements and ensure completeness and diversity. It uses historical dialogue and soft tag data to guide the training of the generative dialogue model, enabling the generative dialogue model to follow instructions based on action tags and generate more controllable response statements.
[0040] (3) The generative dialogue method based on action tag retrieval proposed in this invention can learn the distribution of action tags through historical dialogue to simulate human dialogue habits and achieve instruction following. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a flowchart illustrating a generative dialogue method based on action tag retrieval, as an embodiment of this application.
[0043] Figure 2 This is a schematic diagram of the comparative learning process of the encoding model of the generative dialogue method based on action tag retrieval, which is an embodiment of this application.
[0044] Figure 3 This is a schematic diagram of a generative dialogue device based on action tag retrieval, as an embodiment of this application.
[0045] Figure 4 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0047] Figure 1 An embodiment of this application illustrates a generative dialogue method based on action tag retrieval, comprising the following steps:
[0048] S1. Construct and train the encoding model to obtain the trained encoding model. Input the candidate historical dialogues into the trained encoding model to obtain the candidate historical dialogue vectors. Store the candidate historical dialogue vectors and their corresponding answers in the vector library. The answers include the reply statement and the action label corresponding to the reply statement.
[0049] In specific embodiments, the encoding model includes a pre-trained Bert module or a pre-trained Roberta-wwm-base model.
[0050] In a specific embodiment, the training process of the encoding model is as follows:
[0051] Construct historical dialogues and their corresponding positive and negative samples;
[0052] The historical dialogues and their corresponding positive and negative samples are respectively input into the encoding model to obtain the historical dialogue vector, positive sample vector, and negative sample vector.
[0053] The contrastive learning loss function is constructed based on the historical dialogue vectors, positive sample vectors, and negative sample vectors, as shown in the following equation:
[0054] ;
[0055] Where L represents the contrastive learning loss function, Represents the historical dialogue vector. Represents a positive sample vector. This represents the i-th negative sample vector. {1, 2, ..., N}, where N is the number of negative samples; Represents cosine similarity. Indicates the temperature coefficient;
[0056] The coding model is trained using a contrastive learning loss function to obtain the trained coding model.
[0057] For details, please refer to Figure 2The process involves acquiring the contextual dialogue, segmenting it into historical dialogue and responses. Responses strongly relevant to the historical dialogue are designated as positive samples, while those weakly relevant are designated as negative samples. The encoding model employs a pre-trained BERT model or a pre-trained Roberta-wwm-base model, trained using contrastive learning. Historical dialogues and their corresponding positive and negative samples are input into the encoding model, resulting in historical dialogue vectors, positive sample vectors, and negative sample vectors. The cosine similarity between historical dialogue vectors and positive sample vectors, and between historical dialogue vectors and negative sample vectors, are calculated and divided by a small temperature coefficient to make the encoding model more sensitive to positive and negative samples. A contrastive learning loss function is then calculated, and the encoding model is trained based on this loss function to obtain the trained encoding model.
[0058] Furthermore, in the embodiments of this application, the N of the contrastive learning loss function is equal to 2, that is, the negative samples are selected from the replies of other rounds in the current historical dialogue and any replies in other dialogues. The temperature coefficient is used to control the sharpness of the distribution; a lower temperature coefficient will make the branches sharper, while a higher temperature coefficient will make them smoother.
[0059] Building a vector library using a trained encoding model involves inputting each candidate historical dialogue into the model to obtain its corresponding candidate historical dialogue vector. The vector library stores several candidate historical dialogue vectors and their corresponding responses. Each response is composed of a reply statement and an action label, separated by a delimiter. The action labels are a small set of predefined categories based on expert experience, further annotated manually. These action labels include categories such as "consultation," "answering questions," and "linking," and can be further refined into secondary labels, such as "answering questions - examination introduction," or "consultation - disease-related consultation." However, the sample size of the action labels is too small, requiring further data augmentation to obtain a larger sample size.
[0060] S2, Obtain training data. Each sample in the training data includes historical dialogues and their corresponding answers. Construct a soft-label generation model and a generative dialogue model. Input the answers of each sample in the training data into the soft-label generation model. Guide the soft-label generation model through prompting engineering to modify the action labels in each sample's answer into instruction statements based on the action labels and response statements in each sample's answer, and output soft-label data, which includes instruction statements and response statements.
[0061] In specific embodiments, the soft tag generation model includes the qwen2-72b model, and the generative dialogue model includes the qwen2-7b model.
[0062] In a specific embodiment, the soft tag generation model, guided by prompting engineering, modifies the action tags in each sample's answer into instruction statements based on the action tags and response statements in each sample's answer, and outputs soft tag data, specifically including:
[0063] Construct prompt words. The prompt words require determining the separator between action tags and response statements in the given answer, modifying the content of the action tags to make them diverse, and at the same time, accurately describing the content of the response statements.
[0064] The soft tag generation model generates soft tag data based on prompt words and answers.
[0065] Specifically, the embodiments of this application construct prompts to enable a soft-tag generation model to generate soft-tag data. The soft-tag generation model employs the qwen2-72b model with a larger number of parameters to meet the requirements of the soft-tag data generation task. In the training data, responses are concatenated from action tags and reply statements, separated by a delimiter. Soft-tag data is concatenated from instruction statements and reply statements, also separated by a delimiter. The generative dialogue model is trained using historical dialogues and soft-tag data, employing the computationally less computationally intensive qwen2-7b model.
[0066] To enhance the generative dialogue model's understanding of instruction statements, embodiments of this application construct soft tag data through the following pipeline.
[0067] (1) One answer was found: "Q&A - Examination Introduction, Consultation - Disease-related Consultation\t||\tIf you usually have poor sleep quality, you can also have liver function and blood routine tests. What are your thoughts?"
[0068] (2) Construct prompt words: "Based on the given answer, use \t||\t as the separator between the action label and the reply statement, modify the content in the action label to make it more diverse and more accurately describe the content of the reply statement." Input the answer and prompt words into the soft label generation model to generate soft label data.
[0069] (3) Output soft-label data: "Reply to the visitor on how to check symptoms through examination, and ask the visitor if they are willing to continue treatment. If you usually have poor sleep quality, you can also have liver function and blood routine tests. What are your thoughts?" This part, "Reply to the visitor on how to check symptoms through examination, and ask the visitor if they are willing to continue treatment," is an instruction statement obtained by modifying action labels and response statements. Different instruction statements can be generated by combining action labels with response statements, thus increasing the sample size and strengthening the ability to follow instructions.
[0070] (4) Train the generative dialogue model together with the historical dialogue of each sample in the training data and the generated soft label data, and use the trained generative dialogue model to perform generative dialogue.
[0071] S3 uses the historical dialogues and soft-label data of each sample in the training data to train the generative dialogue model, resulting in a trained generative dialogue model.
[0072] In a specific embodiment, step S3 specifically includes:
[0073] The historical dialogues of each sample in the training data and the instruction statements in the soft-label data are input into the generative dialogue model to obtain the generated response statements. A loss function is constructed based on the generated response statements and the response statements in the soft-label data. The generative dialogue model is then trained based on the loss function to obtain the trained generative dialogue model.
[0074] Specifically, in the training process of a generative dialogue model, the historical dialogues of each sample in the training data and the instruction statements in the soft-label data are input into the generative dialogue model to obtain the response statements generated by the model. A loss function is constructed using these generated response statements and the response statements in the soft-label data. Based on this loss function, the generative dialogue model is trained to obtain a trained generative dialogue model. This trained model enhances its understanding of action labels, improves the relevance and consistency of generated content, reduces reliance on expert experience, lowers labor costs, and enhances the system's scalability and flexibility.
[0075] S4. Obtain the historical dialogue to be replied to and input it into the trained encoding model to obtain the historical dialogue vector to be replied to. Retrieve the top N most similar candidate historical dialogue vectors from the vector library. Extract action labels from the answers corresponding to the top N most similar candidate historical dialogue vectors. Input the historical dialogue to be replied to and the action labels into the trained generative dialogue model to generate the corresponding reply statement.
[0076] Specifically, the trained generative dialogue model is deployed. During the inference phase, the historical dialogue to be responded to is input into the trained encoding model to generate a historical dialogue vector. The top N candidate historical dialogue vectors most similar to the historical dialogue vector to be responded to are retrieved from the vector library. Here, the cosine similarity between the historical dialogue vector to be responded to and the candidate historical dialogue vectors can be calculated. In one embodiment, N=5. Therefore, the 5 most similar candidate historical dialogue vectors are retrieved from the vector library, and action tags are extracted from their corresponding answers. The historical dialogue to be responded to and the extracted action tags are input into the trained generative dialogue model to generate the corresponding response statement.
[0077] Further reference Figure 3 As an implementation of the methods shown in the above figures, this application provides an embodiment of a generative dialogue device based on action tag retrieval, which is similar to... Figure 1 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0078] This application provides a generative dialogue device based on action tag retrieval, including:
[0079] Vector library construction module 1 is configured to build and train an encoding model to obtain a trained encoding model. Candidate historical dialogues are input into the trained encoding model to obtain candidate historical dialogue vectors. The candidate historical dialogue vectors and their corresponding answers are stored in the vector library. The answers include the reply statement and the action label corresponding to the reply statement.
[0080] Data augmentation module 2 is configured to acquire training data, where each sample includes historical dialogues and their corresponding answers; construct a soft-label generation model and a generative dialogue model, input the answers of each sample in the training data into the soft-label generation model, guide the soft-label generation model through prompting engineering to modify the action labels in each sample's answer into instruction statements based on the action labels and response statements in each sample's answer, and output soft-label data, which includes instruction statements and response statements;
[0081] Model building module 3 is configured to train the generative dialogue model using the historical dialogue and soft-label data of each sample in the training data, so as to obtain the trained generative dialogue model.
[0082] The retrieval and generation module 4 is configured to obtain the historical dialogue to be replied to and input it into the trained encoding model to obtain the historical dialogue vector to be replied to. The historical dialogue vector to be replied to is retrieved from the vector library to find the top N most similar candidate historical dialogue vectors. Action labels are extracted from the answers corresponding to the top N most similar candidate historical dialogue vectors. The historical dialogue to be replied to and the action labels are input into the trained generative dialogue model to generate the corresponding reply statement.
[0083] Figure 4 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. For example... Figure 4 As shown, the electronic device in this embodiment includes a processor 401 and a memory 402; wherein the memory 402 is used to store computer execution instructions; and the processor 401 is used to execute the computer execution instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant descriptions in the foregoing method embodiments.
[0084] Alternatively, the memory 402 can be either standalone or integrated with the processor 401.
[0085] When the memory 402 is set up independently, the electronic device also includes a bus 403 for connecting the memory 402 and the processor 401.
[0086] This invention also provides a computer storage medium storing computer execution instructions, which, when executed by processor 401, implement the above method.
[0087] This invention also provides a computer program product, including a computer program, which, when executed by a processor 401, implements the above-described method.
[0088] In the embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device 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 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 indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0089] The modules described as separate components may or may not be physically separate. The components shown as modules 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 modules can be selected to implement the solution of this embodiment according to actual needs.
[0090] Furthermore, the functional modules in the various embodiments of this invention can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The unit formed by the above modules can be implemented in hardware or in the form of hardware plus software functional units.
[0091] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor 401 to execute some steps of the methods of the various embodiments of this application.
[0092] It should be understood that the processor 401 described above can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor, or the processor 401 can be any conventional processor 401. The steps of the method disclosed in this invention can be directly manifested as the hardware processor 401 executing the steps, or as a combination of hardware and software modules within the processor 401 executing the steps.
[0093] The memory 402 may include high-speed RAM memory, and may also include non-volatile memory NVM, such as at least one disk storage device, and may also be a USB flash drive, portable hard drive, read-only memory, disk or optical disc, etc.
[0094] Bus 403 can be an Industry Standard Architecture (ISA), a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Bus 403 can be divided into address bus, data bus, control bus, etc. For ease of illustration, the bus 403 in the accompanying drawings of this application is not limited to only one bus 403 or one type of bus 403.
[0095] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0096] An exemplary storage medium is coupled to processor 401, enabling processor 401 to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of processor 401. Processor 401 and storage medium can reside in application-specific integrated circuits (ASICs). Alternatively, processor 401 and storage medium can exist as discrete components in an electronic device or host device.
[0097] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A generative dialogue method based on action tag retrieval, characterized in that, Includes the following steps: Construct and train an encoding model to obtain a trained encoding model. Input candidate historical dialogues into the trained encoding model to obtain candidate historical dialogue vectors. Store the candidate historical dialogue vectors and their corresponding answers in a vector library. The answers include reply statements and action tags corresponding to the reply statements. Acquire training data, where each sample includes historical dialogues and their corresponding responses; construct a soft-label generation model and a generative dialogue model, inputting the responses of each sample in the training data into the soft-label generation model, and guiding the soft-label generation model through prompting engineering to modify the action labels in each sample's response into instruction statements based on the action labels and response statements in each sample's response, and outputting soft-label data, specifically including: Construct prompt words, wherein the prompt words require the soft tag generation model to determine the separator between action tags and reply statements in the given answer and require the soft tag generation model to modify the content in the action tags; The soft tag generation model generates soft tag data based on the prompt words and the answers, and the soft tag data includes the instruction statement and the response statement; The generative dialogue model is trained using the historical dialogue and soft-label data of each sample in the training data to obtain the trained generative dialogue model. The historical dialogue to be replied to is obtained and input into the trained encoding model to obtain the historical dialogue vector to be replied to. The top N most similar candidate historical dialogue vectors are retrieved from the vector library. Action tags are extracted from the answers corresponding to the top N most similar candidate historical dialogue vectors. The historical dialogue to be replied to and the action tags are input into the trained generative dialogue model to generate the corresponding reply statement.
2. The generative dialogue method based on action tag retrieval according to claim 1, characterized in that, The encoding model includes a pre-trained Bert module or a pre-trained Roberta-wwm-base model.
3. The generative dialogue method based on action tag retrieval according to claim 1, characterized in that, The training process of the encoding model is as follows: Construct historical dialogues and their corresponding positive and negative samples; The historical dialogue and its corresponding positive and negative samples are respectively input into the encoding model to obtain the historical dialogue vector, positive sample vector, and negative sample vector; Based on the historical dialogue vectors, positive sample vectors, and negative sample vectors, a contrastive learning loss function is constructed as follows: ; Where L represents the contrastive learning loss function, Represents the historical dialogue vector. Represents a positive sample vector. This represents the i-th negative sample vector. {1, 2, ..., N}, where N is the number of negative samples; Represents cosine similarity. Indicates the temperature coefficient; The encoding model is trained based on the contrastive learning loss function to obtain the trained encoding model.
4. The generative dialogue method based on action tag retrieval according to claim 1, characterized in that, The generative dialogue model is trained using the historical dialogue and soft-label data of each sample in the training data to obtain the trained generative dialogue model, specifically including: The historical dialogues of each sample in the training data and the instruction statements in the soft-label data are input into the generative dialogue model to obtain the generated response statements. A loss function is constructed based on the generated response statements and the response statements in the soft-label data. The generative dialogue model is trained based on the loss function to obtain the trained generative dialogue model.
5. The generative dialogue method based on action tag retrieval according to claim 1, characterized in that, The soft tag generation model includes the qwen2-72b model, and the generative dialogue model includes the qwen2-7b model.
6. A generative dialogue device based on action tag retrieval, characterized in that, include: The vector library construction module is configured to build and train an encoding model to obtain a trained encoding model. Candidate historical dialogues are input into the trained encoding model to obtain candidate historical dialogue vectors. The candidate historical dialogue vectors and their corresponding answers are stored in the vector library. The answers include the reply statement and the action label corresponding to the reply statement. The data augmentation module is configured to acquire training data, wherein each sample in the training data includes historical dialogues and their corresponding responses; A soft-label generation model and a generative dialogue model are constructed. The answer of each sample in the training data is input into the soft-label generation model. Through prompting engineering, the soft-label generation model modifies the action labels in each sample's answer into instruction statements based on the action labels and response statements in each sample's answer, and outputs soft-label data. Specifically, this includes: Construct prompt words, wherein the prompt words require the soft tag generation model to determine the separator between action tags and reply statements in the given answer and require the soft tag generation model to modify the content in the action tags; The soft tag generation model generates soft tag data based on the prompt words and the answers, and the soft tag data includes the instruction statement and the response statement; The model building module is configured to train the generative dialogue model using historical dialogue and soft-label data for each sample in the training data, to obtain a trained generative dialogue model. The retrieval and generation module is configured to acquire the historical dialogue to be replied to and input it into the trained encoding model to obtain the historical dialogue vector to be replied to. The module retrieves the top N most similar candidate historical dialogue vectors from the vector library, extracts action tags from the answers corresponding to the top N most similar candidate historical dialogue vectors, and inputs the historical dialogue to be replied to and the action tags into the trained generative dialogue model to generate the corresponding reply statement.
7. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-5.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-5.