Dialogue data generation method, dialogue model training method and electronic device

By using the state probability transfer matrix to generate dialogue data, the problem of high-cost data acquisition in dialogue model training is solved, efficient and diverse dialogue data generation is achieved, and the generalization ability of dialogue model is improved.

CN119250184BActive Publication Date: 2025-03-11CHENGDU JIAFAANTAI EDUCATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411775487.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-03-11
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

The prior art requires a large amount of high-quality dialogue data when training efficient dialogue models, and data collection depends on the participation of a large number of high-quality teachers, resulting in high labor costs.

Method used

By obtaining the state probability transfer matrix and initial state corresponding to the student type, dialogue transfer is performed based on these matrices, dialogue text of the corresponding state is generated, and dialogue list is formed, and dialogue data is generated.

Benefits of technology

It realizes the cost of generating dialogue data in a cost-effective manner, reduces the cost of data collection, and the generated dialogue data is highly diverse and representative, improving the generalization ability and learning effect of dialogue models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119250184B_ABST
    Figure CN119250184B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method for generating dialogue data, a method for training a dialogue model, and an electronic device, and relates to the field of natural language technology. By obtaining the knowledge system and student type of dialogue data to be generated, obtaining the state probability transfer matrix corresponding to the student type and the initial state in the state probability transfer matrix, starting from the initial state, cyclically updating the current state according to the state probability transfer matrix, executing the action corresponding to the current state, generating at least one dialogue text based on the knowledge system, and sequentially adding the role and each dialogue text corresponding to the current state to a dialogue list until the current state is updated to the terminal state in the state probability transfer matrix, and taking the dialogue list as a set of dialogue data. Therefore, it is possible to generate a large amount of dialogue data without the teacher and the student having a large amount of real dialogue interaction to generate dialogue data, so as to provide a dialogue model for training, and save high labor costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language technology, and in particular to a dialogue data generation method, a dialogue model training method and an electronic device. Background Art

[0002] Foreign language learning dialogue refers to a learning method that improves language skills by communicating with others in the target foreign language.

[0003] In modern foreign language learning, the training of dialogue models is one of the key factors to improve learning outcomes. However, to train an efficient dialogue model, a large amount of high-quality dialogue data is required. This data must not only cover a variety of learning scenarios, but also reflect the interactions between learners of different levels.

[0004] Conversation data for foreign language learning usually needs to be generated by real conversations between professional teachers and students. This means that a large number of high-quality teachers are required to participate in data collection. These teachers not only need to have a high level of foreign language proficiency, but also need to have certain teaching experience and logical consistency to ensure that the generated conversation data has teaching value. This high requirement leads to very high labor costs for data collection. Summary of the invention

[0005] In view of this, an object of embodiments of the present invention is to provide a method for generating dialogue data, a method for training a dialogue model, and an electronic device to at least partially improve the above-mentioned problem.

[0006] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:

[0007] In a first aspect, an embodiment of the present invention provides a method for generating conversation data, the method comprising:

[0008] Acquire the knowledge system and student type of the dialogue data to be generated; the student type representation is differentiated according to the student's own foreign language ability;

[0009] Obtaining a state probability transfer matrix corresponding to the student type and an initial state in the state probability transfer matrix; the state probability transfer matrix includes a plurality of states and the probability of each state transferring to another state; the state includes a role type;

[0010] Starting from the initial state, the previous state and the current state are cyclically updated according to the state probability transfer matrix, the action corresponding to the current state is executed, at least one dialogue text is generated based on the knowledge system, and the role corresponding to the current state and each dialogue text are sequentially added to the dialogue list until the current state is updated to the terminal state in the state probability transfer matrix; the current state represents the state currently being processed, and the previous state represents the state before the current state is updated;

[0011] The conversation list is regarded as a group of conversation data.

[0012] Optionally, the obtaining of the state probability transfer matrix corresponding to the student type and the initial state in the state probability transfer matrix includes:

[0013] Obtaining a preset initial state probability transfer matrix corresponding to the student type and a plurality of annotated real conversation data;

[0014] According to each of the real dialogue data, the initial state probability transfer matrix is ​​adjusted to obtain a state probability transfer matrix corresponding to the student type;

[0015] A state in the state probability transfer matrix is ​​preset as an initial state.

[0016] Optionally, adjusting the initial state probability transfer matrix according to each of the real dialogue data to obtain the state probability transfer matrix corresponding to the student type includes:

[0017] The probability of a state transferring to another state in the initial state probability transfer matrix is ​​arbitrarily selected as the target probability;

[0018] Initialize the Beta distribution parameters according to the target probability to obtain the prior parameters;

[0019] According to each of the real conversation data, the beta distribution parameters are updated to obtain posterior parameters;

