Text processing method and device, electronic equipment and storage medium

By determining the dialogue role in human-computer dialogue and using end-to-end models trained by literary works, the problem of low dialogue quality is solved, and dialogue output and emotional communication experience that are more in line with the character are achieved.

CN119294405APending Publication Date: 2025-01-10SHANGHAI KAITUO HUANYU TECH DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311462832.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-03
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

The prior art is difficult to effectively improve the quality of dialogue in human-computer dialogue, especially due to the problem of error accumulation in non-end-to-end models and the problem of insufficient detailed character description.

Method used

By determining the dialogue roles of both parties in the human-computer dialogue process, and using the end-to-end dialogue model obtained by training in the work clips in literary works for input and output, directly generate response results to avoid error accumulation, and at the same time, using the work clips to describe them in a comprehensive and detailed manner. Character design.

Benefits of technology

It significantly improves the quality of human-computer dialogue, making the role output played by the robot more in line with its character design, and provides more realistic emotional communication and role experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119294405A_ABST
    Figure CN119294405A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a text processing method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a to-be-responded text from a user, and determining the dialogue roles played by two dialogue parties in a man-machine dialogue process according to the to-be-responded text. And meanwhile, determining a dialogue model corresponding to the dialogue role. And then, inputting the to-be-responded text into the dialogue model, and finally displaying a response result of the to-be-responded text output by the dialogue model. The dialogue model is an end-to-end model and is used for improving the model error accumulation problem of a non-end-to-end model. And meanwhile, the dialogue model can be trained by utilizing the work fragments in the literature work, so that the dialogue model learns rich role information, the response result output by the dialogue model better conforms to the man-machine interaction of the dialogue role played by the robot during man-machine interaction, and the quality of the man-machine interaction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a text processing method, device, electronic device and storage medium. Background Art

[0002] With the continuous development of artificial intelligence, users can interact with machines with conversation capabilities in different scenarios, more specifically, human-computer dialogue. In some entertainment scenarios, robots and users can play different dialogue roles, thus providing users with an immersive dialogue experience.

[0003] For example, in a game scenario, the dialogue role played by the robot can be a non-player character (NPC) in the game, and the user as a player can talk to different NPCs in the game to advance the game progress. For another example, in a reading scenario, the robot and the reader can also play the roles in the literary work to have a dialogue to enrich the reading experience.

[0004] In the above scenario, how to improve the quality of dialogue between humans and machines becomes an urgent problem to be solved. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a text processing method, device, electronic device and storage medium to improve the quality of human-computer dialogue.

[0006] In a first aspect, an embodiment of the present invention provides a text processing method, comprising:

[0007] Determine the dialogue roles played by both parties in the human-computer dialogue process according to the text to be answered from the user;

[0008] Determining a dialogue model corresponding to the dialogue role, wherein the dialogue model is trained using fragments of literary works;

[0009] The text to be responded is input into the dialogue model; and the response result of the text to be responded output by the dialogue model is displayed.

[0010] In a second aspect, an embodiment of the present invention provides a text processing device, including:

[0011] A dialogue role determination module, a dialogue model determination module, an input module and a display module;

[0012] The dialogue role determination module is used to determine the dialogue roles played by the two parties in the human-computer dialogue process according to the text to be answered from the user;

[0013] A dialogue model determination module, used to determine a dialogue model corresponding to the dialogue role, wherein the dialogue model is trained using fragments of literary works;

[0014] An input module, used for inputting the text to be responded to into the dialogue model; and

[0015] A display module is used to display the response result of the text to be responded to output by the dialogue model.

[0016] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the text processing method in the first aspect. The electronic device may also include a communication interface for communicating with other devices or a communication network.

[0017] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the text processing method as in the first aspect.

[0018] The text processing method provided by the embodiment of the present invention obtains the text to be answered from the user, and determines the dialogue roles played by the two parties in the human-computer dialogue process according to the text to be answered. At the same time, the dialogue model corresponding to the dialogue role is determined, and the text to be answered is input into the dialogue model, and finally the answer result of the text to be answered output by the dialogue model is displayed. Among them, the dialogue model required for realizing human-computer dialogue can be obtained by training using fragments of literary works.

[0019] During the human-computer dialogue process, if a non-end-to-end model is used, the errors of multiple models in the non-end-to-end model will gradually accumulate, and eventually reduce the quality of human-computer dialogue. The dialogue model in the above method is essentially an end-to-end model. The reason is that after the prompt text and the text to be answered from the user are input into the dialogue model, the dialogue model can directly output the answer result. The use of this end-to-end model can obviously improve the error accumulation problem of the non-end-to-end model, thereby improving the quality of human-computer dialogue.

[0020] In addition, in the above method, the dialogue model is trained using fragments of literary works. Compared with a limited number of artificially set keywords used to describe the character's personality, the fragments of the works can obviously describe the character's personality more comprehensively and in detail, so that the dialogue model can learn rich character information. When the user uses the dialogue model to conduct a conversation, the response results output by the model can be more in line with the personality of the dialogue role played by the robot, thereby improving the quality of human-computer dialogue. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flowchart of a text processing method provided by an embodiment of the present invention;

[0023] Figure 2 A flowchart of another text processing method provided by an embodiment of the present invention;

[0024] Figure 3 A flowchart of another text processing method provided by an embodiment of the present invention;

