Dialogue model training method, intelligent dialogue method, intelligent dialogue device and electronic equipment
By using a large model to extract question-and-answer samples from source data that meet the needs of specific scenarios in intelligent dialogue model training and training the model based on sample labels, the problem that the model in the existing technology is unable to answer different scenarios efficiently and accurately, achieving more efficient and accurate model training and answering effects.
Patent Information
- Application Number
- CN202510162303.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-06-13
AI Technical Summary
When training intelligent dialogue models, the prior art is difficult to meet the needs of different application scenarios, resulting in the training of the model cannot answer the questions of the applied scenarios efficiently and accurately.
By obtaining the source data for extracting question and answer samples, according to the sample requirement information corresponding to each pre-set question and answer type, a large model is used to determine the question and answer samples that meet the sample requirement information corresponding to the question and answer type from the source data, and train the training model based on the question and answer samples marked with the sample label to obtain a dialogue model that can generate the answer content that meets the compliance requirements.
The training dialogue model can provide efficient and accurate answers to the applied scenarios, improve the accuracy of the dialogue model's answers, and quickly and accurately extract question and answer samples through large models, improving the model training efficiency and sample richness.
Smart Images

Figure CN120146181A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and particularly to a training method for a dialogue model, an intelligent dialogue method, a device, an electronic device, and a computer-readable storage medium. Background Art
[0002] In the field of intelligent dialogue, model training is a crucial link, which determines the performance, accuracy, and generalization ability of the model. Traditional machine learning methods usually rely on predefined datasets for training. Through the various data in the dataset, the model can be trained to have the ability to answer different questions, and the answers can meet specific requirements, such as meeting security requirements, compliance requirements, requirements of not containing sensitive words, and so on.
[0003] When training an intelligent dialogue model with related technologies, usually each data in the existing dataset is used to train the model. However, in actual applications, the requirements for the model in different application scenarios vary greatly. Using each data in the existing dataset to train the model is very likely to cause the trained dialogue model to be unable to answer the applied scenario efficiently and accurately, resulting in poor answer accuracy of the dialogue model. Summary of the Invention
[0004] The present application provides a training method for a dialogue model, an intelligent dialogue method, a device, an electronic device, and a computer-readable storage medium, which can enable the trained dialogue model to answer the applied scenario efficiently and accurately, thereby making the answer accuracy of the dialogue model higher. The specific solutions are as follows:
[0005] In a first aspect, the present application provides a training method for a dialogue model, and the method includes:
[0006] Obtain source data for extracting question-and-answer samples;
[0007] According to the sample requirement information corresponding to each question-and-answer type set in advance, determine question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type from the source data through a large model;
[0008] Obtain the sample label corresponding to the question-and-answer sample, and the sample label is used to indicate the compliance of the answer content in the question-and-answer sample;
[0009] Train a model to be trained based on the question-and-answer sample marked with the sample label to obtain a trained dialogue model, and the dialogue model is used to generate answer content that meets the compliance requirements.
[0010] Optionally, the sample requirement information corresponding to each pre-set Q&A type is used to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the source data through a large model, including:
[0011] Extract key information from the source data;
[0012] According to the sample requirement information corresponding to each pre-set Q&A type, use a large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the key information.
[0013] Optionally, the extraction of key information from the source data includes at least one of the following:
[0014] Extract key information from the source data by means of regular expressions;
[0015] Extract key information from the source data by means of a pre-trained large model.
[0016] Optionally, the extraction of key information from the source data includes:
[0017] Based on the sample requirement information corresponding to each pre-set Q&A type, extract key information corresponding to the sample requirement information corresponding to each Q&A type from the source data.
[0018] Optionally, the use of a large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the key information according to the sample requirement information corresponding to each pre-set Q&A type includes:
[0019] Determine the Q&A type corresponding to each piece of key information;
[0020] Based on the Q&A type corresponding to each piece of key information, according to the sample requirement information corresponding to each pre-set Q&A type, use a large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the key information.
[0021] Optionally, the use of a large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the key information based on the Q&A type corresponding to each piece of key information and according to the sample requirement information corresponding to each pre-set Q&A type includes:
[0022] Obtain pre-set example Q&A samples;
[0023] Based on the example Q&A samples and the Q&A types corresponding to each of the key point information, and according to the sample requirement information corresponding to each of the preset Q&A types, determine, through a large model, Q&A samples from the key point information that meet the sample requirement information corresponding to the Q&A type and are consistent with the example Q&A samples.
[0024] Optionally, the determining, through a large model, Q&A samples from the key point information that meet the sample requirement information corresponding to the Q&A type according to the sample requirement information corresponding to each of the preset Q&A types based on the Q&A types corresponding to each of the key point information includes:
[0025] Obtain the sample constraint conditions corresponding to each Q&A type, where the sample constraint conditions are used to indicate the sample styles of the samples of the Q&A type;
[0026] Based on the Q&A types corresponding to each of the key point information and the sample constraint conditions corresponding to each Q&A type, determine, through a large model, Q&A samples of each Q&A type from the key point information that meet the sample requirement information corresponding to the Q&A type and meet the corresponding sample constraint conditions according to the sample requirement information corresponding to each of the preset Q&A types.
[0027] Optionally, before training the model to be trained based on the Q&A samples marked with the sample labels, the method further includes:
[0028] Perform text rewriting processing on the Q&A samples to rewrite the Q&A samples into smooth text to obtain rewritten Q&A samples;
[0029] The training of the model to be trained based on the Q&A samples marked with the sample labels includes:
[0030] Train the model to be trained based on the rewritten Q&A samples marked with the sample labels.
[0031] Optionally, the determining, through a large model, Q&A samples from the source data that meet the sample requirement information corresponding to the Q&A type includes:
[0032] Extract Q&A samples from the source data through a large model;
[0033] Perform quantity expansion rewriting on the extracted Q&A samples through a large model to obtain Q&A samples that meet the sample requirement information corresponding to the Q&A type.
[0034] Optionally, the method further includes:
[0035] Determine the actual answer content corresponding to the question input by the user through the dialogue model;
[0036] Find out the non-compliant answer content that does not meet the compliance requirements from the actual answer content, and mark the non-compliant answer content and the corresponding questions as non-compliant Q&A samples;
[0037] Optimize and train the dialogue model with the non-compliant Q&A samples to obtain an optimized dialogue model.
[0038] Optionally, the determining the actual answer content corresponding to the question input by the user through the dialogue model includes:
[0039] Obtain question logs;
[0040] Filter out non-user input question logs from the question logs to obtain user input question logs;
[0041] Determine the actual answer content corresponding to the user input question logs through the dialogue model.
[0042] Optionally, the sample requirement information corresponding to each Q&A type includes at least one of the following:
[0043] The sample demand quantity corresponding to each Q&A type;
[0044] The sample demand ratio between each Q&A type.
[0045] Optionally, the source data includes general Q&A source data and / or source data corresponding to the target scenario, and the target scenario is the scenario where the dialogue model is applied.
[0046] Optionally, the source data corresponding to the target scenario includes at least one of the following: historical Q&A data corresponding to the target scenario, examination data corresponding to the target scenario, institutional data corresponding to the target scenario, introduction data corresponding to the target scenario, and proprietary name explanation data involved in the target scenario.
[0047] Optionally, each Q&A type includes a daily Q&A type and a target scenario Q&A type.
[0048] Optionally, the target scenario is a target enterprise, and the target scenario Q&A type includes at least one of the following types: self-awareness Q&A, target enterprise awareness Q&A, information security Q&A, policy and system security Q&A, and command attack Q&A.
[0049] In a second aspect, the present application also provides an intelligent dialogue method, and the method includes:
[0050] Obtain a query question input by the user;
[0051] Input the query problem entered by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query problem, where the dialogue model is trained by the training method of the dialogue model according to any item of the first aspect.
[0052] Optionally, the step of inputting the query problem entered by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query problem includes:
[0053] Obtain a reference database, where the reference data in the reference database is used for the dialogue model to refer to during the process of answering questions;
[0054] Input the query problem entered by the user into a pre-trained dialogue model so that the dialogue model obtains the answer content corresponding to the query problem based on the reference database.
[0055] Optionally, the intelligent dialogue method further includes:
[0056] Search for non-compliant answer content that does not meet the compliance requirements from the answer content;
[0057] Update the content in the reference database according to the non-compliant answer content.
[0058] Optionally, before inputting the query problem entered by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query problem, the intelligent dialogue method further includes:
[0059] Identify whether there is non-compliant content in the query problem entered by the user;
[0060] If there is, rewrite the query problem entered by the user so that the rewritten query problem does not have non-compliant content;
[0061] The step of inputting the query problem entered by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query problem includes:
[0062] Input the rewritten query problem into a pre-trained dialogue model to obtain the answer content corresponding to the rewritten query problem.
[0063] Optionally, the dialogue model is pre-connected to the risk control module of a large model, and the risk control module is used to control daily non-compliant content;
[0064] The step of inputting the query problem entered by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query problem includes:
[0065] Input the query problem entered by the user into a pre-trained dialogue model, so that the dialogue model controls the non-compliant content of the query problem through the risk control module to obtain a compliant query problem, and generate compliant answer content corresponding to the compliant query problem.
[0066] Optionally, the intelligent dialogue method further includes:
[0067] Detect privacy information in the answer content;
[0068] Perform encryption processing on the privacy information to obtain encrypted answer content, and the encrypted answer content is used for display.
[0069] Optionally, the encryption processing of the privacy information includes at least one of the following:
[0070] Hide the privacy information;
[0071] Replace the privacy information with special characters;
[0072] Encrypt and encode the privacy information to obtain encoded information.
[0073] In a third aspect, the present application further provides a training device for a dialogue model, and the device includes:
[0074] A source data acquisition unit for acquiring source data for extracting question-and-answer samples;
[0075] A sample determination unit for determining question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type from the source data through a large model according to the sample requirement information corresponding to each pre-set question-and-answer type;
[0076] A marking unit for acquiring a sample label corresponding to the question-and-answer sample, and the sample label is used to indicate the compliance of the answer content in the question-and-answer sample;
[0077] A training unit for training a model to be trained based on the question-and-answer samples marked with the sample labels to obtain a trained dialogue model, and the dialogue model is used to generate answer content that meets the compliance requirements.
[0078] In a fourth aspect, the present application further provides an intelligent dialogue device, and the device includes:
[0079] A problem acquisition unit for acquiring a query problem input by a user;
[0080] An answer generation unit for inputting the query question input by the user into a pre-trained dialogue model to obtain an answer content corresponding to the query question, where the dialogue model is trained by the training method of the dialogue model according to any one of the first aspects.
[0081] In a fifth aspect, the present application further provides an electronic device, including: a processor, a memory, and computer program instructions stored on the memory and executable on the processor; when the processor executes the computer program instructions, the method according to any one of the first aspect to the second aspect is implemented.
[0082] In a sixth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, the method according to any one of the first aspect to the second aspect is implemented.
[0083] In a seventh aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method according to any one of the first aspect to the second aspect is implemented.
[0084] Compared with the prior art, the present application has the following advantages:
[0085] The training method of the dialogue model provided by the embodiment of the present application obtains source data for extracting Q&A samples, and this source data provides the source of samples required for the training of the dialogue model. According to the sample requirement information corresponding to each Q&A type set in advance, the large model determines Q&A samples that meet the sample requirement information corresponding to the Q&A type from the source data. In this way, the staff can set the sample requirement information corresponding to different Q&A types according to the scenario to which the dialogue model is applied, and the sample requirement information corresponding to each set Q&A type can meet the scenario to which the dialogue model is applied. The present application also extracts samples from the source data according to the sample requirement information corresponding to each Q&A type based on the large model. Since the large model has an intelligent data processing function, the large model can conveniently and flexibly extract Q&A samples that meet the sample requirement information, and then obtain the sample labels corresponding to the Q&A samples. The sample labels are used to indicate the compliance of the answer content in the Q&A samples. The model to be trained is trained based on the Q&A samples marked with the sample labels, and the trained dialogue model obtained can generate answer content that meets the compliance requirements.
[0086] It can be seen that when obtaining Q&A samples in the training method of the dialogue model provided by this application, by extracting Q&A samples from the source data according to the sample demand information corresponding to each Q&A type preset to meet the scenarios to which the dialogue model is applied and based on the large model, it is possible not only to make the distribution of each extracted Q&A sample meet the requirements of the scenarios to which the dialogue model is applied, so that the trained dialogue model can answer efficiently and accurately for the applied scenarios, making the answers of the dialogue model more accurate, but also to quickly and accurately extract Q&A samples that meet the sample demand information by using the large model, improving the model training efficiency, and further improving the richness of the extracted samples. By selecting Q&A samples that meet the sample demand information corresponding to each Q&A type, this application can also avoid a lot of ineffective training, reduce the waste of computing resources, and further improve the model training efficiency.
[0087] In addition, this application also marks the compliance labels for the Q&A samples. In this way, the trained model can also answer content that meets the compliance requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1 is a schematic diagram of the application scenario of the dialogue model provided by this application;
[0089] Figure 2 is a schematic flowchart of an example of the training method of the dialogue model provided by an embodiment of this application;
[0090] Figure 3 is a schematic classification diagram of an example of the Q&A types in this application;
[0091] Figure 4 is a schematic flowchart of an example of obtaining Q&A samples in an embodiment of this application
[0092] Figure 5 is an application flowchart of the dialogue model trained by an embodiment of this application;
[0093] Figure 6 is a schematic flowchart of an example of the intelligent dialogue method provided by an embodiment of this application;
[0094] Figure 7 is an example of the effect diagram of encrypting privacy information provided by an embodiment of this application;
[0095] Figure 8 is another example of the effect diagram of encrypting privacy information provided by an embodiment of this application
[0096] Figure 9 is a block diagram of the structure of the electronic device provided by this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0097] To enable those skilled in the art to better understand the technical solutions of this application, the following clearly and completely describes this application in conjunction with the accompanying drawings in the embodiments of this application. However, this application can be implemented in many other ways different from the following description. Therefore, based on the embodiments provided in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.
[0098] It should be noted that the terms "first", "source domain", "third", etc. in the claims, specification and drawings of this application are used to distinguish similar objects and are not used to describe a specific order or sequence. Such data can be interchanged under appropriate circumstances so that the embodiments of this application described herein can be implemented in an order other than that shown or described herein. In addition, the terms "comprising", "having" and their variants are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0099] To facilitate the understanding of the embodiments of this application, the application background of the embodiments is described.
[0100] In the field of intelligent dialogue, model training is a crucial link, which determines the performance, accuracy and generalization ability of the model. Traditional machine learning methods usually rely on predefined data sets for training. Through the various data in the data set, the model can be trained to have the ability to answer different questions, and the answers can meet specific requirements, such as meeting security requirements, compliance requirements, and the requirement of not containing sensitive words, etc.
[0101] When training an intelligent dialogue model using related technologies, usually each data in the existing data set is used to train the model. That is, the training set is determined before the start of training, and the training set usually does not change during the entire training process. Even if it changes, it is to add some general data. This method greatly limits the flexibility of the model to adapt to new environments or new categories.
[0102] In practical applications, the requirements for the model vary greatly in different application scenarios. Using each data in the existing data set to train the model is very likely to result in the trained dialogue model being unable to answer the applied scenario efficiently and accurately, thus resulting in poor answer accuracy of the dialogue model.
[0103] In addition, when preparing sample data for a specific task scenario, if a too large and complex general dataset is used, it may contain a large amount of information irrelevant to the task scenario, resulting in a waste of computing resources and an increase in training time.
[0104] To solve the above problems, the embodiments of the present application provide a training method for a dialogue model, an intelligent dialogue method, a device, an electronic device, and a computer-readable storage medium. The aim is to enable the trained dialogue model to answer efficiently and accurately for the applied scenario, so that the accuracy of the dialogue model's answers is higher.
[0105] The training method for the dialogue model provided by the present application can be used to train a general dialogue model or a dialogue model for a specific scenario. For example, it can be used to train an employee Q&A dialogue model within an enterprise, a medical Q&A dialogue model, a service consultation Q&A dialogue model, a professional knowledge Q&A dialogue model, etc. The present application does not specifically limit.
[0106] To facilitate the understanding of the method embodiments of the present application, its application scenario is introduced. Please refer to Figure 1 , Figure 1 which is a schematic diagram of the application scenario of the solution provided by the embodiments of the present application. This application scenario is a schematic example and does not serve as a specific description of its application scenario. As Figure 1 shown, a server 102 and a client 101 are provided in this application scenario. In this embodiment, a connection is established between the client 101 and the server 102 through network communication for data transmission.
[0107] The client 101 can be an electronic device with a display function and data processing function such as a mobile phone, a tablet computer (pad), a smart watch, a desktop computer, a smart TV, a VR device, a vehicle-mounted device, a wearable device, a notebook computer, etc. The client 101 is used to send an inquiry question to the server 102 and obtain and display the generated answer content from the server 102.
[0108] The server 102 has high computing power. The server 102 can be a server, and the server 102 has high-speed central processing unit (CPU) computing power, long-term reliable operation, strong input / output (I / O) external data throughput capacity, and better scalability. The server 102 can be a single server or a server cluster. A dialogue model is deployed on the server 102. The server 102 can generate response content corresponding to the questions sent by the client through the dialogue model and send the response content to the client 101. The server 102 can also provide other specific services for the client 101, such as user information access, website access, application program access, etc., which are not specifically limited in this application.
[0109] The dialogue model deployed on the server 102 is trained by the model training method provided by this application.
[0110] The client 101 and the server 102 can communicate with each other using various communication systems, such as a wired communication system or a wireless communication system. The wireless communication system can be, for example, a global system for mobile communications (GSM) system, a code division multiple access (CDMA) system, a wideband code division multiple access (WCDMA) system, a general packet radio service (GPRS), a long term evolution (LTE) system, an LTE frequency division duplex (FDD) system, an LTE time division duplex (TDD), a universal mobile telecommunication system (UMTS), a worldwide interoperability for microwave access (WiMAX) communication system, a future fifth generation (5G) system or a new radio (NR), a satellite communication system, etc.
[0111] Embodiment 1
[0112] The first embodiment of the present application provides a method for training a dialogue model. This method is applied to an electronic device, which can be an electronic device with data processing functions such as a server, a laptop, a tablet computer, a desktop computer, a mobile phone, a smart TV, etc.
[0113] As Figure 2 shown, the method for training the dialogue model provided in the first embodiment of the present application includes the following steps S110 to S140.
[0114] Step S110: Obtain source data for extracting question-and-answer samples.
[0115] The above source data may include general question-and-answer source data and / or source data corresponding to the target scenario, where the target scenario is the scenario to which the dialogue model is applied.
[0116] The above general source data may be daily question-and-answer dialogue data. The general source data may include an existing general question-and-answer sample set, that is, a general question-and-answer evaluation set, which may specifically include an industry evaluation set and general attack instructions, etc.
[0117] The above target scenario may be a specific enterprise scenario, a medical inquiry field, a professional knowledge query field, a navigation field, a catering service field, etc. Those skilled in the art can set specific target scenarios according to actual needs.
[0118] The source data corresponding to the target scenario includes at least one of the following: historical question-and-answer data corresponding to the target scenario, examination data corresponding to the target scenario, institutional data corresponding to the target scenario, introduction data corresponding to the target scenario, proprietary name explanation data corresponding to the target scenario, historical event information corresponding to the target scenario, human resources policies corresponding to the target scenario, etc. For example, when the target scenario is an intelligent question-and-answer scenario within a specific enterprise, the source data corresponding to the target scenario may include the historical question-and-answer data of the enterprise's employees, enterprise introduction information, explanations of proprietary nouns involved in the enterprise's field, historical events that have occurred in the enterprise, etc.
[0119] The source data may include data that is already a question-and-answer pair, or may include non-question-and-answer pair data, such as news, articles, rules and regulations, etc. Those skilled in the art can use various data that can extract question-and-answer samples to train the dialogue model as source data according to actual needs. The electronic device can obtain the source data pre-stored manually, or obtain or query the source data from other devices. For example, obtain the source data from a third-party database. The present application does not specifically limit the specific method of obtaining the source data.
[0120] Step S120: According to the sample requirement information corresponding to each pre-set question-and-answer type, determine question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type from the source data through a large model.
[0121] As Figure 3 shown, each of the above question-and-answer types includes a daily question-and-answer type and a target-scenario question-and-answer type. Daily questions and answers can include ideological concepts, sensitive phrases, etc. The target scenario can be a target enterprise. In this case, the target-scenario question-and-answer type includes at least one of the following types: self-awareness question-and-answer, target-enterprise awareness question-and-answer, information security question-and-answer, policy and system question-and-answer, command attack question-and-answer, operation guidance question-and-answer, and explanation question-and-answer.
[0122] The target-enterprise awareness question-and-answer includes at least one of the following: question-and-answer about the personnel structure of the target enterprise, question-and-answer about the department settings of the target enterprise, and question-and-answer about the public opinion events of the target enterprise.
[0123] The information security question-and-answer includes at least one of the following: personal information question-and-answer, enterprise information question-and-answer, and enterprise service data question-and-answer.
[0124] The policy and system security question-and-answer includes at least one of the following: human resources question-and-answer, enterprise governance question-and-answer, legal compliance question-and-answer, financial information question-and-answer, risk governance question-and-answer, enterprise operation question-and-answer, internal supervision question-and-answer, procurement management question-and-answer, technology management question-and-answer, asset management question-and-answer, and external relations question-and-answer.
[0125] Since the scenarios to which the dialogue model is applied are different, the focus directions for training the dialogue model are usually also different. For example, if the dialogue model is applied to the employee query scenario within an enterprise, there can be more question-and-answers related to enterprise rules and regulations, enterprise awareness, and enterprise security. If the dialogue model is applied to daily question-and-answer, there can be more daily question-and-answers. Those skilled in the art can set the sample demand information corresponding to each question-and-answer type according to actual needs.
[0126] The above sample demand information can include the sample demand quantities corresponding to each question-and-answer type, or can also include the sample demand ratios and the total sample demand among each question-and-answer type.
[0127] The sample demand information corresponding to each pre-set question-and-answer type can be set by a human according to the scenario to which the dialogue model is applied and then input into the electronic device, so that the electronic device can obtain the sample demand information corresponding to each question-and-answer type.
[0128] The above large model is a pre-trained model. Specifically, the large model can be a large language model (LLM for short). A large language model is a deep learning model that can understand and generate natural language. It has an extremely large number of parameters and can process and learn language patterns, grammatical structures, semantic information, etc. from a large amount of text data, so as to realize the reply to the input information. Through the large language model, the large model can be applied to various fields such as text generation, machine translation, intelligent dialogue, sentiment analysis, question answering system, intelligent writing, document summarization, etc.
[0129] In the embodiments of the present application, the large model can be a model that has been trained in the related art, or can be obtained by training according to the training methods in the related art. The present application does not specifically limit this.
[0130] Specifically, step S120 can be implemented according to the following steps: preprocess the source data. The preprocessing can include processing such as removing noise, unifying the text format, word segmentation, and annotation of the source data, so as to make the preprocessed source data more convenient for the subsequent efficiency and accuracy of generating question-and-answer samples. Construct a prompt. The prompt is used to instruct the large model to extract question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type from the source data. For example, the prompt can be "Please extract 1000 question-and-answer samples of X question-and-answer type and 3000 question-and-answer samples of Y question-and-answer type from the 'a source database' and 'b source database' in the form of one question and one answer". Input the prompt into the large model. Among them, the large model has the permission to access and query the data in each source database, so that the large model can extract or construct question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type under the prompt of the prompt.
[0131] In one implementation, step S120 can be implemented according to the following steps S121 to step S122.
[0132] Step S121: Extract key point information from the source data.
[0133] Since the source data is usually a large amount of raw data collected, a lot of content is invalid for the extraction of question-and-answer samples. For example, the source data includes many special characters, punctuation marks, and articles irrelevant to the question-and-answer that are irrelevant to the question-and-answer. In order to improve the efficiency of the subsequent large model in constructing question-and-answer samples, key point information can be extracted from the source data.
[0134] Step S121 can extract key point information from the source data by means of regular expression method, or can extract key point information from the source data by means of a pre-trained information extraction model.
[0135] In this embodiment, step S121 can be implemented according to the following steps: Determine the type of information to be extracted, such as entities (person names, place names), relationships (the relationship between A and B), events (time of occurrence, location, participants, etc.), obtain examples of key point information that has been extracted, and extract key point information from the source data according to the type of information to be extracted and the examples of key point information.
[0136] Specifically, a pre-trained key point information extraction model can be used to extract key point information from the source data based on the type of information to be extracted and the examples of key point information. The key point information extraction model is used to extract key point information from a large amount of data. The training of the key point information extraction model can refer to the model training methods in related technologies, which will not be introduced in detail in this application. Alternatively, key point information can also be extracted from the source data by the regular expression method or other methods.
[0137] Among them, the regular expression method is more suitable for extracting key point information when the format of the source data is relatively simple (for example, the source data is structured or semi-structured data), and has the advantages of high efficiency and speed in extracting key point information and saving computing resources. The key point information extraction model can perform relatively accurate information extraction for various different source data, has stronger applicability, and is more accurate in extraction.
[0138] Step S122: According to the sample requirement information corresponding to each question-and-answer type set in advance, determine, through the large model, question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type from the key point information.
[0139] In one embodiment, step S121 can extract key point information from the source data in the following manner: Based on the sample requirement information corresponding to each question-and-answer type set in advance, extract key point information corresponding to the sample requirement information corresponding to each question-and-answer type from the source data. In this embodiment, when extracting key point information, the quantity of the extracted key point information matches the sample requirement information corresponding to each question-and-answer type. In this way, it can better avoid excessive extraction of some information, thereby reducing the workload, improving the efficiency of model training, and reducing the consumption of computing resources.
[0140] The key point information corresponds to the sample requirement information corresponding to each question-and-answer type. For example, the data volume ratio of different types of key point information may correspond to the ratio relationship between each question-and-answer type. If the proportion of policy system type questions and answers is higher than that of daily question and answer type questions, then the key point information extracted from the policy system data source can be more than the key point information extracted from the general question and answer source data.
[0141] It can be understood that source data of the same type can provide data sources for different types of Q&A samples, and Q&A samples of the same type can also be extracted or generated based on different types of source data. Therefore, the number of key point information extracted in the embodiments of the present application only needs to be generally consistent with the sample requirement information corresponding to each Q&A type, and does not need to be exactly the same.
[0142] In one implementation manner, step S122 can be implemented according to the following steps S122a to S122b.
[0143] Step S122a: Determine the Q&A type corresponding to each piece of key point information.
[0144] Since the specific content included in different key point information is different, the corresponding Q&A types are also different. For example, if the key point information is enterprise rules and regulations, the corresponding Q&A type can be policy and system type Q&A. If the key point information is enterprise news events, the corresponding Q&A type can be enterprise cognition type Q&A.
[0145] In the embodiments of the present application, the Q&A type corresponding to the key point information can be determined by the keyword matching method. For example, if the keyword "how to set permissions" is included in the key point information, the key point information is usually about operation guidance type Q&A. The Q&A type corresponding to the key point information can also be determined by the pattern matching method. For example, the sentence structure pattern in the key point information is used to refine the corresponding Q&A classification. For example, questions starting with "why" are usually classified as explanation type Q&A.
[0146] Step S122b: Based on the Q&A type corresponding to each piece of key point information, according to the sample requirement information corresponding to each Q&A type set in advance, use the large model to determine, from the key point information, Q&A samples that meet the sample requirement information corresponding to the Q&A type.
[0147] After marking the Q&A type corresponding to each piece of key point information, the large model can obtain the Q&A type corresponding to each piece of key point information. Therefore, it is more convenient for the large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type, improving the generation efficiency of Q&A samples.
[0148] In a specific embodiment, step S122b can be implemented according to the following steps: Obtain the example Q&A samples set in advance; Based on the example Q&A samples and the Q&A type corresponding to each piece of key point information, and according to the sample requirement information corresponding to each Q&A type set in advance, use the large model to determine, from the key point information, Q&A samples that meet the sample requirement information corresponding to the Q&A type and are consistent with the example Q&A samples.
[0149] The example Q&A samples are used to indicate the styles of the Q&A samples constructed by the large model, so that the Q&A samples constructed by the large model meet the formats or forms of the example samples.
[0150] In a specific embodiment, step S122b can be implemented as follows: Obtain the sample constraint conditions corresponding to each Q&A type, where the sample constraint conditions are used to indicate the sample styles of the samples of the Q&A type; Based on the Q&A types corresponding to each key point information and the sample constraint conditions corresponding to each Q&A type, according to the sample requirement information corresponding to each Q&A type set in advance, use the large model to determine from the key point information the Q&A samples of each Q&A type that meet the sample requirement information corresponding to the Q&A type and meet the corresponding sample constraint conditions.
[0151] The sample constraint conditions refer to the specific requirements or standards for the Q&A samples set for each Q&A type. These sample constraint conditions are used to guide the screening of the Q&A samples that meet the requirements from the key point information. Each Q&A type may have different focuses and requirements, so the corresponding sample constraint conditions will also be different. These constraint conditions help ensure that the selected Q&A samples can accurately reflect the characteristics of the Q&A type and meet the needs of training, evaluation, or other applications.
[0152] For example, for factual Q&A samples, the sample constraint conditions may include: containing clear factual statements, and the answers should be objective and verifiable information; for explanatory Q&A samples, the sample constraint conditions may include: needing to explain the reasons or principles behind the phenomenon, and the answers should involve causal relationships or theoretical elaborations; for guiding Q&A samples, the sample constraint conditions may include providing operation steps or guidelines, and the answers should specifically describe how to complete a certain task or solve a certain problem. Those skilled in the art can set the sample constraint conditions corresponding to different types of Q&A samples according to the actual situation, so that the large model can generate Q&A samples that meet the sample constraint conditions, thereby making the Q&A samples obtained by the large model more in line with the needs of different types and training the model more efficiently and accurately.
[0153] In one implementation manner, step S120 can be implemented as follows: Extract Q&A samples from the source data through the large model; Use the large model to perform quantitative expansion on the extracted Q&A samples to obtain Q&A samples that meet the sample requirement information corresponding to the Q&A type. In this implementation manner, first extract Q&A samples from the source data through the large model. Since the extracted Q&A samples may not meet the sample requirement information corresponding to the Q&A type, therefore, the large model can be used to perform quantitative expansion on the Q&A samples, so that the large model expands more Q&A samples based on the existing Q&A samples, thereby obtaining Q&A samples that meet the sample requirement information corresponding to the Q&A type.
[0154] Step S130: Obtain the sample label corresponding to the Q&A sample, where the sample label is used to indicate the compliance of the answer content in the Q&A sample.
[0155] The sample label corresponding to the Q&A sample can be a label indicating whether the answer content is compliant, specifically, it can be a label indicating whether the answer content contains sensitive content, a label indicating whether the answer content contains confidential information, etc. Those skilled in the art can label the Q&A sample according to the compliance requirements that the dialogue model needs to meet in the actual application process.
[0156] In this application, the sample label can be marked manually or by using an automated tool.
[0157] Step S140: Train the model to be trained based on the Q&A sample marked with the sample label to obtain a trained dialogue model, where the dialogue model is used to generate answer content that meets the compliance requirements.
[0158] Step S140 can specifically be trained using training methods such as supervised training method, semi-supervised training method, adversarial learning training, cyclic learning training, etc. in related technologies.
[0159] The model to be trained mentioned above can be a large-scale pre-trained language model suitable for dialogue tasks. Based on the large-scale pre-trained language model, the dialogue model required by this application can be trained relatively quickly and efficiently.
[0160] Specifically, the model to be trained can be trained according to the following process: Adjust the hyperparameters of the model according to the specific requirements of the task, such as learning rate, batch size, number of training epochs, etc., select an appropriate loss function (such as cross-entropy loss) and optimization algorithm to guide the learning process of the model; convert the Q&A sample into an input format that the model can accept, and use the training set to train the model. After each round of training, use the validation set to evaluate the model performance and adjust the parameters to avoid overfitting. Continuously monitor key performance indicators, such as accuracy, recall rate, etc. during the training process to timely understand the learning progress of the model; evaluate the performance of the model on an independent test set to ensure that it can maintain good performance on unseen data. This application briefly introduces the training of the model to be trained. The specific training process of the model can adopt the model training method in related technologies, and the specific training process of the model is not the focus of the content of this application.
[0161] In one implementation manner, before step S140, the following step S140a can also be included.
[0162] Step S140a: Perform text rewriting processing on the Q&A sample to adjust the text expression mode of the Q&A sample and obtain a rewritten Q&A sample.
[0163] Specifically, the text of the Q&A sample can be rewritten based on a preset text template through template replacement. For example, for questions with certain specific patterns, fixed templates can be designed for replacement. For example, "What is X?" can be rewritten as "Please explain the concept of X." Alternatively, the Q&A sample can also be rewritten by replacing words with synonyms. For example, a thesaurus can be used to replace some of the words in the original sentence to make the expression more diverse. Optionally, a pre-trained language model such as a deep learning model can also be used to perform text rewriting on the Q&A sample to convert the input sentence into a smoother or different expression.
[0164] Step S140 can be specifically implemented according to the following steps S141.
[0165] Step S141: Train the model to be trained based on the rewritten Q&A sample marked with the sample label.
[0166] In this embodiment, by performing text rewriting on the Q&A sample, it can be specifically used to adjust the Q&A sample into a more smooth, more flexible expression, etc., which is more in line with the text expression requirements desired by the user.
[0167] In this embodiment, the preset rewriting rules can be specifically obtained, and the Q&A sample is processed for text rewriting based on the rewriting rules. The preset rewriting rules are used to indicate the conditions that the rewritten text needs to meet, and can be specifically used to indicate that the text is rewritten to be more in line with the text for model training.
[0168] After the Q&A sample generated by the large model is rewritten, the rewritten Q&A sample can be made more in line with model training, improving the accuracy and efficiency of model training.
[0169] In one embodiment, as Figure 5 shown, the above method may further include the following steps S150 to S170.
[0170] Step S150: Determine the actual answer content corresponding to the question input by the user through the dialogue model.
[0171] Step S150 is to answer the question input by the user through the dialogue model. This step can be understood as the actual answer content generated during the actual application of the dialogue model.
[0172] In a specific embodiment, as Figure 5 shown, step S150 can be implemented according to the following steps S151 to step S153.
[0173] Step S151: Obtain the question log.
[0174] Step S152: Filter out non-user input problem logs from the problem log to obtain user input problem logs.
[0175] Step S153: Determine the actual response content corresponding to the user input problem log through the dialogue model.
[0176] Since the dialogue system usually has an automated response mechanism, such as welcome messages, confirmation messages, or prompts automatically generated based on the context, these are all system-generated content and not directly input by the user. Additionally, for ease of maintenance and troubleshooting, the system may record various error messages, abnormal situations, and debugging-related logs, and such information also does not belong to the part of user interaction. Data simulating user interaction generated during the development and testing phases may also be mixed into the production environment logs. In this embodiment, by screening the logs and only retaining the inputs truly from the user, it can effectively focus on the real feedback of the user experience, thereby providing more accurate data support for the training and optimization of the dialogue model. This method not only improves the effectiveness of data analysis but also promotes the continuous improvement and development of the dialogue system.
[0177] Step S160: Search for non-compliant response content that does not meet the compliance requirements from the actual response content, and mark the non-compliant response content and the corresponding questions as non-compliant Q&A samples.
[0178] In this step, a sensitive information library containing sensitive words or phrases can be established in advance, and regular expressions or other methods can be used to retrieve whether there are words in the sensitive information library from the actual response content. If so, it can be determined as a non-compliant Q&A sample. Alternatively, a pre-trained classifier model can be used to automatically identify non-compliant responses.
[0179] Step S170: Perform model optimization training on the dialogue model through the non-compliant Q&A samples to obtain an optimized dialogue model.
[0180] In this implementation, the dialogue model is continuously optimized during the actual deployment and use process. By marking non-compliant Q&A samples, the dialogue model is continuously optimized, so that the dialogue model can better avoid generating similar non-compliant response content in the future.
[0181] The following uses a specific example to exemplarily illustrate the process of obtaining Q&A samples in the embodiments of the present application. For example Figure 4 As shown, the process of obtaining Q&A samples in this example may include the following steps 1 to 8.
[0182] Step 1: Obtain the source data for extracting Q&A samples.
[0183] For example Figure 4As shown, the source data may include structured source data such as institutional data and human resources policy data, fragmented source data such as examination data, historical Q&A data, and glossary data, and evaluation set source data such as industry evaluation sets and attack instructions. For the relevant content of the source data, refer to the description in the above embodiments, and it will not be repeated here.
[0184] Step 2: Extract key information from the source data.
[0185] Step 3: Determine the Q&A type corresponding to the key information.
[0186] Step 4: Obtain sample Q&A samples.
[0187] Step 5: Obtain sample constraint conditions.
[0188] Step 6: Based on the above key information, the Q&A type corresponding to the key information, the sample Q&A samples, and the above sample constraint conditions, generate Q&A samples through a large model.
[0189] Step 7: Rewrite the Q&A samples to obtain rewritten Q&A samples.
[0190] Step 8: Mark compliance labels for the Q&A samples to obtain Q&A samples with questions and corresponding answer contents.
[0191] The processes of the above Step 1 to Step 8 can refer to the above embodiments and will not be elaborated here.
[0192] The training method of the dialogue model provided by the embodiment of the present application obtains source data for extracting Q&A samples. This source data provides the source of samples required for training the dialogue model. According to the sample requirement information corresponding to each pre-set Q&A type, a large model is used to determine Q&A samples in the source data that meet the sample requirement information corresponding to the Q&A type. In this way, staff can first set the sample requirement information corresponding to different Q&A types according to the scenario to which the dialogue model is applied, and the sample requirement information corresponding to each set Q&A type can meet the scenario to which the dialogue model is applied. The present application also extracts samples from the source data according to the sample requirement information corresponding to each Q&A type based on the large model. Since the large model has an intelligent data processing function, it is very convenient and flexible to extract Q&A samples that meet the sample requirement information through the large model. Then, obtain the sample labels corresponding to the Q&A samples. The sample labels are used to indicate the compliance of the answer content in the Q&A samples. Train the model to be trained based on the Q&A samples marked with the sample labels, and the trained dialogue model obtained can generate answer content that meets the compliance requirements.
[0193] It can be seen that when obtaining question-and-answer samples in the training method of the dialogue model provided by this application, according to the sample requirement information corresponding to each question-and-answer type preset to meet the scenario applied by the dialogue model and based on the large model, question-and-answer samples are extracted from the source data. This can not only make the distribution of each extracted question-and-answer sample meet the requirements of the scenario applied by the dialogue model, so that the trained dialogue model can answer efficiently and accurately for the applied scenario, making the answer accuracy of the dialogue model higher, but also can quickly and accurately extract question-and-answer samples that meet the sample requirement information by using the large model, improving the model training efficiency, and can also improve the richness of the extracted samples. This application selects question-and-answer samples that meet the sample requirement information corresponding to each question-and-answer type, and can also avoid a lot of ineffective training, reduce the waste of computing resources, and further improve the model training efficiency.
[0194] In addition, this application also marks the compliance label for the question-and-answer samples. In this way, the trained model can also answer the content that meets the compliance requirements.
[0195] Embodiment 2
[0196] The second embodiment of this application also provides an intelligent dialogue method, which is applied to an electronic device. The electronic device can be a server, a desktop computer, a laptop computer, a mobile terminal, a gateway, or other electronic devices with data processing capabilities.
[0197] As Figure 6 shown, the intelligent dialogue method provided in this embodiment includes the following steps S210 to step S220.
[0198] Step S210: Obtain the query question input by the user.
[0199] The above user can be an employee within an enterprise, a customer, or a person who queries daily information. The application scenarios of the intelligent dialogue method are different, that is, the application scenarios of the dialogue model are different, and the targeted users are also different.
[0200] Step S220: Input the query question input by the user into the pre-trained dialogue model to obtain the answer content corresponding to the query question.
[0201] It can be understood that the intelligent dialogue method in the embodiment of this application can have an intelligent dialogue with the user through text or through voice. The dialogue model is used to obtain the answer content in text form.
[0202] The dialogue model is trained by the training method of the dialogue model described in any one of the first embodiments.
[0203] Specifically, step S220 can be implemented according to the following steps S221 to step S222.
[0204] Step S221: Obtain a reference database, where the reference data in the reference database is used for the dialogue model to refer to during the process of answering questions.
[0205] The reference database is a pre-set database, and various reference data can be included in the reference database. For example, when the intelligent dialogue method is applied to employees within an enterprise to query information, the reference data can include the enterprise's historical Q&A data, the enterprise's corresponding examination data, the enterprise's system data, the enterprise's introduction data, the interpretation data of the proprietary names involved in the enterprise, and so on.
[0206] Step S222: Input the query question entered by the user into a pre-trained dialogue model, so that the dialogue model obtains the answer content corresponding to the query question based on the reference database.
[0207] In this embodiment, by setting up a reference database, the dialogue model can search for information in the reference data, so as to be able to generate more accurate and rich answer content.
[0208] In one implementation manner, the above method may further include the following steps S230 to S240.
[0209] Step S230: Search for non-compliant answer content that does not meet the compliance requirements from the answer content.
[0210] The method for step S230 to search for non-compliant answer content may refer to step S160 in the first embodiment, and will not be repeated here.
[0211] Step S240: Update the content in the reference database according to the non-compliant answer content.
[0212] Specifically, the data to be updated in the reference database can be determined according to the non-compliant answer content. For some simple non-compliant questions, they can be directly modified in the database. For example, replace sensitive words or adjust the expression to make it more accurate. If some answer content completely does not meet the requirements and cannot be repaired, it can be removed from the database. Or, a to-be-updated mark information can be added to the data to be updated, so that the data can be updated uniformly when the database update time arrives. An automated AI audit system can be used to monitor and automatically correct the content newly added to the database in real time to ensure that it always meets the compliance requirements.
[0213] In this implementation manner, updating the reference database according to the non-compliant answer content can timely update the non-compliant or incorrect information in the reference database, so that more accurate intelligent dialogue can be performed subsequently.
[0214] In one implementation, before step S220, the following steps S220a to S220b may also be included.
[0215] Step S220a: Identify whether there is any non-compliant content in the query problem input by the user.
[0216] Specifically, the query problem can be identified for non-compliant content through a sensitive word matching method, or a pre-trained non-compliant content inspection model can be used to detect whether there is non-compliant content in the query problem.
[0217] Non-compliant content may include sensitive information such as personal privacy and financial information, inappropriate language such as offensive language and discriminatory remarks, false or misleading statements, content violating laws and regulations, and so on.
[0218] Step S220b: If there is, rewrite the query problem input by the user so that the rewritten query problem has no non-compliant content.
[0219] Specifically, the non-compliant words in the query problem can be replaced through synonym replacement, or the query problem can be modified into text without non-compliant content through a pre-trained text rewriting model.
[0220] Step S220 can be implemented according to the following step S223.
[0221] Step S223: Input the rewritten query problem into a pre-trained dialogue model to obtain the answer content corresponding to the rewritten query problem.
[0222] In this implementation, the non-compliant content in the query problem is rewritten, enabling the dialogue model to generate answer content based on a compliant query problem, improving the compliance of the entire Q&A process.
[0223] In one implementation, the dialogue model can be pre-connected to the risk control module of the large model, and the risk control module is used to control daily non-compliant content.
[0224] The Risk Control Module is a crucial component of the large model, aiming to identify, prevent, and mitigate various risk factors to ensure the security and compliance of the system.
[0225] Step S220 can be implemented as follows: Input the query problem input by the user into a pre-trained dialogue model, so that the dialogue model controls the non-compliant content of the query problem through the risk control module, obtains a compliant query problem, and generates compliant answer content corresponding to the compliant query problem.
[0226] The risk control module accessing the large model in this embodiment can better control the non-compliant content in the questions asked by users and the answer content generated by the dialogue model, thereby improving the security of the generated answer content.
[0227] In one implementation, the intelligent dialogue method may further include the following steps S250 to step S260.
[0228] Step S250: Detect the privacy information in the answer content.
[0229] The privacy information may include various information involving personal privacy such as phone numbers, email addresses, employee numbers, ID numbers, etc., and may also include enterprise privacy information, such as enterprise financial information, employee salary information, and so on.
[0230] Step S260: Encrypt the privacy information to obtain the encrypted answer content, and the encrypted answer content is used for display.
[0231] For example, the privacy information can be hidden. As Figure 8 shown, the privacy information can be replaced with special characters. As Figure 7 shown, or the privacy information can be encrypted and encoded to obtain the encoded information, etc. Other encryption processing methods can also be used to encrypt the privacy information, and the present application does not specifically limit it.
[0232] The relevant content in the intelligent dialogue method provided in this embodiment is similar to the relevant content in the training method of the dialogue model provided in the first embodiment. For the specific description, execution process, and beneficial effects, please refer to the first embodiment, and this embodiment will not be elaborated further.
[0233] Embodiment III
[0234] The third embodiment of the present application also provides a training device for the dialogue model corresponding to the training method embodiment of the dialogue model provided in the first embodiment. Since the device embodiment is basically similar to the method embodiment, the description is relatively simple. For the details of the relevant technical features and the achieved effects, please refer to the corresponding description of the training method embodiment of the dialogue model provided above. The training device for the dialogue model provided in this embodiment includes:
[0235] A source data acquisition unit for acquiring source data for extracting question-and-answer samples;
[0236] A sample determination unit for determining question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type from the source data through the large model according to the sample requirement information corresponding to each pre-set question-and-answer type;
[0237] A tagging unit for obtaining a sample tag corresponding to the Q&A sample, where the sample tag is used to indicate the compliance of the answer content in the Q&A sample;
[0238] A training unit for training a model to be trained based on the Q&A sample marked with the sample tag to obtain a trained dialogue model, where the dialogue model is used to generate answer content that meets the compliance requirements.
[0239] Optionally, the sample determination unit is specifically configured to:
[0240] Extract key information from the source data;
[0241] According to the sample requirement information corresponding to each Q&A type set in advance, use a large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the key information.
[0242] Optionally, the sample determination unit is specifically configured to:
[0243] Extract key information from the source data by using the regular expression method;
[0244] Extract key information from the source data by using a pre-trained large model.
[0245] Optionally, the sample determination unit is specifically configured to:
[0246] Based on the sample requirement information corresponding to each Q&A type set in advance, extract key information corresponding to the sample requirement information corresponding to each Q&A type from the source data.
[0247] Optionally, the sample determination unit is specifically configured to:
[0248] Determine the Q&A type corresponding to each key information;
[0249] Based on the Q&A type corresponding to each key information, according to the sample requirement information corresponding to each Q&A type set in advance, use a large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the key information.
[0250] Optionally, the sample determination unit is specifically configured to:
[0251] Obtain the pre-set example Q&A samples;
[0252] Based on the example Q&A samples and the Q&A type corresponding to each key information, and according to the sample requirement information corresponding to each Q&A type set in advance, use a large model to determine Q&A samples that meet the sample requirement information corresponding to the Q&A type and are consistent with the example Q&A samples from the key information.
[0253] Optionally, the sample determination unit is specifically configured to:
[0254] Obtain the sample constraint conditions corresponding to each question-and-answer type, where the sample constraint conditions are used to indicate the sample styles of the samples of the question-and-answer type;
[0255] Based on the question-and-answer types corresponding to the key point information and the sample constraint conditions corresponding to each question-and-answer type, according to the sample requirement information corresponding to each question-and-answer type set in advance, use a large model to determine from the key point information the question-and-answer samples of each question-and-answer type that meet the sample requirement information corresponding to the question-and-answer type and meet the corresponding sample constraint conditions.
[0256] Optionally, the device further includes:
[0257] A rewriting unit, configured to perform text rewriting processing on the question-and-answer samples to rewrite the question-and-answer samples into smooth texts, obtaining rewritten question-and-answer samples;
[0258] The training unit is specifically configured to: train the model to be trained based on the rewritten question-and-answer samples marked with the sample labels.
[0259] Optionally, the sample determination unit is specifically configured to:
[0260] Extract question-and-answer samples from the source data through a large model;
[0261] Perform quantity expansion rewriting on the extracted question-and-answer samples through a large model to obtain question-and-answer samples that meet the sample requirement information corresponding to the question-and-answer type.
[0262] Optionally, the device further includes:
[0263] An optimization unit, configured to: determine the actual answer content corresponding to the question input by the user through the dialogue model; find the non-compliant answer content that does not meet the compliance requirements from the actual answer content, and mark the non-compliant answer content and the corresponding question as non-compliant question-and-answer samples; perform model optimization training on the dialogue model through the non-compliant question-and-answer samples to obtain an optimized dialogue model.
[0264] Optionally, the optimization unit is specifically configured to: obtain a question log; filter out non-user input question logs from the question log to obtain user input question logs; determine the actual answer content corresponding to the user input question logs through the dialogue model.
[0265] Optionally, the sample requirement information corresponding to each question-and-answer type includes at least one of the following:
[0266] The sample quantity corresponding to each question-and-answer type;
[0267] The sample demand ratio between each Q&A type.
[0268] Optionally, the source data includes general Q&A source data and / or source data corresponding to the target scenario, where the target scenario is the scenario to which the dialogue model is applied.
[0269] Optionally, the source data corresponding to the target scenario includes at least one of the following: historical Q&A data corresponding to the target scenario, examination data corresponding to the target scenario, institutional data corresponding to the target scenario, introduction data corresponding to the target scenario, and proprietary name explanation data involved in the target scenario.
[0270] Optionally, each Q&A type includes a daily Q&A type and a Q&A type for the target scenario.
[0271] Optionally, the target scenario is a target enterprise, and the Q&A types for the target scenario include at least one of the following types: self-awareness Q&A, target enterprise awareness Q&A, information security Q&A, policy and system security Q&A, and command attack Q&A.
[0272] Embodiment 4
[0273] The fourth embodiment of the present application also provides an intelligent dialogue device corresponding to the intelligent dialogue method embodiment provided in the second embodiment. Since the device embodiment is basically similar to the method embodiment, the description is relatively simple. For the details of the relevant technical features and the achieved effects, please refer to the corresponding description of the model training method embodiment provided above. The intelligent dialogue device provided in this embodiment includes:
[0274] A question acquisition unit, configured to acquire a query question input by a user;
[0275] An answer generation unit, configured to input the query question input by the user into a pre-trained dialogue model to obtain an answer content corresponding to the query question, where the dialogue model is trained by the training method of the dialogue model according to any one of the first embodiments.
[0276] The fifth embodiment of the present application also provides an electronic device embodiment corresponding to the training method of the dialogue model provided in the first embodiment. The following description of the electronic device embodiment is only illustrative. The electronic device embodiment is as follows:
[0277] Please refer to Figure 9 to understand the above electronic device, Figure 9 which is a schematic diagram of the electronic device. The electronic device provided in this embodiment includes: a processor 1001, a memory 1002, a communication bus 1003, and a communication interface 1004;
[0278] The memory 1002 is used to store computer instructions for data processing. When the computer instructions are read and executed by the processor 1001, the following steps are performed:
[0279] Obtain source data for extracting Q&A samples;
[0280] According to the sample requirement information corresponding to each Q&A type set in advance, determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the source data through a large model;
[0281] Obtain the sample label corresponding to the Q&A sample, where the sample label is used to indicate the compliance of the answer content in the Q&A sample;
[0282] Train the model to be trained based on the Q&A samples marked with the sample labels to obtain a trained dialogue model, where the dialogue model is used to generate answer content that meets the compliance requirements.
[0283] The sixth embodiment of the present application also provides an electronic device embodiment corresponding to the intelligent dialogue method provided in the second embodiment. The following description of the electronic device embodiment is only illustrative. The electronic device embodiment is as follows:
[0284] The electronic device provided in this embodiment includes: a processor, a memory, a communication bus, and a communication interface;
[0285] The memory is used to store computer instructions for data processing. When the computer instructions are read and executed by the processor, the following steps are performed:
[0286] Obtain a query question input by the user;
[0287] Input the query question input by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query question, where the dialogue model is trained by the training method of the dialogue model in any one of the first embodiments.
[0288] The seventh embodiment of the present application also provides a computer-readable storage medium for implementing the method described in the first embodiment. The description of the computer-readable storage medium embodiment provided in the present application is relatively simple. For the relevant parts, please refer to the corresponding descriptions in the above method embodiments. The following described embodiments are only illustrative.
[0289] The computer-readable storage medium provided in this embodiment stores computer instructions. When the instructions are executed by the processor, the following steps are implemented:
[0290] Obtain source data for extracting Q&A samples;
[0291] According to the sample requirement information corresponding to each pre-set Q&A type, determine Q&A samples that meet the sample requirement information corresponding to the Q&A type from the source data through a large model;
[0292] Obtain the sample label corresponding to the Q&A sample, where the sample label is used to indicate the compliance of the answer content in the Q&A sample;
[0293] Train the model to be trained based on the Q&A samples marked with the sample labels to obtain a trained dialogue model, where the dialogue model is used to generate answer content that meets the compliance requirements.
[0294] The eighth embodiment of the present application also provides a computer-readable storage medium for implementing the method described in the second embodiment. The description of the computer-readable storage medium embodiment provided in the present application is relatively simple. For the relevant parts, please refer to the corresponding descriptions in the above method embodiments. The following described embodiments are only illustrative.
[0295] The computer-readable storage medium provided in this embodiment stores computer instructions, and when the instructions are executed by a processor, the following steps are implemented:
[0296] Obtain the query question input by the user;
[0297] Input the query question input by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query question, where the dialogue model is trained by the training method of the dialogue model described in any one of the first embodiments.
[0298] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0299] Memory may include non-permanent memory in computer-readable media, random access memory (RAM), and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0300] 1. A computer-readable medium includes both permanent and non-permanent, removable and non-removable media that can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer-readable medium does not include transitory media such as modulated data signals and carrier waves.
[0301] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0302] Although the present application is disclosed above with preferred embodiments, it is not intended to limit the present application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be determined by the scope defined in the claims of the present application.
Claims
1. A method for training a dialogue model, characterized in that: The method comprises: Obtain source data for extracting question and answer samples; According to the preset sample requirement information corresponding to each question and answer type, determine the question and answer samples that meet the sample requirement information corresponding to the question and answer type from the source data through the big model; Obtaining a sample label corresponding to the question and answer sample, wherein the sample label is used to indicate compliance of the answer content in the question and answer sample; The model to be trained is trained based on the question and answer samples marked with the sample labels to obtain a trained dialogue model, and the dialogue model is used to generate answer content that meets compliance requirements.
2. The method for training a dialogue model according to claim 1, characterized in that: The step of determining, from the source data using the big model, question and answer samples that meet the sample demand information corresponding to each question and answer type according to the preset sample demand information respectively includes: Extracting key information from the source data; According to the preset sample requirement information corresponding to each question and answer type, the question and answer samples that meet the sample requirement information corresponding to the question and answer type are determined from the key point information through the big model.
3. The method for training a dialogue model according to claim 2, characterized in that: The extracting key information from the source data includes at least one of the following: Extracting key information from the source data by using a regular expression method; Key information is extracted from the source data through a pre-trained large model.
4. The method for training a dialogue model according to claim 2, characterized in that: The extracting key information from the source data includes: Based on the preset sample requirement information corresponding to each question and answer type, key information corresponding to the sample requirement information corresponding to each question and answer type is extracted from the source data.
5. The method for training a dialogue model according to claim 2, characterized in that: The step of determining, according to the preset sample requirement information corresponding to each question and answer type, the question and answer samples satisfying the sample requirement information corresponding to the question and answer type from the key point information through the large model includes: Determine the question and answer type corresponding to each of the key information; Based on the question and answer types corresponding to each of the key point information, and in accordance with the pre-set sample requirement information corresponding to each of the question and answer types, question and answer samples that meet the sample requirement information corresponding to the question and answer type are determined from the key point information through a large model.
6. An intelligent dialogue method, characterized in that: The method comprises: Get the query question entered by the user; The query question input by the user is input into a pre-trained dialogue model to obtain an answer content corresponding to the query question, and the dialogue model is trained by the dialogue model training method described in any one of claims 1 to 5.
7. A training device for a dialogue model, characterized in that: The device comprises: A source data acquisition unit, used to acquire source data for extracting question and answer 1 samples; A sample determination unit, configured to determine, from the source data, a question and answer sample that satisfies the sample requirement information corresponding to each question and answer type according to the preset sample requirement information corresponding to each question and answer type through a large model; A labeling unit, used to obtain a sample label corresponding to the question and answer sample, wherein the sample label is used to indicate the compliance of the answer content in the question and answer sample; A training unit is used to train a to-be-trained model based on the question and answer samples marked with the sample labels to obtain a trained dialogue model, wherein the dialogue model is used to generate answer content that meets compliance requirements.
8. An intelligent dialogue device, characterized in that: The device comprises: A question acquisition unit, used to acquire a query question input by a user; An answer generation unit is used to input the query question input by the user into a pre-trained dialogue model to obtain the answer content corresponding to the query question, and the dialogue model is trained by the dialogue model training method described in any one of claims 1 to 5.
9. An electronic device, characterized in that: include: A processor, a memory, and computer program instructions stored on the memory and executable on the processor; When the processor executes the computer program instructions, the method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 6.
Citation Information
Cited By
Search model training method, search task processing method and webpage search task processing method
CN121456105A