[0020] Calculating an adjusted update probability according to the posterior parameters, and updating the target probability to the update probability;

[0021] Each probability in the initial state probability transfer matrix is ​​traversed, each probability is updated, and the state probability transfer matrix is ​​obtained.

[0022] Optionally, starting from the initial state, cyclically updating the previous state and the current state according to the state probability transfer matrix, executing the action corresponding to the current state, generating at least one dialogue text based on the knowledge system, and sequentially adding the role corresponding to the current state and each dialogue text to the dialogue list until the current state is updated to the terminal state in the state probability transfer matrix, includes:

[0023] Taking the initial state as the current state, executing the action corresponding to the current state to obtain at least one dialogue text, adding the role corresponding to the current state and each dialogue text to the dialogue list, and updating the previous state to the current state;

[0024] According to the state probability transfer matrix and the previous state, the current state, the previous state and the state probability transfer matrix are updated cyclically, the action corresponding to the current state is executed, at least one dialogue text is obtained, and the role corresponding to the current state and each dialogue text are added to the dialogue list until the current state is updated to the terminal state in the state probability transfer matrix.

[0025] Optionally, executing the action corresponding to the current state to obtain at least one dialogue text, adding the role corresponding to the current state and the dialogue text to a dialogue list, and updating the previous state to the current state includes:

[0026] Execute the action corresponding to the current state and determine whether the execution is successful;

[0027] If yes, obtain the dialogue text generated by the action corresponding to the current state, add the role corresponding to the current state and the dialogue text to the dialogue list, and update the previous state to the current state;

[0028] If not, update the current state according to the state probability transfer matrix and the previous state, and execute the action corresponding to the updated current state until the action is successfully executed, obtain the dialogue text generated by the action corresponding to the current state, add the role corresponding to the current state and the dialogue text to the dialogue list, and update the previous state to the current state.

[0029] Optionally, the action includes at least one node, the node is a generation node or a detection node, and the node includes a prompt word template;

[0030] The executing the action corresponding to the current state includes:

[0031] If the action only includes generating a node, filling the prompt word template of the node according to the knowledge system to construct a prompt word, and sending the prompt word to the language big model to obtain a dialogue text;

[0032] If the action includes generating nodes and detecting nodes, the nodes are processed in a loop in sequence according to the order of the nodes in the action;

[0033] If the node currently being processed is a generation node, according to the knowledge system, the prompt word template of the generation node is filled to construct a first prompt word, and the first prompt word is sent to the language big model to obtain a first dialogue text;

[0034] If the node currently being processed is a detection node, fill in the prompt word template of the detection node according to the knowledge system, the dialogue list and the first dialogue text to construct a second prompt word, and send the second prompt word to the language macro model to obtain a result of whether the first dialogue text is expected;

[0035] If the result is as expected, continue to execute the actions of other nodes of the action;

[0036] If the result does not meet expectations, the execution process of the action is terminated.

[0037] Optionally, the cyclically updating the current state, the previous state, and updating the state probability transfer matrix according to the state probability transfer matrix and the previous state includes:

[0038] According to the current state and the transition probabilities of each state corresponding to it, a new state is selected as the updated current state;

[0039] The probability corresponding to the terminal state in the state probability transfer matrix is ​​updated according to a predetermined strategy.

[0040] Optionally, the predetermined strategy includes:

[0041] The probability of the terminal state increases with each cycle in a linear or nonlinear manner;

[0042] Or, when the length of the conversation list is greater than a preset length, the probability of the termination state increases with each cycle in a linear or nonlinear manner;

[0043] Alternatively, when the length of the conversation list is greater than a preset length, the probability of the termination state is increased with each cycle in a linear or nonlinear manner, and when the probability of the termination state reaches a preset probability, the increase stops.

[0044] In a second aspect, an embodiment of the present invention provides a method for training a dialogue model, the method comprising:

[0045] Acquire multiple groups of conversation data; the conversation data is generated by the method described in any one of the first aspects above;

[0046] The dialogue model is trained using the dialogue data to obtain a mature dialogue model.

[0047] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the program, the method for generating dialogue data described in any one of the first aspect and / or the method for training dialogue models described in the second aspect are implemented.

[0048] The embodiments of the present invention provide a method for generating dialogue data, a method for training a dialogue model, and an electronic device. The method performs dialogue transfer according to a state probability transfer matrix, and generates a dialogue text of a corresponding state each time the transfer occurs, so that dialogue data can be generated more economically and efficiently, greatly reducing the cost of data collection. Through the state probability transfer matrix corresponding to different student types, the generated dialogue data can include the learning process of students of different levels, and the generated dialogue data can be distributed more evenly, and the generated dialogue data can have a high degree of diversity and representativeness, which can help the dialogue model learn dialogue modes in different scenarios and improve its generalization ability, so that the dialogue model can simulate more realistic dialogue scenarios in various situations, thereby improving the language practice effect of learners.