[0025] Figure 4 A schematic diagram of a training text creation process provided by an embodiment of the present invention;

[0026] Figure 5 A flowchart of another text processing method provided by an embodiment of the present invention;

[0027] Figure 6 A flowchart of another text processing method provided by an embodiment of the present invention;

[0028] Figure 7 A schematic diagram of a model training process provided by an embodiment of the present invention;

[0029] Figure 8 A structural schematic diagram of a text processing device provided by an embodiment of the present invention;

[0030] Fig. 9 For Figure 8 A schematic diagram of the structure of an electronic device corresponding to the text processing device provided in the illustrated embodiment. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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. 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.

[0032] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two, but does not exclude the inclusion of at least one.

[0033] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0034] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to identifying", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is identified" may be interpreted as "when determining" or "in response to determining" or "when identifying (stated condition or event)" or "in response to identifying (stated condition or event)", depending on the context.

[0035] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a product or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such a product or system. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the product or system including the elements.

[0036] Before describing in detail the methods provided by the embodiments of the present invention, the usage scenarios of the present solution may also be described:

[0037] As mentioned in the background technology, human-machine dialogue can be a dialogue between a user and another dialogue character played by a robot. For example, the dialogue character played by the robot can be an NPC in a game. It can be a virtual customer service in an online shopping scenario, a virtual teacher in an online education scenario, a virtual doctor in a medical scenario, etc.

[0038] In addition, in the new dialogue scene, that is, the dialogue scene between novel characters, users and robots can also play different dialogue roles to conduct dialogues. The dialogue roles can be characters in novels, movies, and TV series. The characters that dialogue with users can simulate the scenes and actions in the novel, so that users can feel the emotional expression and plot direction of the novel more easily. At the same time, this function also provides readers with a new way of reading, allowing readers to more intuitively feel the real emotional exchange and role experience while reading.

[0039] Different dialogue roles often have different personalities, and no matter which role the robot plays, the response output by the role to the user should be consistent with the role's own personalities, so as to ensure the quality of human-computer dialogue. In order to achieve the above effect, the text processing method provided in the following embodiments of the present invention can be used to realize human-computer dialogue.

[0040] Based on the above description, some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In addition, the following embodiments and features in the embodiments can be combined with each other if there is no conflict between the embodiments. In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.

[0041] Figure 1 The flowchart of a text processing method provided by an embodiment of the present invention is shown in FIG. The text processing method provided by an embodiment of the present invention is essentially a human-computer interaction method, so the method can be performed by a robot that provides human-computer interaction functions. It is understandable that the robot can be implemented as a virtual robot that plays a role in the conversation, or a physical robot. Figure 1 As shown, the method comprises the following steps:

[0042] S101, determining the dialogue roles played by the two parties in the human-computer dialogue process according to the text to be responded from the user.

[0043] As described in the background technology, the user can have a human-machine dialogue with the robot. Optionally, the robot can play different dialogue roles in different scenarios, such as an NPC in a game scenario, a role in a literary work in a reading scenario, and so on.

[0044] During the role-playing human-computer dialogue process, the robot can obtain the text to be answered generated by the user, and then, optionally, the robot can directly determine the dialogue roles played by the two parties in the human-computer dialogue process based on the keywords contained in the text to be answered. Optionally, the keywords contained in the text to be answered can usually be used to describe a certain role in a literary work. Taking the reading scene as an example, assuming that the text to be answered is "Wukong, what should I do?", and the keyword is "Wukong", the robot can determine that the dialogue role played by the robot can be Sun Wukong. Correspondingly, the user plays the role of Tang Monk.

[0045] S102, determining a dialogue model corresponding to the dialogue role, where the dialogue model is trained using fragments of literary works.

[0046] In practice, the dialogue model can be trained using fragments of literary works that contain dialogues between different characters.

[0047] Optionally, the robot can collect fragments of literary works corresponding to the dialogue role determined in step S101 to complete the training of the dialogue model corresponding to the dialogue role in real time, thereby obtaining the dialogue model corresponding to the dialogue role that the robot needs to play in step S101.

[0048] Optionally, a pre-trained dialogue model may be deployed in the robot, and this dialogue model may be trained using excerpts from different literary works. Using this dialogue model, the robot can play different roles in different literary works. This dialogue model is also the dialogue model corresponding to the dialogue role.

[0049] In addition, in order to ensure the effect of the dialogue model learning the character setting and the quality of the output dialogue, optionally, a fragment of a literary work can be used to train the dialogue model for the literary work, so that different literary works can have their own corresponding dialogue models. Using this dialogue model, the robot can play different roles in a literary work. In this case, the robot can further determine the dialogue model corresponding to the dialogue role from the dialogue models corresponding to different literary works.

[0050] S103, inputting the text to be responded to into the dialogue model.

[0051] S104, displaying the response result of the text to be responded to output by the dialogue model.

[0052] Next, the robot can input the text to be answered into the dialogue model corresponding to the dialogue role, so that the dialogue model can output the answer result of the text to be answered. Finally, the robot can also display the answer result of the text to be answered output by the dialogue model.

[0053] Those skilled in the art should understand that the above step S104 may also be replaced by other steps, for example, outputting the response result of the text to be responded to output by the dialogue model in the form of voice.

