Dynamic sampling dialogue generation model training method and device, equipment and medium
By using dynamic sampling, the answer word sequence and word position information of the reference answer statement are obtained. The answer words are generated using a pre-trained dialogue generation model and adjusted according to the replacement probability. This solves the problem of low recall and precision in existing financial dialogue generation models and achieves more accurate financial dialogue generation.
Patent Information
- Application Number
- CN202310725410.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2043-06-16
AI Technical Summary
Existing retrieval-based and generative dialogue generation methods suffer from low recall and low answer precision in the financial field. In particular, when there are no similar queries in the financial database, the recall is low, the generated answers are far from the query, and the answer precision is low.
By using dynamic sampling, the answer word sequence and word position information of the reference answer statement are obtained. The answer words are generated using a pre-trained dialogue generation model and adjusted according to the replacement probability. Finally, the standard answer statement is generated. The model is optimized by fine-tuning the training data.
It improves the accuracy of the financial dialogue generation model, increases the recall and precision of responses, and ensures that the generated responses are closer to the user's query.
Smart Images

Figure CN116719920B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a dynamic sampling dialogue generation model training method and device, equipment and medium. BACKGROUND
[0002] Dialogue generation is an important field of natural language processing, and has a very wide application prospect in financial document translation, financial consulting and other fields. At present, the industry generally uses a retrieval method or a generation method for dialogue generation. The retrieval method is to vectorize the user's financial inquiry sentence, then calculate the similarity with the vectorized answer sentence in the financial database, and then find the most similar answer sentence to the financial inquiry sentence in the financial database. The generation method is to obtain the encoding features of the financial inquiry sentence through the encoder, and then input the encoding features into the decoder to generate the answer to the financial inquiry sentence. However, both the retrieval method and the generation method have their shortcomings. The retrieval method has a low recall rate when there is no similar data in the financial database. The generation method generally causes the generated answer to be far away from the financial inquiry sentence, and the accuracy of the answer is low. SUMMARY
[0003] The present application provides a dynamic sampling dialogue generation model training method, device, equipment and medium, which mainly aims to improve the accuracy of the financial dialogue generation model.
[0004] To achieve the above purpose, the present application provides a dynamic sampling dialogue generation model training method, which comprises:
[0005] Step A, obtaining a reference answer sentence, performing word segmentation on the reference answer sentence to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
[0006] Step B, inputting the inquiry sentence corresponding to the reference answer sentence into the pre-trained dialogue generation model to obtain the i-th position answer word, wherein i=1, 2, 3…n, and the initial value is 1;
[0007] Step C, obtaining the reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, and calculating the replacement probability of the reference answer word, and obtaining the i+1-th position input word according to the replacement probability;
[0008] Step D, inputting the i+1-th position input word into the dialogue generation model to generate the i+1-th position answer word, and returning to step C until there is no corresponding reference answer word in the answer word sequence, to obtain a plurality of position answer words;
[0009] Step E, collecting the answer words of each position to obtain a standard answer sentence of the query sentence, generating fine-tuning training data according to the query sentence and the standard answer sentence, and training the dialogue generation model through the fine-tuning training data.
[0010] Optionally, the inputting the query sentence corresponding to the reference answer sentence into the pre-trained dialogue generation model to obtain the i-th position answer word comprises:
[0011] performing word segmentation on the query sentence based on a word segmenter in the dialogue generation model to obtain a query word sequence;
[0012] converting each word in the query word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence;
[0013] passing the word vector sequence through a decoding layer of a Transformer in the dialogue generation model to generate the i-th position answer word of the query sentence.
[0014] Optionally, the performing word segmentation on the reference answer sentence to obtain an answer word sequence comprises:
[0015] constructing a prefix dictionary according to a preset statistical dictionary, and segmenting the reference answer sentence by using a regular expression to obtain a segmented answer sentence;
[0016] constructing a directed acyclic graph of the segmented answer sentence according to the prefix dictionary;
[0017] obtaining a maximum probability path of the directed acyclic graph by using a dynamic programming method, and performing word segmentation according to the maximum probability path to obtain the answer word sequence.
[0018] Optionally, the obtaining the i+1-th position input word according to the replacement probability comprises:
[0019] obtaining a preset replacement probability threshold;
[0020] determining whether the replacement probability is greater than or equal to the replacement probability threshold;
[0021] if the replacement probability is greater than or equal to the replacement probability threshold, taking the reference answer word as the i+1-th position input word;
[0022] if the replacement probability is less than the replacement probability threshold, taking the i-th position answer word as the i+1-th position input word.
[0023] Optionally, after the dialogue generation model is trained through the fine-tuning training data, the method further comprises:
[0024] acquire multi-dimensional objective indexes, and test and analyze a standard dialogue generation model obtained by training the dialogue generation model through the fine-tuning training data through the multi-dimensional objective indexes, to determine whether the standard dialogue model reaches a preset fine-tuning target;
[0025] If the standard dialogue generation model does not reach the preset fine-tuning target, the step C is returned to;
[0026] If the standard dialogue generation model reaches the preset fine-tuning target, the fine-tuning training of the standard dialogue generation model is completed.
[0027] Optionally, the calculation of the replacement probability of the reference answer word comprises:
[0028] The replacement probability N of the reference answer word is calculated through the following probability calculation formula:
[0029]
[0030]
[0031] wherein, the y and are a current position answer word and a reference answer word corresponding to the current position answer word respectively, T is a total number of positions, is a preset parameter value, μ is a distribution, and ~ indicates equivalent to.
[0032] To solve the above problems, the application further provides a dialogue generation model training device for dynamic sampling, which comprises:
[0033] a word information acquisition module, configured to acquire a reference answer sentence, perform word segmentation on the reference answer sentence to obtain an answer word sequence, and obtain a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
[0034] an input word acquisition module, configured to input an inquiry sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2, 3…n, the initial value is 1, acquire a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculate a replacement probability of the reference answer word, and obtain an i+1-th position input word according to the replacement probability;
[0035] an answer word acquisition module, configured to input the i+1-th position input word into the dialogue generation model to generate an i+1-th position answer word, and return to the previous step until there is no corresponding reference answer word in the answer word sequence, to obtain a plurality of position answer words;
[0036] The model training module is configured to collect the answer words of each position to obtain a standard answer sentence of the inquiry sentence, generate fine-tuning training data according to the inquiry sentence and the standard answer sentence, and train the dialogue generation model through the fine-tuning training data.
[0037] Optionally, the inputting the inquiry sentence corresponding to the reference answer sentence into the pre-trained dialogue generation model to obtain the i-th position answer word comprises:
[0038] performing word segmentation on the inquiry sentence based on a word segmenter in the dialogue generation model to obtain an inquiry word sequence;
[0039] converting each word in the inquiry word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence;
[0040] passing the word vector sequence through a decoding layer of a Transformer in the dialogue generation model to generate the i-th position answer word of the inquiry sentence.
[0041] To solve the above problems, the present application further provides an electronic device, which comprises:
[0042] at least one processor; and
[0043] a memory in communication connection with the at least one processor; wherein
[0044] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the dialogue generation model training method with dynamic sampling as described above.
[0045] To solve the above problems, the present application further provides a computer readable storage medium, which comprises a storage data area and a storage program area, the storage data area stores created data, and the storage program area stores a computer program; wherein the computer program is executed by a processor to implement the dialogue generation model training method with dynamic sampling as described above.
[0046] In the embodiment of the present application, first, the reference answer statement is acquired, the reference answer statement is segmented, the answer word sequence is obtained, and the reference answer word and the word position information are obtained according to the answer word sequence, so as to achieve the purpose of acquiring the word information; then the inquiry statement corresponding to the reference answer statement is input into the dialogue generation model to obtain the i-th position answer word, and the reference answer word corresponding to the i-th position answer word in the answer word sequence is obtained based on the word position information, and the i+1-th position input word is obtained by calculating the replacement probability, then the i+1-th position input word is input into the dialogue generation model to generate the i+1-th position answer word, so as to achieve the purpose of acquiring the answer words at multiple positions; finally, the answer words at various positions are collected to obtain the standard answer statement, and the fine-tuning training data is generated according to the inquiry statement and the standard answer statement to train the dialogue generation model. The present application compares the reference answer word with the answer word generated by the pre-trained financial dialogue generation model, replaces the answer word according to the replacement probability of the reference answer word, so as to obtain the fine-tuning training data for training the financial dialogue generation model, and to achieve the purpose of improving the accuracy of the financial dialogue generation model. BRIEF DESCRIPTION OF DRAWINGS
[0047] Figure 1 A flowchart of a dynamic sampling dialogue generation model training method provided by an embodiment of the present application is shown in the figure;
[0048] Figure 2 A detailed flowchart of a step in the dynamic sampling dialogue generation model training method provided by an embodiment of the present application is shown in the figure;
[0049] Figure 3 A detailed flowchart of a step in the dynamic sampling dialogue generation model training method provided by an embodiment of the present application is shown in the figure;
[0050] Figure 4 A module diagram of the dynamic sampling dialogue generation model training device provided by an embodiment of the present application is shown in the figure;
[0051] Figure 5 An internal structure diagram of the electronic device for implementing the dynamic sampling dialogue generation model training method provided by an embodiment of the present application is shown in the figure.
[0052] The implementation of the present application, the functional features and the advantages will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0053] It should be understood that the specific embodiments described herein are merely intended to explain the present application, and are not intended to limit the present application.
[0054] The embodiment of the application provides a dynamic sampling dialogue generation model training method. The execution subject of the dynamic sampling dialogue generation model training method includes at least one of electronic devices capable of being configured to execute the method provided by the embodiment of the application, such as a server and a terminal. The server can be an independent server, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. In other words, the dynamic sampling dialogue generation model training method can be executed by software or hardware installed in a remote device or a server device, and the software can be a blockchain platform. The server includes but is not limited to a single server, a server cluster, a cloud server, or a cloud server cluster.
[0055] Referring to Figure 1 FIG. 1 is a flowchart of a dynamic sampling dialogue generation model training method provided by an embodiment of the application. In this embodiment, the dynamic sampling dialogue generation model training method includes the following steps S1-S5:
[0056] S1, obtaining a reference answer sentence, performing word segmentation on the reference answer sentence to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence.
[0057] In the embodiment of the application, the reference answer sentence can be obtained from a pre-constructed training database. Word segmentation of the reference answer sentence means recombining continuous word sequences into semantic independent word sequences according to certain specifications, and the word segmentation method has multiple choices depending on the language. The specific language category of the reference answer sentence will be determined.
[0058] For example, if the reference answer sentence is a Chinese text, the word segmentation method can be a jieba word segmentation method, a HanLP word segmentation method, etc. If the reference answer sentence is an English text, the word segmentation method can be an NLTK word segmentation method, a SpaCy word segmentation method, etc.
[0059] Further, the reference answer sentence can be various answer sentences in the financial industry, such as "Do you want to handle long-term loans or short-term loans?", "We have xx insurance, xxx insurance, etc. Do you need to handle which insurance?", "How much capital do you plan to invest in financial management?" and the like
[0060] In the embodiment of the present application, each reference answer word in the answer word sequence is separated by a " / " symbol, and further, each answer word sequence has a prefix "CLS" and a suffix "SEP", for example, the prefix is "recite the frist law", and the suffix is "end of sentence". Wherein, the prefix and the suffix are used to determine the position of the answer word sequence, and each answer word sequence is divided.
[0061] Further, referring to Figure 2 As shown, the reference answer sentence is segmented to obtain an answer word sequence, comprising:
[0062] S101, constructing a prefix dictionary according to a preset statistical dictionary, and segmenting the reference answer sentence by using a regular expression to obtain a segmented answer sentence;
[0063] S102, constructing a directed acyclic graph of the segmented answer sentence according to the prefix dictionary;
[0064] S103, using a dynamic programming method to obtain a maximum probability path of the directed acyclic graph, and segmenting according to the maximum probability path to obtain the answer word sequence.
[0065] In the embodiment of the present application, the reference answer word is a constituent word constituting the answer word sequence, and the word position information is the order position of the reference answer word in the answer word sequence, that is, each reference answer word is located in the first word in the answer word sequence.
[0066] Further, the reference answer sentence is obtained, comprising:
[0067] Obtaining retrieval question and answer data in training data, and constructing a training database according to the labeled part in the retrieval question and answer data;
[0068] Obtaining a reference answer sentence from the training database.
[0069] In the embodiment of the present application, the retrieval question and answer data is data for training a preset dialogue generation model, and the retrieval question and answer data has unlabeled retrieval question and answer data and labeled retrieval question and answer data, wherein the unlabeled retrieval question and answer data is generally used for the pre-training link of the training step in the dialogue generation model, and the labeled retrieval question and answer data is generally used for the fine-tuning link in the training step in the dialogue generation model. Further, the labeled retrieval question and answer data includes an inquiry sentence and a reference answer sentence.
[0070] Further, the labeled retrieval question and answer data is data labeled by artificial or labeling tools, wherein the labeling tools can be LabelImg tools, RectLabel tools, etc.
[0071] In detail, the annotation types of the annotated retrieval question and answer data include classification annotation, annotation annotation, and frame annotation, and the data types of the annotated retrieval question and answer data are picture, voice, text and the like. The annotated retrieval question and answer data in the scheme is text data, and the annotation type is answer annotation annotation.
[0072] Further, the form of the annotated retrieval question and answer data is <query_database, answer_database>, wherein the query_database is an inquiry sentence, which is input into an encoder in a dialogue generation model, and the answer_database is a reference answer sentence, which is a true result of annotation.
[0073] S2, input the inquiry sentence corresponding to the reference answer sentence into the pre-trained dialogue generation model to obtain an i-th position answer word.
[0074] In the embodiment of the application, the inquiry sentence is an inquiry part in the annotated retrieval question and answer data, which is a question type sentence for training the dialogue generation model, and the form is query_database.
[0075] For example, the training data is <“Do you want to invest in stocks?”, “The stock risk is too large, or invest in funds”>, and the inquiry sentence is “Do you want to invest in stocks?”.
[0076] In detail, i in the i-th position answer word is a representation of each position answer word, i=1, 2, 3...n, and the initial value is 1.
[0077] In the embodiment of the application, the pre-trained dialogue generation model is a GPT-2 model (Generative Pre-trained Transformer 2), which is a generative neural network model and can be applied to multiple text related fields, such as machine translation, question answering, basic reading comprehension, sentiment analysis, text summarization and text generation, etc. In the scheme, the dialogue generation model is used in the text generation field.
[0078] The GPT-2 model has two training methods of pre-training and fine-tuning. In the pre-training stage, a large amount of unlabelled language text is used for training, and then a generative language model is initialized. In the fine-tuning stage, the pre-trained model is fine-tuned according to different requirements of specific tasks using related annotation data.
[0079] Referring to Figure 3As shown, in the embodiment of the present application, the input of the inquiry sentence corresponding to the reference answer sentence in the training database into the pre-trained dialogue generation model obtains the i-th position answer word, which comprises:
[0080] S201, based on the tokenizer in the dialogue generation model, the inquiry sentence is segmented to obtain an inquiry word sequence;
[0081] S201, each word in the inquiry word sequence is converted into a word vector by a word embedding algorithm to obtain a word vector sequence;
[0082] S201, the word vector sequence is input into the decoding layer of the Transformer in the dialogue generation model to generate the i-th position answer word of the inquiry sentence.
[0083] In the embodiment of the present application, the tokenizer is a tool for default segmentation of input text in the dialogue generation model.
[0084] In detail, the word embedding algorithm (Word Embedding) is a method of converting words in text into digital vectors. The word embedding method embeds a high-dimensional space with all word quantities into a much lower continuous vector space, so that each word or phrase is mapped to a vector in the real number field.
[0085] Further, the Transformer is a deep learning model based on self-attention mechanism, which consists of an encoding layer (Encoder) and a decoding layer (Decoder). The pre-trained dialogue generation model is composed of multiple Transformers.
[0086] S3, based on the word position information, the reference answer word corresponding to the i-th position answer word in the answer word sequence is obtained, and the replacement probability of the reference answer word is calculated, and the i+1-th position input word is obtained according to the replacement probability.
[0087] In the embodiment of the present application, the reference answer word is a word corresponding to each position answer word in the answer word sequence obtained according to the reference answer sentence, and the reference answer word can replace each position answer word to construct a new input word.
[0088] In the embodiment of the present application, the replacement probability is the probability of determining whether to replace each position answer word with the reference answer word in the answer word sequence.
[0089] In the embodiment of the present application,
[0090] The replacement probability N of the reference answer word is calculated by the following probability calculation formula:
[0091]
[0092]
[0093] wherein, the y and are the current position answer word and the reference answer word corresponding to the current position answer word respectively, T is the total number of positions, indicates the cumulative value of whether all previous positions y and are the same, if the same, add 1, if different, add 0, β is a preset parameter value of [0, 1], the parameter value will be dynamically reduced with the increase of time, the amount of reduction each time is 10% of the number of words in the answer word sequence, μ is a distribution, ~ indicates equivalent to.
[0094] Further, the i+1th position input word obtained according to the replacement probability comprises:
[0095] obtaining a preset replacement probability threshold;
[0096] determining whether the replacement probability is greater than or equal to the replacement probability threshold;
[0097] if the replacement probability is greater than or equal to the replacement probability threshold, the reference answer word is taken as the i+1th position input word;
[0098] if the replacement probability is less than the replacement probability threshold, the i th position answer word is taken as the i+1th position input word.
[0099] S4, input the i+1th position input word into the dialogue generation model, generate the i+1th position answer word, and return to S3 until there is no corresponding reference answer word in the answer word sequence, to obtain the answer words of multiple positions.
[0100] In another embodiment of the application, the i+1th position input word can also be input into the pre-trained dialogue generation model to generate the i+1th position answer word, and return to S3 until the answer word output is completed.
[0101] S5, the answer words of each position are collected to obtain the standard answer sentence of the inquiry sentence, and the fine-tuning training data is generated according to the inquiry sentence and the standard answer sentence, and the dialogue generation model is trained through the fine-tuning training data.
[0102] In the embodiment of the application, after the dialogue generation model is trained through the fine-tuning training data, the method further comprises:
[0103] acquire multi-dimensional objective indexes, and test and analyze a standard dialogue generation model obtained by training the dialogue generation model through the fine-tuning training data through the multi-dimensional objective indexes, to determine whether the standard dialogue model reaches a preset fine-tuning target;
[0104] If the standard dialogue generation model does not reach the preset fine-tuning target, return to step S3.
[0105] If the standard dialogue generation model reaches the preset fine-tuning target, the fine-tuning training of the standard dialogue generation model is completed.
[0106] In the embodiment of the application, the multi-dimensional objective indexes can be BLEU, ROUGE and perplexity indexes, and the preset fine-tuning target can be that the BLEU index, the ROUGE index and the perplexity index of the standard dialogue generation model reach a predetermined multiple of the pre-trained dialogue generation model.
[0107] The BLEU (bilingual evaluation understudy) index is a bilingual translation quality evaluation index, which is used to evaluate the translation quality of the dialogue generation model for machine translation, the ROUGE (Recall-Oriented Understudy for Gisting Evaluation) index is a quality evaluation index based on recall rate, and the perplexity is an index for evaluating the quality of a language model.
[0108] Further, after the training of the standard dialogue generation model is completed, the standard dialogue generation model can be used to provide financial consulting services for customers, and to answer questions such as "I want to make financial investment, can you perform an online risk assessment for me to determine the most suitable financial investment type for me?", "I want to open a store and need a low-interest loan, can you tell me which channels can help me solve this problem?"
[0109] In the embodiment of the present application, first, a reference answer sentence is acquired, the reference answer sentence is segmented, an answer word sequence is obtained, and reference answer words and word position information are obtained according to the answer word sequence, so as to achieve the purpose of acquiring word information; then, an inquiry sentence corresponding to the reference answer sentence is input into a dialogue generation model to obtain an i-th position answer word, and a reference answer word corresponding to the i-th position answer word in the answer word sequence is obtained based on the word position information, and an i+1-th position input word is obtained by calculating a replacement probability; then, the i+1-th position input word is input into the dialogue generation model to generate an i+1-th position answer word, so as to achieve the purpose of acquiring answer words at multiple positions; finally, the answer words at the multiple positions are collected to obtain a standard answer sentence, and fine-tuning training data is generated according to the inquiry sentence and the standard answer sentence to train the dialogue generation model. The present application compares the reference answer words with answer words generated by a pre-trained financial dialogue generation model, replaces the answer words according to the replacement probability of the reference answer words, so as to obtain fine-tuning training data for training the financial dialogue generation model, and to achieve the purpose of improving the accuracy of the financial dialogue generation model.
[0110] As shown in Figure 4 FIG. 1 is a module schematic diagram of the dialogue generation model training device according to the present application.
[0111] The dialogue generation model training device 100 according to the present application can be installed in an electronic device. According to the functions to be implemented, the dialogue generation model training device can include a word information acquisition module 101, an input word acquisition module 102, an answer word acquisition module 103, and a model training module 104. The modules according to the present application can also be referred to as units, which refer to a series of computer program segments that can be executed by an electronic device processor and can complete a fixed function, and are stored in the memory of the electronic device.
[0112] In the present embodiment, the functions of each module / unit are as follows:
[0113] The word information acquisition module 101 is configured to acquire a reference answer sentence, segment the reference answer sentence to obtain an answer word sequence, and obtain a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence.
[0114] The input word acquisition module 102 is configured to input an inquiry sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2, 3…n, the initial value is 1, obtain a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculate a replacement probability of the reference answer word, and obtain an i+1-th position input word according to the replacement probability.
[0115] The answering word obtaining module 103 is configured to input the i+1th position input word into the dialogue generation model, generate an i+1th position answering word, and return to the previous step until there is no corresponding reference answer word in the answer word sequence, so as to obtain answering words in multiple positions.
[0116] The model training module 104 is configured to collect answering words in various positions to obtain a standard answering sentence of the inquiry sentence, generate fine-tuning training data according to the inquiry sentence and the standard answering sentence, and train the dialogue generation model through the fine-tuning training data.
[0117] In detail, the modules in the dynamic sampling dialogue generation model training device 100 in the embodiment of the present application use the same technical means as the above Figures 1 to 3 The dynamic sampling dialogue generation model training method, and can produce the same technical effects, which will not be described here.
[0118] As Figure 5 shown, it is a structural schematic diagram of an electronic device for implementing the dynamic sampling dialogue generation model training method of the present application.
[0119] The electronic device can include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and can further include a computer program stored in the memory 11 and executable on the processor 10, such as a dynamic sampling dialogue generation model training program.
[0120] In some embodiments, the processor 10 can be composed of integrated circuits, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same function or different functions, including one or more combinations of central processing units (CPU), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control core of the electronic device. It connects all components of the electronic device through various interfaces and lines, executes or runs programs or modules stored in the memory 11 (such as the dynamic sampling dialogue generation model training program), and calls data stored in the memory 11 to perform various functions of the electronic device and process data.
[0121] The memory 11 includes at least one type of readable storage medium, such as a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 can also be an external storage device of the electronic device, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 11 can include both an internal storage unit and an external storage device of the electronic device. The memory 11 can be used to store application software and various data installed in the electronic device, such as a code of a dynamically sampled dialogue generation model training program, and can also be used to temporarily store data that has been output or will be output.
[0122] The communication bus 12 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable connection and communication between the memory 11 and at least one processor 10, etc.
[0123] The communication interface 13 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface can include a wired interface and / or a wireless interface (e.g., a WI-FI interface, a Bluetooth interface, etc.), and is typically used to establish a communication connection between the electronic device and other electronic devices. The user interface can be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface can also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, etc. The display can also be appropriately referred to as a display screen or a display unit, and is used to display information processed in the electronic device and to display a visualized user interface.
[0124] Figure 5 Only an electronic device with components is shown, and those skilled in the art can understand that, Figure 5The illustrated structure does not constitute a limitation on the electronic device, which can include fewer or more components than those shown, or combine certain components, or arrange different components.
[0125] For example, although not shown, the electronic device can also include a power supply (such as a battery) to power each component. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, so that functions such as charge management, discharge management, and power consumption management can be realized through the power management device. The power supply can also include one or more direct current or alternating current power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and any other components. The electronic device can also include various sensors, Bluetooth modules, Wi-Fi modules, and the like, which are not described here.
[0126] It should be understood that the embodiments are only for illustration and are not limited in the scope of the patent application by this structure.
[0127] The dynamic sampling dialogue generation model training program stored in the memory 11 in the electronic device is a combination of multiple computer programs, which, when running in the processor 10, can realize:
[0128] Step A, obtaining a reference answer sentence, performing word segmentation on the reference answer sentence to obtain an answer word sequence, and obtaining multiple reference answer words and word position information of each reference answer word according to the answer word sequence;
[0129] Step B, inputting the inquiry sentence corresponding to the reference answer sentence into the pre-trained dialogue generation model to obtain the i-th position answer word, where i = 1, 2, 3…n, and the initial value is 1;
[0130] Step C, obtaining the reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, and calculating the replacement probability of the reference answer word, to obtain the i+1-th position input word according to the replacement probability;
[0131] Step D, inputting the i+1-th position input word into the dialogue generation model to generate the i+1-th position answer word, and returning to Step C until there is no corresponding reference answer word in the answer word sequence, to obtain multiple position answer words;
[0132] Step E, collecting the answer words of each position to obtain the standard answer sentence of the inquiry sentence, generating fine-tuning training data according to the inquiry sentence and the standard answer sentence, and training the dialogue generation model through the fine-tuning training data.
[0133] Specifically, the specific implementation method of the processor 10 for the above computer programs can refer to Figure 1The description of the related steps in the corresponding embodiments will not be repeated here.
[0134] Further, the modules / units integrated in the electronic device, if realized in the form of software function units and sold or used as independent products, can be stored in a nonvolatile computer readable storage medium. The computer readable storage medium can be volatile or nonvolatile. For example, the computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0135] The application further provides a computer readable storage medium, which stores a computer program, and the computer program can realize the following steps when executed by a processor of an electronic device:
[0136] Step A, obtaining a reference answer statement, performing word segmentation on the reference answer statement to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
[0137] Step B, inputting an inquiry statement corresponding to the reference answer statement into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2, 3…n, and the initial value is 1;
[0138] Step C, obtaining a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, and calculating a replacement probability of the reference answer word, and obtaining an i+1-th position input word according to the replacement probability;
[0139] Step D, inputting the i+1-th position input word into the dialogue generation model to generate an i+1-th position answer word, and returning to step C until there is no corresponding reference answer word in the answer word sequence, to obtain a plurality of position answer words;
[0140] Step E, collecting the answer words at each position to obtain a standard answer statement of the inquiry statement, generating fine-tuning training data according to the inquiry statement and the standard answer statement, and training the dialogue generation model through the fine-tuning training data.
[0141] In several embodiments provided in the application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and another division mode can be used in actual implementation.
[0142] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, i.e., may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.
[0143] In addition, each functional module in various embodiments of the application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software functional modules.
[0144] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and the present application can be implemented in other specific forms without departing from the spirit or essential characteristics of the present application.
[0145] Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting, and the scope of the application is defined by the appended claims rather than the above description, and therefore all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the present application. Any additional reference signs in the claims should not be considered as limiting the claims to which they relate.
[0146] The blockchain referred to in the present application is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. Blockchain, in essence, is a decentralized database, a series of data blocks associated using cryptography, each containing a batch of network transaction information for verifying the validity (anti-fake) of the information and generating the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0147] The embodiments of the present application can acquire and process related data based on artificial intelligence technology. Among them, artificial intelligence (Artificial Intelligence, AI) is to use digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Theory, method, technology and application system.
[0148] In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices stated in the system claim can also be realized by one unit or device through software or hardware. The second word is used to indicate the name, and does not mean any specific order.
[0149] Finally, it should be noted that the above examples are merely intended to illustrate the technical solutions of the present application and not to limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A method for training a dynamic sampling dialogue generation model, characterized in that, The method comprises: Step A, obtaining a reference answer statement, performing word segmentation on the reference answer statement to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence; Step B, inputting an inquiry statement corresponding to the reference answer statement into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i = 1, 2, 3…n, and the initial value is 1; Step C, obtaining a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculating a replacement probability of the reference answer word, if the replacement probability of the reference answer word is greater than or equal to a preset threshold, taking the reference answer word as an i+1-th position input word, if the replacement probability of the reference answer word is less than the preset threshold, taking the i-th position answer word as the i+1-th position input word; Step D, inputting the i+1-th position input word into the dialogue generation model to generate an i+1-th position answer word, and returning to step C until there is no corresponding reference answer word in the answer word sequence, to obtain a plurality of position answer words; Step E, collecting the answer words at each position to obtain a standard answer statement of the inquiry statement, generating fine-tuning training data according to the inquiry statement and the standard answer statement, and training the dialogue generation model through the fine-tuning training data. 2.The dynamic sampling-based dialogue generation model training method of claim 1, wherein, The method comprises: performing word segmentation on the inquiry statement based on a word segmenter in the dialogue generation model to obtain an inquiry word sequence; converting each word in the inquiry word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence; generating the i-th position answer word of the inquiry statement through a decoding layer of a Transformer in the dialogue generation model. 3.The dynamic sampling-based conversation generation model training method of claim 1, wherein, The method comprises: constructing a prefix dictionary according to a preset statistical dictionary, and segmenting the reference answer statement using a regular expression to obtain a segmented answer statement; constructing a directed acyclic graph of the segmented answer statement according to the prefix dictionary; obtaining a maximum probability path of the directed acyclic graph using a dynamic programming method, and performing word segmentation according to the maximum probability path to obtain the answer word sequence. 4.The dynamic sampling-based conversation generation model training method of claim 1, wherein, After the dialogue generation model is trained through the fine-tuning training data, the method further comprises: obtaining a plurality of objective indicators, and testing and analyzing a standard dialogue generation model obtained by training the dialogue generation model through the fine-tuning training data through the plurality of objective indicators to determine whether the standard dialogue generation model reaches a preset fine-tuning target; if the standard dialogue generation model does not reach the preset fine-tuning target, returning to step C; if the standard dialogue generation model reaches the preset fine-tuning target, the fine-tuning training of the standard dialogue generation model is completed.
5. The dynamically sampled conversational generation model training method of claim 1, wherein, The method comprises: The replacement probability N of the answer word is calculated by the following probability calculation formula: Wherein, the and are the current position answer word and the reference answer word corresponding to the current position answer word respectively, T is the total number of positions, is a preset parameter value, is a distribution, and ~ represents is equivalent to. 6.A dynamic sampling dialogue generation model training apparatus, characterized in that, The device comprises: The word information acquisition module is configured to acquire a reference answer sentence, perform word segmentation on the reference answer sentence to obtain an answer word sequence, and obtain a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence; The input word acquisition module is configured to input an inquiry sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, where i = 1, 2, 3…n, the initial value is 1, obtain a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculate the replacement probability of the reference answer word, if the replacement probability of the reference answer word is greater than or equal to a preset threshold, take the reference answer word as an i+1-th position input word, and if the replacement probability of the reference answer word is less than the preset threshold, take the i-th position answer word as the i+1-th position input word; The answer word acquisition module is configured to input the i+1-th position input word into the dialogue generation model to generate an i+1-th position answer word, and return to the previous step until there is no corresponding reference answer word in the answer word sequence, to obtain a plurality of position answer words. The model training module is configured to collect the answer words at each position to obtain a standard answer sentence of the inquiry sentence, generate fine-tuning training data according to the inquiry sentence and the standard answer sentence, and train the dialogue generation model through the fine-tuning training data.
7. The dynamically sampled dialogue generation model training apparatus of claim 6, wherein, The inputting of the inquiry sentence corresponding to the reference answer sentence into the pre-trained dialogue generation model to obtain an i-th position answer word comprises: performing word segmentation on the inquiry sentence based on a word segmenter in the dialogue generation model to obtain an inquiry word sequence; converting each word in the inquiry word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence; passing the word vector sequence through a decoding layer of a Transformer in the dialogue generation model to generate an i-th position answer word of the inquiry sentence.
8. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the dynamic sampling dialogue generation model training method of any one of claims 1 to 5.
9. A computer readable storage medium comprising a storage data area and a storage program area, the storage data area storing created data, the storage program area storing a computer program; wherein, The computer program is executed by the processor to implement the dynamic sampling dialogue generation model training method of any one of claims 1 to 5.
Citation Information
Patent Citations
Instant checking method for answer reliability of question-answering system based on recursive inquiry
CN113987141A
Multi-round dialogue rewriting method and device and medium
CN115587598A