[0049] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0051] Figure 1 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention;

[0052] Figure 2 A flowchart of a method for generating conversation data provided by an embodiment of the present invention;

[0053] Figure 3 A schematic diagram of a flow chart of an action execution provided by an embodiment of the present invention;

[0054] Figure 4 Another schematic diagram of a flow chart of an action execution provided by an embodiment of the present invention;

[0055] Figure 5 A flowchart of a dialogue model training method provided by an embodiment of the present invention.

[0056] Icon: 100 - electronic device; 101 - memory; 102 - communication interface; 103 - processor; 104 - bus. DETAILED DESCRIPTION

[0057] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0058] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0059] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0060] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0061] As mentioned in the background technology, in modern foreign language learning, the training of dialogue models is one of the key factors to improve learning results. However, to train an efficient dialogue model, a large amount of high-quality dialogue data is required. This data should not only cover various learning scenarios, but also reflect the interactions between learners of different levels.

[0062] High-quality dialogue data often needs to be generated by professional teachers who have real dialogue interactions with students. This means that a large number of high-quality teachers are needed to participate in data collection. These teachers not only need to have a high level of foreign language proficiency, but also need to have certain teaching experience and logical consistency to ensure that the generated dialogue data has teaching value. This high requirement leads to very high labor costs for data collection.

[0063] Based on the above situation, the embodiments of the present invention provide a method for generating dialogue data, a method for training a dialogue model, and an electronic device. The dialogue is transferred according to a set state probability transfer matrix, and a corresponding dialogue text is generated for each transfer. After the state probability transfer matrix transfer is completed, a set of dialogue data is generated. Therefore, a large amount of dialogue data can be generated more economically and efficiently through this method, which greatly reduces the cost of data collection.

[0064] To implement the process steps and functions of each example of the present invention, please refer to Figure 1 , Figure 1 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention. The electronic device 100 includes a memory 101 and a processor 103, and the memory 101 and the processor 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses 104 or signal lines. The memory 101 can be used to store software programs and modules, and the processor 103 executes the software programs and modules stored in the memory 101 to perform various functional applications and data processing.

[0065] The electronic device 100 may be, but is not limited to, a personal computer (PC), a server, a distributed computer, etc. It is understandable that the electronic device 100 is not limited to a physical server, but may also be a virtual machine on a physical server, a virtual machine built on a cloud platform, etc., which can provide the same functions as the server or virtual machine. The operating system of the electronic device 100 may be, but is not limited to, a Windows system, a Linux system, etc.

[0066] Among them, the memory 101 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.

[0067] The communication connection between the electronic device 100 and an external device is achieved through at least one communication interface 102 (which can be wired or wireless).

[0068] The processor 103 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the embodiment of the present invention can be completed by the hardware integrated logic circuit in the processor 103 or the instructions in the form of software. The processor 103 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.

[0069] Understandably, Figure 1 The structure shown is for illustration only. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0070] The following is an exemplary description of the method for generating conversation data provided by the present invention. Specifically, Figure 2 A flow chart of a method for generating conversation data provided by an embodiment of the present invention is shown in FIG. Figure 2 , the execution subject of this method can be the above Figure 1 The electronic device 100 shown in FIG. 1 includes: Figure 2 The following steps are shown:

[0071] S210: Obtain the knowledge system and student type of the dialogue data to be generated; wherein the student type represents the type distinction based on the student's own foreign language ability.

[0072] A certain range of knowledge system needs to be given so that dialogue data can be better generated based on the knowledge system. Optionally, the knowledge system may include chat topics and knowledge content. The knowledge content may include word ranges, sentence types, and grammatical knowledge.

[0073] Student types are differentiated according to their foreign language abilities. For example, if English conversation data is to be generated, the students are divided according to their English proficiency. Optionally, student types may include "poor", "average", and "good", corresponding to different English abilities.

[0074] For ease of explanation, in this example, English will be used for explanation, that is, the students' abilities are evaluated in English and the knowledge content is in English.

[0075] S220: Obtain the state probability transfer matrix corresponding to the student type and the initial state in the state probability transfer matrix; wherein the state probability transfer matrix includes multiple states and the probability of each state transferring to other states, and the state includes the role type.

[0076] The state probability transfer matrix corresponding to each student type can be different, which can make the generated dialogue data richer; the state probability transfer matrix is ​​used to describe the probability of one state transferring to another state. For example, a 3x3 state probability transfer matrix P ,as follows:

[0077]