[0054] Following the text to be answered shown in step S101, the answer text finally displayed by the robot may be: "Master, rest assured, I will go and find out." This answer text is obviously consistent with the personality of the dialogue role played by the robot (i.e., Sun Wukong).

[0055] Optionally, the dialogue model can be a model with data generation capability, i.e., a generative model. Optionally, the generative model can include a Chat Generative Pre-trained Transformer (ChatGPT), baichuan-7B, MOSS, etc. Among them, baichuan-7B is a large-scale pre-trained language model similar to LLaMA (LargeLanguage Model Meta AI); MOSS is a Transformer-based dialogue model.

[0056] Optionally, the robot can choose to configure a dialogue model of an appropriate size based on its own hardware configuration, such as graphics card configuration and computing resources.

[0057] It should be noted that, since the response result is output by the dialogue model deployed in the robot, the dialogue role played by the robot can also be considered as the dialogue role played by the dialogue model. The specific training process of the dialogue model can refer to the relevant description in the following embodiments.

[0058] In this embodiment, the text to be answered is obtained from the user, and the dialogue roles played by the two parties in the human-computer dialogue process are determined according to the text to be answered. At the same time, the dialogue model corresponding to the dialogue role is determined, and the text to be answered is input into the dialogue model, and finally the answer result of the text to be answered output by the dialogue model is displayed. Among them, the dialogue model required for realizing human-computer dialogue can be trained using fragments of literary works.

[0059] During the human-computer dialogue process, if a non-end-to-end model is used, the errors of multiple models in the non-end-to-end model will gradually accumulate, and eventually reduce the quality of human-computer dialogue. The dialogue model in the above method is essentially an end-to-end model. The reason is that after the prompt text and the text to be answered from the user are input into the dialogue model, the dialogue model can directly output the answer result. The use of this end-to-end model can obviously improve the error accumulation problem of the non-end-to-end model, thereby improving the quality of human-computer dialogue.

[0060] In addition, in the above method, the dialogue model is trained using fragments of literary works. Compared with a limited number of artificially set keywords used to describe the character's personality, the fragments of the works can obviously describe the character's personality more comprehensively and in detail, so that the dialogue model can learn rich character information. When the user uses the dialogue model to conduct a conversation, the response results output by the model can be more in line with the personality of the dialogue role played by the robot, thereby improving the quality of human-computer dialogue.

[0061] Figure 1 In the illustrated embodiment, it has been described that the robot can directly determine the dialogue roles played by the two parties in the human-machine dialogue process according to the keywords contained in the text to be answered. In practice, however, it is possible that the keywords in the text to be answered are insufficient to uniquely determine the dialogue role to be played by the robot, or the text to be answered does not contain keywords describing the dialogue role at all, that is, the text to be answered cannot directly indicate the dialogue role played by the robot.

[0062] For the above two situations, optionally, after the user generates the text to be responded to, the robot may further output a prompt text to the user, so as to prompt the user to input a prompt text for describing the dialogue roles played by the two parties in the dialogue. Among them, the prompt text given by the robot to the user may be, for example, "Please enter the role you need me to play." Based on this, the prompt text given by the user to the robot may be "Please play the role of Tang Monk in "Journey to the West" for a plot dialogue. If you understand, please reply 'I understand'." After that, the robot can determine the dialogue roles played by the two parties in the human-computer dialogue process based on the text to be responded to and the prompt text from the user. And after determining the dialogue roles played by the two parties in the dialogue, the robot can follow the prompt text. Figure 1 The human-computer dialogue is carried out in the manner of the embodiment shown.

[0063] Optionally, the dialogue roles played by both parties can be inferred from the text to be responded to generated by the user. For example, the literary work corresponding to the text to be responded to can be inferred, and then the dialogue roles played by both parties can be inferred based on the context corresponding to the text to be responded to in the literary work.

[0064] Figure 2 The flowchart of another text processing method provided by the embodiment of the present invention is a model training method. The method provided by the embodiment of the present invention is used to train Figure 1 The dialogue model in the embodiment shown. And the model training method provided in the embodiment of the present invention can be executed by a training device. The training device can be either the robot mentioned in each embodiment of the present invention or another device independent of the robot. Figure 2 As shown, the method may include the following steps:

[0065] S201, extracting training text in the form of dialogue from the work clips.

[0066] The training device may obtain pre-collected fragments of literary works and extract training text in the form of dialogue from the fragments of the works. The literary works may include novels, dramas, essays, poems, etc., and any form of literary works may include at least one fragment of the works. Optionally, the training device may extract text describing the dialogue between different characters from the fragments of the works, that is, obtain the training text in the form of dialogue.

[0067] For example, a fragment of a novel could be:

[0068] Yang Guo laughed and said, "You and those seven stinky Taoist priests..." Guo Jing shouted, "Nonsense! Come and pay respect to the Grandmaster." Yang Guo stuck out his tongue and kowtowed to Ma Yu, Qiu Chuji and Wang Chuyi. When he came to kowtow in front of Yin Zhiping, he saw that he was young and turned to Guo Jing and asked, "Isn't this the Grandmaster? I don't think you need to kowtow." Guo Jing said, "This is Uncle Yin, kowtow quickly." Yang Guo was very reluctant, so he kowtowed as well.

[0069] Then the training text in the form of dialogue extracted by the training device can be:

[0070] Yang Guo: You and those seven stinky Taoist priests...

[0071] Guo Jing: Nonsense! Come and pay respect to the Grandmaster.

[0072] Yang Guo: This isn’t the Grandmaster? I don’t think I need to kowtow to him.

[0073] Guo Jing: This is Uncle Yin, kowtow to him quickly.

[0074] S202, training a dialogue model based on the training text in dialogue form.

[0075] The training text in the form of dialogue obtained in step S201 can also be divided into background text and reference response text.

[0076] Following the training text exemplified in step S201, the background text may include:

[0077] Yang Guo: You and those seven stinky Taoist priests...

[0078] Guo Jing: Nonsense! Come and pay respect to the Grandmaster.

[0079] Yang Guo: This isn’t the Grandmaster? I don’t think I need to kowtow to him.

[0080] Reference response text may include: "This is Uncle Yin, kowtow quickly."

[0081] It can be seen that the reference response text is the text following the background text. That is, the background text can be the text before the dialogue model outputs the predicted response text in the training text, and the text in the training text other than the background text is the reference response text.

[0082] Based on the above division, the training device can complete the training of the dialogue model using the training text. Specifically, the training device can input the training text in the form of dialogue into the dialogue model so that the dialogue model outputs the predicted response text according to the background text. The training device can perform loss calculation between the predicted response text and the reference response text, and train the dialogue model according to the loss calculation result between the two response texts.

[0083] Optionally, the loss of the two response texts may be calculated using a mean square error (MSE) function or a cross entropy error function.

[0084] In addition, in order to meet the input requirements of the dialogue model, optionally, the training device may further process the training text in the dialogue form obtained in step S201 to obtain a processing result that meets the input requirements of the dialogue model.

[0085] Specifically, the training device can perform word segmentation processing on the background text in the above training text. After that, the result of the word segmentation processing is encoded, that is, the text is converted into a vector. Optionally, the word segmentation processing can include any one of word granularity segmentation, character granularity segmentation and subword granularity segmentation. Finally, the encoding result is input into the dialogue model.

[0086] Figure 1 A variety of dialogue models are shown. In practice, optionally, the training device can choose to train a dialogue model of appropriate size based on its own hardware configuration, such as graphics card configuration and computing resources.

[0087] In this embodiment, the training device can extract training text in the form of dialogue from the work clips, and use the training text to train the dialogue model. By training the dialogue model with the training text extracted from the work clips, it is obvious that a response result that is more in line with the dialogue character setting can be obtained, thereby improving the quality of human-computer dialogue. In addition, the contents not described in detail in this embodiment and the technical effects that can be achieved can all be referred to the relevant descriptions in the above embodiments, and will not be repeated here.

[0088] It is easy to understand that a literary work may generally contain multiple characters, and these multiple characters may have intertwined dialogue relationships. That is, the training text in the form of dialogue extracted from the work fragment may describe the dialogue between at least two characters.

[0089] At this time, if the training text in the form of dialogue extracted in the above embodiment describes the dialogue between two characters, then the training text can be input into the dialogue model and directly Figure 2 The model training is performed in the manner of the embodiment shown. When the training text describes a dialogue between three or more characters, the training device can also divide the training text in the form of dialogue. Then, the dialogue model is trained using the multiple dialogue segments obtained by the division. Any dialogue segment obtained by the division describes a dialogue between two characters in a literary work. The specific training process can also be found in Figure 2 The relevant description in the illustrated embodiment will not be repeated here.

[0090] In this embodiment, it is considered that the actual human-computer dialogue process is usually conducted between two parties. Therefore, in order to make the dialogue model more suitable for such dialogues between two parties, in the model training stage, when a dialogue between at least three characters is extracted from a literary work, the training text can be split by dividing the dialogue segments to obtain a dialogue between two characters, and the model training is performed based on the training text, so as to better ensure the training effect of the dialogue model.

[0091] based on Figure 2 The text processing method shown can be based on Figure 3 The illustrated embodiment describes the model training process in more detail. Figure 3 A flowchart of another text processing method provided by an embodiment of the present invention is shown below. Figure 3 As shown, the method may include the following steps:

[0092] S301, identifying a target punctuation mark in a work segment indicating the start of a dialogue.

[0093] S302, extracting the dialogue text in the work segment according to the target punctuation marks.

[0094] The training device can identify target punctuation marks in the work segment that indicate the start of a conversation, and then extract the conversation text in the work segment based on the target punctuation marks.

[0095] Optionally, the target punctuation marks may include a colon and double quotes, etc., and the dialogue text extracted by the training device is the text after the colon or between two double quotes. Optionally, the method of extracting the dialogue text according to the target punctuation marks may be specifically as follows: the training device may extract the dialogue text according to a preset regular expression. Optionally, the regular expression may be: [^:]*: “.*?”.

[0096] Among them, [^:]* means matching zero or more characters that are not ":", and ".*?" means matching any non-\n, \r character after the left quotation mark until the right quotation mark is encountered. Therefore, the above regular expression can be used to extract sentences in the form of XXXXXX: "XXXXX" from the work fragment.

[0097] Following the work segment given in step S201, the training device can recognize the colon and double quotation marks after "Yang Guo laughed and said", and thus extract a dialogue text as "You and those seven stinky Taoist priests..." Similarly, the training device can also recognize the colon and double quotation marks after "Guo Jing shouted", and then can also extract a dialogue text as "Nonsense! Come and pay homage to the ancestor".