[0078] It contains three states: A, B and C. The matrix represents the probability of transition between the three states A, B and C. Each element in the matrix P ij Indicates from the state i Transfer to state j The probability, for example, P AA represents the probability of transitioning from state A to state A, P AB represents the probability of transitioning from state A to state B, and so on. We can use a table to simply illustrate, as shown in Table 1:

[0079] Table 1

[0080]

[0081] The percentages in Table 1 represent the probability of transferring from the state on the horizontal axis to the numerical axis. It is clear that the probability of one state transferring to another state can be known. For the sake of convenience in the following explanation, the state probability transfer matrix will be expressed in this way.

[0082] The state includes a role type, which indicates to which role the state belongs, for example, a role can be a teacher or a student.

[0083] The initial state is a state specified in the state probability transfer matrix, for example, A is the initial state.

[0084] S230: Starting from the initial state, the current state is cyclically updated according to the state probability transfer matrix, the action corresponding to the current state is executed, at least one dialogue text is generated based on the knowledge system, and the role and each dialogue text corresponding to the current state are added to the dialogue list in sequence until the current state is updated to the terminal state in the state probability transfer matrix.

[0085] Each state corresponds to an action, which means something needs to be done when transferring to a state.

[0086] According to the example in Table 1, a simple example is given. The action of state A is the teacher speaking, the action of state B is ending, the action of state C is the student speaking, and state A is the initial state.

[0087] Starting from the initial state A, first execute the action corresponding to A, generate the dialogue text spoken by the teacher according to the knowledge system, add it to the dialogue list, and then transfer according to Table 1, such as transfer C, execute the action corresponding to C, generate the dialogue text spoken by the student according to the knowledge system, add it to the dialogue list, and then transfer according to Table 1, such as transfer A, and then execute the action corresponding to A until you transfer to state B, then end the transfer. The state probability transfer matrix P This is just an example. In actual operation, the state probability transfer matrix is ​​often more complicated.

[0088] Among them, the method of generating dialogue text can use a large language model to generate a single text.

[0089] S240: The conversation list is regarded as a group of conversation data.

[0090] By continuously transferring the state probability transfer matrix in step S230, a dialogue list including multiple dialogue texts is generated. The dialogue list is used as a group of dialogue data and can be used in dialogue model training.

[0091] This method performs state transfer in the state probability transfer matrix, generates dialogue text according to the action corresponding to the state, and adds the dialogue text to the dialogue list to generate a set of rich and complete dialogue data. In this way, there is no need for teachers and students to conduct a large number of real dialogue interactions to generate dialogue data. A large amount of dialogue data can be generated to provide dialogue models for training, which can save high labor costs.

[0092] In a possible implementation, in order to more accurately reflect the performance of students in the actual English communication process, the state probability transfer matrix may also be adjusted. The above step S220 includes the following steps:

[0093] S221: Obtain a preset initial state probability transfer matrix corresponding to the student type and a plurality of annotated real conversation data.

[0094] Among them, the preset initial state probability transfer matrix can be obtained by collecting opinions from multiple experienced English speaking teachers through questionnaires. Each English speaking teacher needs to estimate the students' language usage in different teaching situations based on his or her own teaching experience. The content of the questionnaire can be shown in Table 2.

[0095] Table 2

[0096]

[0097] According to the feedback provided by each English speaking teacher, the average probability of different types of students is taken to obtain the initial state probability transfer matrix. For example, the initial state transfer matrix of the "good" students is shown in Table 3.

[0098] Table 3

[0099]

[0100] The annotated real dialogue data represents the real process of the students in the dialogue record. For example, 300 annotated real dialogue data were collected.

[0101] S222: According to each real dialogue data, the initial state probability transfer matrix is ​​adjusted to obtain the state probability transfer matrix corresponding to the student type.

[0102] Then adjust the initial state probability transfer matrix according to the real conversation data to obtain the state probability transfer matrix corresponding to the student type. For example, adjust the initial state probability transfer matrix of the "good" students, find the data of the "good" students in 300 data, and adjust the initial state probability transfer matrix.

[0103] Optionally, Beta distribution may be used to adjust the initial state probability transfer matrix, and the above step S222 may include the following steps:

[0104] S2221: Arbitrarily select the probability of one state transferring to another state in the initial state probability transfer matrix as the target probability.

[0105] S2222: Initialize Beta distribution parameters according to the target probability to obtain prior parameters.

[0106] S2223: Update the Beta distribution parameters according to the real conversation data to obtain the posterior parameters.

[0107] S2224: Calculate the adjusted update probability based on the posterior parameters, and update the target probability to the update probability.

[0108] S2225: Traverse each probability in the initial state probability transfer matrix, update each probability, and obtain the state probability transfer matrix.

[0109] First, select the probability of transferring from one state to another one by one and make adjustments. For example, the estimated probability of the initial state probability transfer matrix of the "good" student transferring to the "student-correct English answer" state in the "teacher-start" state is 88.71%. Adjust this probability first.

[0110] To estimate the parameters of the Beta distribution, we use the initial probability as the basis. The Beta distribution is a continuous probability distribution, often used to represent the uncertainty of a probability or ratio. According to the probability of transferring from the "Teacher-Start" state to the "Student-Correct English Answer", the Beta distribution parameters are initialized to obtain the prior parameters α and β:

[0111]

[0112] in, p The probability of transferring from the "teacher-start" state to the "student-correct answer in English" state is 88.71%, and N represents a constant. In this example, the confidence value of N is set to 1000, so α is 8871 and β is 1129.

[0113] For example, among the 300 conversation data collected, 57 conversation records of "good" students are counted, and the actual number of transfers from "teacher-start" to "student-correct English answer" is counted. Among these 57 conversation records, 56 were successfully transferred to "student-correct English answer", that is, the number of successful transfers is 56. Therefore, the posterior parameter can be expressed as:

[0114] α′=α+number of successes

[0115] β′=β+(total number of times − number of successes)

[0116] That is, α′ is 8871+56=8927, and β′ is 1129+1=1130.

[0117] The adjusted update probability can be calculated based on the obtained posterior parameters, and the calculation formula can be:

[0118]

[0119] That is, the adjusted probability is 8927 / (8927+1130)=88.76%.

[0120] Finally, traverse each probability in the initial state probability transfer matrix, update each probability in the above way, and obtain the final state probability transfer matrix.

[0121] S223: Preset a state in the state probability transfer matrix as an initial state.

[0122] In the embodiment of the present invention, "Teacher-Start" may be used as the initial state.

[0123] In a possible implementation, the above step S230 may include the following steps:

[0124] S231: Take the initial state as the current state, execute the action corresponding to the current state, obtain at least one dialogue text, add the role and each dialogue text corresponding to the current state to the dialogue list, and update the previous state to the current state.

[0125] First, the current state is the initial state, which is "Teacher-Start" in the embodiment of the present invention. By executing the action corresponding to this state, the dialogue text can be obtained. The role and each dialogue text corresponding to the current state are added to the dialogue list. Then, the text includes the role and what the role says.

[0126] S232: According to the state probability transfer matrix and the previous state, the current state, the previous state and the updated state probability transfer matrix are cyclically updated, the action corresponding to the current state is executed, at least one dialogue text is obtained, the role and each dialogue text corresponding to the current state are added to the dialogue list, and the previous state is updated to the current state, until the current state is updated to the terminal state in the state probability transfer matrix.

[0127] Exemplarily, in an embodiment of the invention, the termination state is set to "Teacher-End". When an action is completed, the current state needs to be updated, the action of the current state is executed again, the dialogue text is generated, and the state probability transfer matrix is ​​updated at the same time to adjust the probability of the termination state. For example, the probability of "Teacher-End" is 0% at the beginning. After multiple transfers, the probability of "Teacher-End" begins to increase. When it is transferred to "Teacher-End", the generation of this dialogue data is ended.

[0128] Optionally, according to the state probability transfer matrix, the steps of cyclically updating the current state and updating the state probability transfer matrix include:

[0129] S2321: According to the current state and the transition probabilities of each state corresponding to it, a new state is selected as the updated current state.

[0130] For example, in an embodiment of the present invention, the current state is "teacher-start", and according to the probabilities of the corresponding states, a state is selected as the new current state according to the probability, for example, "student-correct answer in English" is selected.

[0131] S2322: Update the probability corresponding to the terminal state in the state probability transfer matrix according to a predetermined strategy.

[0132] In the embodiment of the present invention, "Teacher-End" is the termination state, and the "Teacher-End" corresponding to student-correct answer in English, student-correct answer in Chinese, student-correct answer in Chinese and English, student-wrong answer in English, student-wrong answer in Chinese, and student-wrong answer in Chinese and English will be updated.

[0133] Optionally, the predetermined strategy includes:

[0134] The probability of the terminal state increases with each cycle in a linear or nonlinear manner.

[0135] For example, the initial probability of the termination state "Teacher-End" in the embodiment of the present invention is 0%. When the current state is updated once, the probability of the termination state increases by 5%. If the current state has not been updated to the termination state, the termination state will increase to 100%, and it will be updated to the termination state next time.

[0136] When the probability of the terminal state increases by 5%, the probabilities of the other states in the column decrease, and the total sums to 100%, as shown in Table 4.

[0137] Table 4

[0138]