[0098] The final conversation text extracted by the training device can be:

[0099] You and those seven stinky Taoist priests...

[0100] Nonsense! Come and meet the Grandmaster.

[0101] Isn't this the founder? I don't think I need to kowtow to him.

[0102] This is Uncle Yin, kowtow to him quickly.

[0103] S303, determining a named entity corresponding to the dialogue text according to the text before the target punctuation mark in the work segment, where the named entity corresponds to a role that generates the dialogue text.

[0104] Next, the training device can also recognize the text before the target punctuation mark in the work segment to identify the named entity corresponding to the dialogue text, wherein the named entity corresponds to the role that generates the dialogue text.

[0105] Continuing with the work segment given in step S201: the training device can identify "Yang Guo laughed" to determine that the dialogue text "You and those seven stinky Taoists..." was produced by the character "Yang Guo", that is, it identifies that the named entity corresponding to the dialogue text is Yang Guo. Similarly, the training device can also determine that the dialogue text "Nonsense! Come and pay respect to the ancestor" was produced by the character "Guo Jing", that is, it identifies that the named entity corresponding to the dialogue text is Guo Jing.

[0106] It should be noted that step S302 and step S303 are only an illustrative execution order, and the present invention does not limit the execution order of the two. The two can be performed simultaneously, or step S303 can be performed first and then step S302.

[0107] S304, creating a training text in a dialogue form according to the dialogue text and the named entities.

[0108] Finally, optionally, the training device may directly combine the conversation text and the named entities into a training text as shown in step S201.

[0109] During the model training process, in order to enable the dialogue model to better learn the character's personality, optionally, for the dialogue text extracted in step S302 and the named entities determined in step S303, the training device can further perform the following replacement processing to obtain the training text in dialogue form.

[0110] Specifically, the training device may first obtain the prompt text, and then add identification information to the named entity corresponding to the dialogue text according to the prompt text, wherein the identification information includes any party in the human-computer dialogue, to obtain the addition result, and finally create a training text in the form of a dialogue from the dialogue text and the addition result. The prompt text describes the dialogue roles played by the two parties in the human-computer dialogue process.

[0111] The prompt text may be "Please play the role of Guo Jing in The Return of the Condor Heroes and have a dialogue about the plot. If you understand, please reply 'I understand'". After step S302 and step S303, the text obtained is:

[0112] Yang Guo: You and those seven stinky Taoist priests...

[0113] Guo Jing: Nonsense! Come and pay respect to the Grandmaster.

[0114] Yang Guo: This isn’t the Grandmaster? I don’t think I need to kowtow to him.

[0115] Guo Jing: This is Uncle Yin, kowtow to him quickly.

[0116] The training device can add identification information before "Guo Jing" in the above text. <bot> ”, <bot>Indicates the robot, indicating that the dialogue role played by the robot is Guo Jing; and adds identification information before "Yang Guo" in the dialogue text. <human> ”, <human>Represents the user, indicating that the dialogue role played by the user is Yang Guo.

[0117] The training text finally created can be expressed as follows:

[0118] <human>:Please play the role of Guo Jing in The Return of the Condor Heroes and have a dialogue with him. If you understand, please reply "I understand".

[0119] \n <bot>:Understood.

[0120] \n <human>Yang Guo: You and those seven stinky Taoist priests...

[0121] \n <bot>Guo Jing: Nonsense! Come and pay respect to the Grandmaster.

[0122] \n <human>Yang Guo: This isn’t the Grandmaster? I don’t think I need to kowtow to him.

[0123] \n <bot>Guo Jing: This is Uncle Yin, kowtow to him quickly.

[0124] Figure 3 The creation method of the training text in the embodiment shown can also be combined with Figure 4 understand.

[0125] In this embodiment, the training device can first extract the dialogue text in the work segment according to the target punctuation mark, and then determine the named entity corresponding to the dialogue text according to the text before the target punctuation mark. Then, add identification information to the named entity corresponding to the dialogue text, and create a training text in the form of dialogue according to the dialogue text and the addition result. In addition, the contents not described in detail in this embodiment and the technical effects that can be achieved can all be referred to the relevant descriptions in the above embodiments, and will not be repeated here.

[0126] In practice, human-computer dialogue is usually initiated by the user, that is, the user first generates the text to be answered, and the robot then gives the answer result. The training text used in the training process of the dialogue model must also meet the above requirements, that is, in the training text, the role that generates the first sentence can be the dialogue role played by the user, rather than the dialogue role played by the dialogue model. Therefore, for the dialogue text extracted in the above embodiments, when the first sentence in the dialogue text is generated by the dialogue role played by the dialogue model, the training device can intercept the dialogue text according to the dialogue role played by the dialogue model to ensure that the first sentence in the remaining dialogue text after interception is not generated by the dialogue role played by the dialogue model. Further, the training device can create a training text in the form of a dialogue based on the remaining dialogue text and the replacement result.

[0127] For example, suppose the dialogue model is to play the role of "Yang Guo". Figure 3 The extracted dialogue text in the illustrated embodiment:

[0128] You and those seven stinky Taoist priests...

[0129] Nonsense! Come and meet the Grandmaster.

[0130] This person is not the ancestor, right? I don't think I need to kowtow to him.

[0131] This is Uncle Yin, kowtow to him quickly.