[0139] Alternatively, when the length of the conversation list is greater than a preset length, the probability of the termination state increases with each cycle in a linear or nonlinear manner.

[0140] On the basis of the above predetermined strategy, the probability of updating the termination status is increased when the length of the conversation list is greater than the preset length.

[0141] For example, the probability of the termination state is updated after the conversation list includes 10 conversation texts. It can be determined that the termination state will not be selected before the 10 conversation texts are generated, so that the conversation list can include at least 10 conversation texts.

[0142] Alternatively, when the length of the conversation list is greater than a preset length, the probability of the termination state is increased linearly or nonlinearly with each cycle, and stops increasing when the probability of the termination state reaches a preset probability.

[0143] Further restrictions are imposed on the predetermined strategy, and an upper limit value is set for the probability of the termination state. For example, the upper limit is set to 50%. When the probability of the termination state is updated to 50%, the probability of the termination state is no longer updated.

[0144] In one possible implementation, see Figure 3 , Figure 3 A flowchart of an action execution provided by an embodiment of the present invention, executing an action corresponding to a current state, obtaining at least one dialogue text, adding a role and each dialogue text corresponding to the current state to a dialogue list, and updating a previous state to a current state, may include the following steps:

[0145] S2311: Execute the action corresponding to the current state and determine whether the execution is successful. If so, execute step S2312; if not, execute step S2313.

[0146] S2312: Get the dialogue text generated by the action corresponding to the current state, add the role and dialogue text corresponding to the current state to the dialogue list, and update the previous state to the current state.

[0147] S2313: Update the current state according to the state probability transfer matrix and the previous state, and execute the action corresponding to the updated current state until the action is successfully executed, obtain the dialogue text generated by the action corresponding to the current state, add the role and dialogue text corresponding to the current state to the dialogue list, and update the previous state to the current state.

[0148] Optionally, the action includes at least one node, the node is a generation node or a detection node, the node includes a prompt word template, and executing the action corresponding to the current state may include:

[0149] If the action only includes generating nodes, the prompt words are constructed based on the knowledge system and the prompt word template of the filling node, and the prompt words are sent to the language model to obtain the dialogue text.

[0150] For example, the action is the action "Teacher opening action" corresponding to the "Teacher-Start" state, and the node included in the action is Teacher Opening [Generate Node].

[0151] The knowledge system includes chat topics and knowledge content. The topic is: "Favorite Food"; the knowledge content is:

[0152] Words: food, like, dislike, taste, flavor, etc.

[0153] Phrases: favorite food, taste good, too spicy, etc.

[0154] Sentence pattern: I like / dislike... because..., The best food I've ever had is..., etc.

[0155] Grammar: Use present tense to express preferences, use comparative adjectives, etc.

[0156] The prompt word template is: Your current role is a teacher. You need to give an opening speech to the students based on the theme of "

Topic

[0157] According to the knowledge system and the prompt word template, the prompt words are constructed as follows: Your current role is a teacher. You need to give an opening remark to the students based on the theme of "Favorite Food" to start the oral practice process; the opening remark is.

[0158] The language model can generate content based on the prompt words and knowledge system, such as: "Hi, let's start. What's your favorite food?". Then the action is executed successfully. And the pre-condition state is updated to "Teacher-Start".

[0159] For another example, the action is the action "student correct answer action" corresponding to the "student-English correct answer" state, and the node included in the action is student correct answer [generate node].

[0160] In the same manner as above, the generated dialogue is "I like fired rice." and the pre-condition state is updated to "student - correct answer in English".

[0161] The dialogue list at this time is: {"role": "Teacher", "content": "Hi, let's start. What's your favorite food?"}, {"role": "Student", "content": "I like firedrice."}. Among them, role is the role, and content is the generated content.

[0162] Among them, the large language model can be a model based on an autoencoder, a model based on a Transformer, a recursive neural network model, etc.

[0163] If the action includes generating nodes and detecting nodes, each node is processed in turn according to the order of the nodes in the action.

[0164] If the node currently being processed is a generation node, the prompt word template of the generation node is filled in according to the knowledge system to construct a first prompt word, and the first prompt word is sent to the language model to obtain a first dialogue text.

[0165] If the node currently being processed is a detection node, fill in the prompt word template of the detection node according to the knowledge system, the dialogue list and the first dialogue text to construct a second prompt word, and send the second prompt word to the language big model to obtain the result of whether the first dialogue text is expected;

[0166] If the result is as expected, continue to execute the actions of other nodes;

[0167] If the result does not meet expectations, the execution process of the action is terminated.