[0132] The training device can delete the line "You and those seven stinky Taoist priests..." to get the remaining dialogue text. Figure 3 The replacement process is performed in the manner of the illustrated embodiment to create training text.

[0133] In this embodiment, by intercepting the dialogue text, it can be ensured that the training scenario of the model is consistent with the usage scenario of the model, and the interference caused by the previous text of the remaining text generated by other characters in the training text to the predicted response text output by the dialogue model can be improved.

[0134] In practice, a piece of work may include not only dialogue sentences but also narration text. Figure 2 The work clips in the illustrated embodiment, where "Yang Guo laughed", "Guo Jing shouted", and "Yang Guo stuck out his tongue and kowtowed to Ma Yu, Qiu Chuji, and Wang Chuyi" are all narration texts. And the narration sentences are used to correspond to the dialogue texts one by one. It can be seen that the narration texts can be used to reflect the character's actions, such as body posture and / or expression. These narration texts can also indirectly reflect the character's personality. And the narration text can usually appear before the dialogue begins.

[0135] Therefore, in order to further improve the training effect of the dialogue model, the training device can also train the dialogue model based on the training text and narration text in the form of dialogue at the same time. Figure 5 The flowchart of another text processing method provided by the embodiment of the present invention is as follows. This method is essentially a model training method. Figure 5 As shown, the method may include the following steps:

[0136] S401, extracting training text in the form of dialogue from the work clips.

[0137] The execution process of step S401 is similar to the corresponding steps of the above-mentioned embodiment, and can be seen in FIG. Figure 2 The relevant description in the illustrated embodiment will not be repeated here.

[0138] S402, extracting the character's narration text from the work clip, where the narration text describes the body posture and / or expression of the character having the dialogue.

[0139] For extracting the narration text, the training device may first identify the target punctuation mark in the work clip that reflects the beginning of the dialogue. Then, the training device may determine the text before the target punctuation mark in the work clip as the narration text and extract it. The narration text describes the body posture and / or expression of the character who generates the dialogue.

[0140] And considering the correspondence between the narration text and the dialogue text, optionally, the narration text can be a sentence starting from the target punctuation mark, located before a dialogue sentence and closest to the dialogue sentence.

[0141] Following the work segment given in step S201, the training device can extract the narration text "Yang Guo laughs" from it according to the target punctuation marks, and the narration text corresponds to the dialogue text "You and those seven stinky Taoists...".

[0142] S403, training a dialogue model based on the training text in dialogue form and the narration text.

[0143] Afterwards, the training device can also train the dialogue model based on the dialogue-style training text and the narration text. Continuing with the above example, the dialogue-style training text and the narration text can form the following text:

[0144] Yang Guo: You and those seven stinky Taoist priests... (Yang Guo laughs)

[0145] Guo Jing: Nonsense! Come and pay respect to the Grandmaster.

[0146] Yang Guo: This isn’t the Grandmaster? I don’t think I need to kowtow to you. (Turning to Guo Jing)

[0147] Guo Jing: This is Uncle Yin, kowtow to him quickly.

[0148] Optionally, the training device can also perform Figure 3 The replacement process in the illustrated embodiment. And for the specific training process of the dialogue model, please refer to the description in the above-mentioned related embodiments, which will not be repeated here.

[0149] In this embodiment, in the training process of the dialogue model, not only the training text in the form of dialogue is used, but also the narration text. The input of the narration text is equivalent to adding the body posture of the dialogue character during the dialogue, which can more comprehensively reflect the personality of the dialogue character, so that the dialogue model can learn richer personality, thereby more accurately outputting the response results and improving the quality of human-computer dialogue. In addition, the contents not described in detail in this embodiment and the technical effects that can be achieved can all be referred to the relevant descriptions in the above embodiments, and will not be repeated here.

[0150] In practice, the dialogue model must ensure that the output response results meet the persona and are semantically logical. In other words, the dialogue model needs to have general capabilities such as text understanding and reasoning on the basis of supporting multiple personas. When using training text extracted from literary works to train the dialogue model, it is possible that the dialogue model will have a large-scale forgetting problem, thus affecting the dialogue model's dialogue ability.

[0151] In order to improve the above-mentioned large-scale forgetting problem and ensure the dialogue ability of the dialogue model, we can use Figure 6 Model training is performed in the manner of the illustrated embodiment. Figure 6 A flowchart of another text processing method provided by an embodiment of the present invention is shown below. Figure 6 As shown, the method may include the following steps:

[0152] S501, extracting training text in the form of dialogue from the work clips.

[0153] The execution process of step S501 is similar to the corresponding steps of the above-mentioned embodiment, and can be seen in FIG. Figure 2 The relevant description in the illustrated embodiment will not be repeated here.

[0154] S502, obtaining other texts whose semantics are irrelevant to the literary work.

[0155] S503, training a dialogue model based on the training texts and other texts extracted from the literary works.

[0156] The training device can obtain other texts that are semantically unrelated to the literary work. The other texts are not limited to those in the literary work or in the form of dialogues, but can be content in different text forms collected by different means. The other texts are used to maintain the general capabilities of the dialogue model.

[0157] Afterwards, the training device may train the dialogue model based on the dialogue-style training text and other texts. Optionally, the ratio of the dialogue-style training text to the other texts may be 1:1.