[0168] The following example illustrates the case where the action includes generating nodes and detecting nodes. The previous state is "Teacher-Start", and the current state is "Student-Chinese and English incorrect answer". The action corresponding to this state is: Student Chinese and English incorrect answer action, including: Student incorrect answer node [generating node], error confirmation node [detecting node], language embedding node [generating node], embedding detection node [detecting node].

[0169] First, based on the student's incorrect response node [Generate Node], request the language model to generate content, for example, the content is "I like football."

[0170] Secondly, according to the error confirmation node [detection node], the generated "I like football.", the knowledge system, and the dialogue list are used in the request language big model to calculate whether the generated content "I like football." meets expectations;

[0171] If the result is as expected, the language embedding node [Generate Node] is executed continuously. For example, if the generated content is "I like football.", the content "I like football." is detected through the embedding detection node [Detect Node].

[0172] If the result does not meet expectations, the execution process of the action is terminated, and the current state is reselected according to the previous state "Teacher-Start". If "Student-Chinese and English Correct Answer" is selected, the corresponding action is executed according to the "Student-Chinese and English Correct Answer" state.

[0173] Optionally, if the result does not meet expectations, the node can be repeatedly executed up to a preset number of times.

[0174] The following is a further description of the process of executing actions, see Figure 4 , Figure 4 Another schematic diagram of a process flow of an action execution provided by an embodiment of the present invention, the process flow may be as follows:

[0175] S1: Determine whether the action only includes generating nodes. If yes, execute S2; if no, execute S3.

[0176] S2: Generate dialogue text. The action ends.

[0177] S3: According to the order of the nodes in the action, each node is processed in a loop in turn.

[0178] S4: Determine whether the node currently being processed is a generated node. If yes, execute S5; if no, execute S6.

[0179] S5: Generate the first dialogue text. Repeat S3 to loop to the next node.

[0180] S6: Obtain a result of whether the first dialogue text is expected.

[0181] S7: Determine whether the result meets expectations. If yes, repeat S3 to loop to the next node; if no, execute S8.

[0182] S8: End the execution process of the action.

[0183] Furthermore, the embodiment of the present invention also provides a method for training a dialogue model, referring to Figure 5 , Figure 5 A flowchart of a dialogue model training method provided by an embodiment of the present invention, the execution subject of the method may be the above Figure 1 The electronic device 100 shown in the figure comprises the following steps:

[0184] S310: Acquire multiple groups of conversation data; wherein the conversation data is generated by the conversation data generation method described above.

[0185] S320: Train the dialogue model using the dialogue data to obtain a mature dialogue model.

[0186] The conversation data generated by the above conversation data generation method can be used to effectively train the conversation model. Since the generated conversation data is highly diverse and representative, it can help the model learn conversation patterns in different scenarios and improve its generalization ability. This enables the model to simulate more realistic conversation scenarios in a variety of situations, thereby improving the language practice effect of learners.

[0187] In summary, the embodiments of the present invention provide a method for generating dialogue data, a method for training a dialogue model, and an electronic device. The dialogue transfer is performed according to the state probability transfer matrix, and each transfer generates a dialogue text of the corresponding state, so that the dialogue data can be generated more economically and efficiently, greatly reducing the cost of data collection. Through the state probability transfer matrix corresponding to different student types, the generated dialogue data can include the learning process of students of different levels, and the generated dialogue data can be distributed more evenly, and the generated dialogue data can have a high degree of diversity and representativeness, which can help the dialogue model learn the dialogue modes in different scenarios and improve its generalization ability, so that the dialogue model can simulate more realistic dialogue scenarios in various situations, thereby improving the language practice effect of learners.

[0188] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0189] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0190] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a computer-readable storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0191] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0192] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

Claims

1. A method for generating conversation data, characterized in that: The method comprises: Acquire the knowledge system and student type of the dialogue data to be generated; the student type representation is differentiated according to the student's own foreign language ability; Obtaining a state probability transfer matrix corresponding to the student type and an initial state in the state probability transfer matrix; the state probability transfer matrix includes a plurality of states and the probability of each state transferring to another state; the state includes a role type; Starting from the initial state, the previous state and the current state are cyclically updated according to the state probability transfer matrix, the action corresponding to the current state is executed, at least one dialogue text is generated based on the knowledge system, and the role corresponding to the current state and each dialogue text are added to the dialogue list in sequence until the current state is updated to the terminal state in the state probability transfer matrix; the current state represents the state currently being processed, and the previous state represents the previous state before the current state is updated; the action includes at least one node, the node is a generation node or a detection node, and the node includes a prompt word template; the execution of the action corresponding to the current state includes: if the action only includes a generation node, according to the knowledge system, fill in the prompt word template of the node to construct a prompt word, and send the prompt word to the language The large model is used to obtain the dialogue text; if the action includes a generation node and a detection node, each of the nodes is processed in turn according to the order of the nodes in the action; if the node currently being processed is a generation node, the prompt word template of the generation node is filled in according to the knowledge system to construct a first prompt word, and the first prompt word is sent to the language large model to obtain a first dialogue text; if the node currently being processed is a detection node, the prompt word template of the detection node is filled in according to the knowledge system, the dialogue list and the first dialogue text to construct a second prompt word, and the second prompt word is sent to the language large model to obtain the result of whether the first dialogue text is expected; if the result meets the expectation, the action of other nodes of the action is continued to be executed; if the result does not meet the expectation, the execution process of the action is terminated; The conversation list is regarded as a group of conversation data.