[0158] In this embodiment, the dialogue model is trained with the help of training texts extracted from literary works and other texts unrelated to the literary works, so that the dialogue model can learn the personality of the characters in the literary works while ensuring general capabilities, thereby ensuring high-quality human-computer dialogue effects when the dialogue model is used subsequently.

[0159] It should be noted that the above Figure 2 to Figure 6 Based on the training method of the embodiment shown, in order to further improve the training effect of the dialogue model, in the process of training the dialogue model, the training text used can also include dialogue training text, narration text and other text. Figure 7 The structural diagram of the model training process is shown. In addition, the specific training process of the dialogue model can refer to the description in the above embodiments, which will not be repeated here.

[0160] The text processing methods provided in the above embodiments of the present invention may be described below by taking a reading scenario as an example.

[0161] Users can have conversations with the robot and produce the following dialogues:

[0162] User: It’s getting late, let’s find a place to stay.

[0163] Robot: Master, this place is not safe and we cannot stay here.

[0164] User: Wukong, what should I do?

[0165] At this time, the robot obtains the text to be answered as "Wukong, what should I do?". The robot can also determine from the text to be answered that the dialogue role played by the robot is "Tang Monk" and the dialogue role played by the user is "Sun Wukong". At the same time, the robot can also determine the dialogue model applicable to "Journey to the West" based on the text to be answered. After that, the robot inputs the text to be answered into the dialogue model, and finally the dialogue model can output "Master, don't worry, I will go and find out", and the response result can also be displayed in the interface.

[0166] The dialogue model may be trained using fragments of literary works. The specific training process may be found in the descriptions of the above embodiments and will not be described in detail here.

[0167] In addition, the processes not described in detail in this embodiment and the technical effects that can be achieved can be found in Figure 1 to Figure 7 Related description in the illustrated embodiment.

[0168] The text processing apparatus of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these text processing apparatuses can be configured using commercially available hardware components through the steps taught in this solution.

[0169] Figure 8 A structural diagram of a text processing device provided by an embodiment of the present invention is shown in FIG. Figure 8 As shown, the device may include:

[0170] The dialogue role determination module 11 is used to determine the dialogue roles played by the two dialogue parties in the human-computer dialogue process according to the text to be responded to from the user.

[0171] The dialogue model determination module 12 is used to determine the dialogue model corresponding to the dialogue role, and the dialogue model is trained using work fragments in literary works.

[0172] The input module 13 is used to input the text to be responded to into the dialogue model.

[0173] The display module 14 is used to display the response result of the text to be responded to output by the dialogue model.

[0174] Those skilled in the art should understand that the display module 14 may be replaced by other modules, for example, a voice module for outputting the response result of the text to be responded to output by the dialogue model in the form of voice.

[0175] Optionally, the device further comprises: a dialogue text extraction module 15, which is used to extract training text in the form of dialogue from the work fragment.

[0176] The training module 16 is used to train the dialogue model according to the training text in the dialogue form.

[0177] Optionally, the dialogue text extraction module 15 is used to identify target punctuation marks in the work segment that indicate the beginning of a dialogue; extract the dialogue text in the work segment based on the target punctuation marks; determine the named entity corresponding to the dialogue text based on the text located before the target punctuation marks in the work segment, the named entity corresponding to the character that generates the dialogue text; and create a training text in the dialogue form based on the dialogue text and the named entity.

[0178] Optionally, the dialogue text extraction module 15 is used to obtain a prompt text, which describes the dialogue roles played by each party in the human-computer dialogue process; according to the prompt text, add identification information to the named entity corresponding to the dialogue text, and the identification information includes any party in the human-computer dialogue to obtain an added result; according to the dialogue text and the added result, create a training text in the dialogue form.

[0179] Optionally, the dialogue text extraction module 15 is further used to intercept the dialogue text according to the dialogue role played by the robot described in the prompt text to obtain the remaining dialogue text; create a training text in the dialogue form according to the remaining dialogue text and the replacement result, and generate a dialogue role in the first text of the remaining dialogue text that is different from the dialogue role played by the robot.

[0180] Optionally, the training module 16 is used to divide the training text in dialogue form into at least two dialogue segments if the training text in dialogue form describes a dialogue between at least three characters in the literary work, and any dialogue segment describes a dialogue between two characters in the literary work; and train the dialogue model based on the dialogue segments.

[0181] Optionally, the training module 16 is used to perform word segmentation on the background text in the training text in the dialogue form; encode the word segmentation; input the encoding result into the dialogue model so that the dialogue model outputs the predicted response text of the background text; and train the dialogue model according to the loss calculation result between the predicted response text and the reference response text, wherein, in the training text in the dialogue form, the reference response text is the context of the background text.

[0182] Optionally, the device further comprises: a narration text extraction module 17, which is used to extract the narration text of the character from the work clip, wherein the narration text describes the body posture and / or expression of the character who generates the dialogue.

[0183] The training module 16 is used to train the dialogue model according to the dialogue-style training text and the narration text.

[0184] Optionally, the training module 16 is used to obtain other texts whose semantics are irrelevant to the literary work; and train the dialogue model based on the training text and the other text extracted from the literary work.

[0185] Figure 8 The device shown can perform Figures 1 to 7 For the method of the embodiment shown in the figure, the part not described in detail in this embodiment can be referred to Figures 1 to 7 The implementation process and technical effects of this technical solution refer to Figures 1 to 7 The description in the illustrated embodiment will not be repeated here.