2. The method according to claim 1, characterized in that The obtaining of the state probability transfer matrix corresponding to the student type and the initial state in the state probability transfer matrix includes: Obtaining a preset initial state probability transfer matrix corresponding to the student type and a plurality of annotated real conversation data; According to each of the real dialogue data, the initial state probability transfer matrix is ​​adjusted to obtain a state probability transfer matrix corresponding to the student type; A state in the state probability transfer matrix is ​​preset as an initial state.

3. The method according to claim 2, characterized in that The initial state probability transfer matrix is ​​adjusted according to each of the real dialogue data to obtain the state probability transfer matrix corresponding to the student type, including: The probability of a state transferring to another state in the initial state probability transfer matrix is ​​arbitrarily selected as the target probability; Initialize the Beta distribution parameters according to the target probability to obtain the prior parameters; According to each of the real conversation data, the beta distribution parameters are updated to obtain posterior parameters; Calculating an adjusted update probability according to the posterior parameters, and updating the target probability to the update probability; Each probability in the initial state probability transfer matrix is ​​traversed, each probability is updated, and the state probability transfer matrix is ​​obtained.

4. The method according to claim 1, characterized in that: Starting from the initial state, cyclically updating the previous state and the current state according to the state probability transfer matrix, executing the action corresponding to the current state, generating at least one dialogue text based on the knowledge system, and sequentially adding the role corresponding to the current state and each dialogue text to the dialogue list until the current state is updated to the terminal state in the state probability transfer matrix, including: Taking the initial state as the current state, executing the action corresponding to the current state to obtain at least one dialogue text, adding the role corresponding to the current state and each dialogue text to the dialogue list, and updating the previous state to the current state; According to the state probability transfer matrix and the previous state, the current state, the previous state and the state probability transfer matrix are updated cyclically, the action corresponding to the current state is executed, at least one dialogue text is obtained, and the role corresponding to the current state and each dialogue text are added to the dialogue list until the current state is updated to the terminal state in the state probability transfer matrix.

5. The method according to claim 4, characterized in that The performing of the action corresponding to the current state to obtain at least one dialogue text, adding the role corresponding to the current state and each dialogue text to a dialogue list, and updating the previous state to the current state includes: Execute the action corresponding to the current state and determine whether the execution is successful; If yes, obtain the dialogue text generated by the action corresponding to the current state, add the role corresponding to the current state and the dialogue text to the dialogue list, and update the previous state to the current state; If not, update the current state according to the state probability transfer matrix and the previous state, and execute the action corresponding to the updated current state until the action is successfully executed, obtain the dialogue text generated by the action corresponding to the current state, add the role corresponding to the current state and the dialogue text to the dialogue list, and update the previous state to the current state.

6. The method according to claim 4, characterized in that The step of cyclically updating the current state, the previous state, and the state probability transfer matrix according to the state probability transfer matrix and the previous state comprises: According to the current state and the transition probabilities of each state corresponding to it, a new state is selected as the updated current state; The probability corresponding to the terminal state in the state probability transfer matrix is ​​updated according to a predetermined strategy.

7. The method according to claim 6, characterized in that The predetermined strategy includes: The probability of the terminal state increases with each cycle in a linear or nonlinear manner; Or, when the length of the conversation list is greater than a preset length, the probability of the termination state increases with each cycle in a linear or nonlinear manner; Alternatively, when the length of the conversation list is greater than a preset length, the probability of the termination state is increased with each cycle in a linear or nonlinear manner, and when the probability of the termination state reaches a preset probability, the increase stops.

8. A method for training a dialogue model, characterized in that: The method comprises: Acquire multiple groups of conversation data; the conversation data is generated by the method according to any one of claims 1 to 7; The dialogue model is trained using the dialogue data to obtain a mature dialogue model.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the dialog data generation method according to any one of claims 1 to 7 and / or the dialog model training method according to claim 8 are implemented.

Citation Information

Patent Citations

  • Conversation flow chart generation method and related device

    CN116308103A

  • Text data set processing method, system and equipment and storage medium

    CN118313345A