[0186] The above describes the internal functions and structure of the human-computer interaction device. In a possible design, the structure of the human-computer interaction device can be implemented as an electronic device, such as Fig. 9 As shown, the electronic device may include: a processor 21 and a memory 22. The memory 22 is used to store the electronic device to perform the above Figures 1 to 7 The program of the text processing method provided in the illustrated embodiment, the processor 21 is configured to execute the program stored in the memory 22 .

[0187] The program includes one or more computer instructions, wherein the one or more computer instructions can implement the following steps when executed by the processor 21:

[0188] Determine the dialogue roles played by both parties in the human-computer dialogue process according to the text to be answered from the user;

[0189] Determining a dialogue model corresponding to the dialogue role, wherein the dialogue model is trained using fragments of literary works;

[0190] Inputting the text to be responded to into the dialogue model;

[0191] Display the response result of the text to be responded to output by the dialogue model.

[0192] Optionally, the processor 21 is further configured to execute the aforementioned Figures 1 to 7 All or part of the steps in the illustrated embodiments.

[0193] The structure of the electronic device may further include a communication interface 23 for the electronic device to communicate with other devices or a communication network.

[0194] In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used by the above electronic device, which includes instructions for executing the above Figures 1 to 7 The program involved in the text processing method in the method embodiment shown.

[0195] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / bot> < / human> < / bot> < / human> < / bot> < / human> < / human> < / human> < / bot> < / bot>

Claims

1. A text processing method, characterized in that: include: Determine the dialogue roles played by both parties in the human-computer dialogue process according to the text to be answered from the user; Determining a dialogue model corresponding to the dialogue role, wherein the dialogue model is trained using fragments of literary works; Inputting the text to be responded to into the dialogue model; Display the response result of the text to be responded to output by the dialogue model.

2. The method according to claim 1, characterized in that The method further comprises: extracting training text in the form of dialogue from the work fragment; The dialogue model is trained according to the training text in the dialogue form.

3. The method according to claim 2, characterized in that The step of extracting a training text in a dialogue form from the work fragment comprises: identifying a target punctuation mark in the piece of work indicating the beginning of dialogue; Extracting the dialogue text in the work segment according to the target punctuation mark; Determining, based on the text before the target punctuation mark in the work segment, a named entity corresponding to the dialogue text, wherein the named entity corresponds to a character that generates the dialogue text; A training text in the form of a dialogue is created according to the dialogue text and the named entities.

4. The method according to claim 3, characterized in that The step of creating the training text in the dialogue form according to the dialogue sentences and the named entities includes: Obtaining a prompt text, wherein the prompt text describes the dialogue roles played by the two parties in the human-computer dialogue process; According to the prompt text, adding identification information to the named entity corresponding to the dialogue text, the identification information including any party in the human-computer dialogue, to obtain an added result; A training text in the form of a dialogue is created according to the dialogue text and the added result.

5. The method according to claim 4, characterized in that The step of creating the training text in the dialogue form according to the dialogue text and the added result includes: According to the dialogue role played by the robot described in the prompt text, intercepting the dialogue text to obtain the remaining dialogue text; A training text in the form of a dialogue is created based on the remaining dialogue text and the added result, and the role of the first text in the remaining dialogue text is different from the dialogue role played by the robot.

6. The method according to any one of claims 2 to 5, characterized in that The step of training the dialogue model according to the training text in the dialogue form includes: If the training text in the form of dialogue describes a dialogue between at least three characters in the literary work, dividing the training text in the form of dialogue into at least two dialogue segments, each dialogue segment describing a dialogue between two characters in the literary work; The dialogue model is trained according to the dialogue fragment.

7. The method according to any one of claims 2 to 5, characterized in that The step of training the dialogue model according to the training text in the dialogue form includes: Performing word segmentation processing on the background text in the training text in the dialogue form; Encoding the word segmentation process; Inputting the encoding result into the dialogue model so that the dialogue model outputs a predicted response text of the background text; The dialogue model is trained based on the loss calculation result between the predicted response text and the reference response text, wherein, in the training text in the dialogue form, the reference response text is the context of the background text.

8. The method according to any one of claims 2 to 5, characterized in that Before training the dialogue model according to the training text in the dialogue form, the method further includes: Extracting a character's narration text from the work clip, the narration text describing the body posture and / or expression of the character producing the dialogue; The step of training the dialogue model according to the training text in the dialogue form includes: The dialogue model is trained according to the training text in the dialogue form and the narration text.

9. The method according to any one of claims 2 to 5, characterized in that The step of training the dialogue model according to the training text in the dialogue form includes: Access to other texts that are semantically unrelated to the literary work in question; The dialogue model is trained based on the training text and the other text extracted from the literary work.

10. A text processing device, characterized in that: include: A dialogue role determination module is used to determine the dialogue roles played by the two parties in the human-computer dialogue process according to the text to be answered from the user; A dialogue model determination module, used to determine a dialogue model corresponding to the dialogue role, wherein the dialogue model is trained using fragments of literary works; An input module, used for inputting the text to be responded to into the dialogue model; as well as A display module is used to display the response result of the text to be responded to output by the dialogue model.

11. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the text processing method as described in any one of claims 1 to 9.

12. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the text processing method according to any one of claims 1 to 9.