Text response method and device, computer equipment and storage medium

The pre-trained text normalization model processes the text input by the user, generates standardized text and inputs it into the language model, which solves the problem of understanding errors in large-scale language models when handling rhetorical texts, and significantly improves the accuracy of the response results.

CN119150882APending Publication Date: 2024-12-17TCL TECHNOLOGY GROUP CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310724042.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-16
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

The existing large-scale language model is prone to errors in understanding when processing text input by users carrying rhetorical techniques, resulting in inaccurate response results.

Method used

The text to be processed using a pre-trained text normalization model, generates the standard text, and inputs it to the language model so that the language model can understand user intentions more accurately. The method includes obtaining the pending text, acquiring the target text normalization model based on the scene domain information, normalizing the to be processed text, and inputting the normative text into the language model to generate the response text.

Benefits of technology

By standardizing text input, the language model's understanding of user intentions is improved and the accuracy of response results is significantly improved, especially when dealing with texts containing rhetorical techniques.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150882A_ABST
    Figure CN119150882A_ABST
Patent Text Reader

Abstract

The invention provides a text response method and device, computer equipment and a storage medium. The method comprises the steps of obtaining a to-be-processed text; processing the to-be-processed text according to the text standardization model to obtain a standard text corresponding to the to-be-processed text; and inputting the standard text into a preset language model to obtain a response text corresponding to the to-be-processed text. According to the text response method provided by the embodiment of the invention, the to-be-processed text is processed on the basis of the text standardization model to obtain the standard text, and then the standard text is input into the preset language model, so that compared with the to-be-processed text, the text description in the standard text is more standardized, and when the text description is input into the language model for processing, the text description is more accurate. And the language model can understand the intention of the user more easily, so that the corresponding response information can be output more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of text processing, and in particular to a text response method, apparatus, computer equipment and storage medium. Background Art

[0002] With the rise of AIGC (AI generated content) technology, people are keen to use various AI tools for creation. For example, common AI tools include various chat tools based on LLM (Large Language Model) and so on.

[0003] However, due to factors of the model itself, such large-scale language models may not be able to accurately understand the text entered by the user. In particular, when the user enters some text containing rhetoric, the language model often understands the literal meaning of the text, resulting in incorrect output results of the model. Summary of the invention

[0004] Based on this, it is necessary to provide a text response method, device, computer equipment and storage medium to address the above technical problems, so as to solve the problem of inaccurate response results of existing language models when processing partial text input by users.

[0005] In a first aspect, the present application provides a text answering method, comprising:

[0006] Get the text to be processed;

[0007] Processing the text to be processed according to the text normalization model to obtain a normalized text corresponding to the text to be processed;

[0008] The standard text is input into a preset language model to obtain a response text corresponding to the text to be processed.

[0009] As a feasible embodiment of the present application, the processing of the to-be-processed text according to the text normalization model to obtain the standard text corresponding to the to-be-processed text includes:

[0010] According to the scene domain information corresponding to the text to be processed, a target text normalization model corresponding to the scene domain information is obtained; the target text normalization model is obtained by training based on the training text corresponding to the scene domain information;

[0011] The text to be processed is processed according to the target text normalization model to obtain a normalized text corresponding to the text to be processed.

[0012] As a feasible embodiment of the present application, the step of inputting the standard text into a preset language model to obtain a response text corresponding to the text to be processed includes:

[0013] Inputting the text to be processed into a preset language model for processing to obtain a first response text, and inputting the standard text into the language model for processing to obtain a second response text;

[0014] According to the similarity between the first response text and the second response text, at least one of the first response text and the second response text is determined as the response text corresponding to the text to be processed.

[0015] As a feasible embodiment of the present application, the step of determining at least one of the first response text and the second response text as the response text corresponding to the text to be processed according to the similarity between the first response text and the second response text includes:

[0016] If the similarity between the first response text and the second response text is greater than a preset similarity threshold, determining the first response text as the response text corresponding to the text to be processed;

[0017] If the similarity between the first response text and the second response text is less than a preset similarity threshold, the second response text is determined as the response text corresponding to the text to be processed.

[0018] As a feasible embodiment of the present application, the text normalization model is obtained through the following steps:

[0019] Get training text;

[0020] Determine the target word in the training text based on the part-of-speech tagging information of each word in the training text and / or a preset named entity recognition model;

[0021] Processing the target words in the training text to obtain label text corresponding to the training text;

[0022] A text normalization model is generated based on the training text and the label text training.

[0023] As a feasible embodiment of the present application, the training and generating of a text normalization model based on the training text and the label text includes:

[0024] Training the pre-trained model based on the first training text in the training text and the first label text in the label text to generate an initialization model;

[0025] Based on the output text obtained by inputting the second training text in the training text into the initialization model and the second label text in the label text, training the preset initialization scoring model to generate a target scoring model;

[0026] The preset initial normalization model is trained based on the initialization model and the target scoring model to obtain a text normalization model.

[0027] As a feasible embodiment of the present application, the text to be processed is processed according to the pre-trained text normalization model to obtain the normalized text corresponding to the text to be processed, including:

[0028] According to the scene domain information corresponding to the text to be processed, a target text normalization model corresponding to the scene domain information is obtained; the target text normalization model is obtained by training based on the training text corresponding to the scene domain information;

[0029] The text to be processed is processed according to the target text normalization model to obtain a normalized text corresponding to the text to be processed.

[0030] As a feasible embodiment of the present application, before the step of processing the text to be processed according to the text normalization model to obtain the standard text corresponding to the text to be processed, the method further includes:

[0031] Performing semantic recognition processing on the text to be processed to obtain part-of-speech information of each word in the text to be processed;

[0032] If the text to be processed contains words to be standardized whose part of speech information is the target part of speech, the step of processing the text to be processed according to the text normalization model to obtain a standardized text corresponding to the text to be processed is performed.

[0033] In a second aspect, the present application provides a text response device, comprising:

[0034] An acquisition module is used to obtain the text to be processed;

[0035] A processing module, used for processing the text to be processed according to a text normalization model to obtain a normalized text corresponding to the text to be processed;

[0036] The response module is used to input the standard text into a preset language model to obtain a response text corresponding to the text to be processed.

[0037] In a third aspect, the present application further provides a computer device, the computer device comprising:

[0038] one or more processors;

[0039] Memory; and

[0040] One or more applications, wherein the one or more applications are stored in the memory and are configured to execute any of the above-mentioned text answering methods by the processor.

[0041] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is loaded by a processor to execute any of the above-described text answering methods.

[0042] The text response method provided in the embodiment of the present application, after obtaining the text to be processed input by the user, will first process the text to be processed based on a trained text normalization model to obtain the standard text after the text to be processed is normalized, and then input the standard text into a preset language model. Since the standard text is obtained based on the pre-trained text normalization model for the text to be processed, the text description in the standard text is more standardized than that of the text to be processed. When it is input into the language model for processing, it is more conducive to the language model to understand the user's intention, thereby more accurately outputting the corresponding response information. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0044] Figure 1 A schematic diagram of the steps of a text answering method provided in an embodiment of the present application;

[0045] Figure 2 A schematic diagram of a process flow for processing a text to be processed based on scene domain information provided in an embodiment of the present application;

[0046] Figure 3 A schematic flow chart of the steps of synchronously inputting a text to be processed into a language model for processing to obtain a response text provided in an embodiment of the present application;

[0047] Figure 4 A schematic diagram of a step flow for determining a response text provided in an embodiment of the present application;

[0048] Figure 5 A schematic diagram of a process flow of obtaining a text normalization model based on training of a specific training text pair provided in an embodiment of the present application;

[0049] Figure 6A schematic diagram of a process flow of obtaining a text normalization model based on training text provided in an embodiment of the present application;

[0050] FIG7( a) is a schematic diagram of a model structure of an initialization model obtained through training provided in an embodiment of the present application;

[0051] FIG7( b) is a schematic diagram of a model structure of a target scoring model obtained through training provided in an embodiment of the present application;

[0052] FIG7( c ) is a schematic diagram of a model structure of a text normalization model obtained through training provided in an embodiment of the present application;

[0053] Figure 8 A schematic diagram of a process flow for processing a text to be processed based on scene domain information provided in an embodiment of the present application;

[0054] Fig. 9 A schematic diagram of the structure of a text response device provided in an embodiment of the present application;

[0055] Fig.10 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0057] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0058] In the description of the present application, the word "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.

[0059] To facilitate understanding of the text response method provided in the embodiment of the present application, the application scenario of the text response method provided in the embodiment of the present application is first described. Specifically, the text response method provided in the embodiment of the present application is mainly applied to the scenario where the user uses a large-scale language model, wherein the user uses the large-scale language model, and usually enters the text information that the user wants to process in the input bar, that is, the chat box. After the text information is input into the large-scale language model for processing, the corresponding response content will be generated in the corresponding response bar in a generative manner. For example, for the question-type text information raised by the user, the language model can generate the corresponding answer content, or for the request-type text information raised by the user, the language model can generate the content corresponding to the request.

[0060] However, in actual application, it is found that for some texts input by users, especially for texts input by users that contain rhetoric, for example, when the user inputs "There is always chaos at home, what should I do?", the language model often understands the literal meaning. For example, it understands the user's input as "The chickens in the user's home are flying everywhere, and the dogs are running around, and the user cannot manage these animals", and may thus give suggestions on how to manage these animals, which means that it is unable to make an accurate response.

[0061] In order to solve the above problems, the embodiment of the present application provides a text response method, which uses a pre-trained text normalization model to properly process the text input by the user into a normalized standard text during the user's use of the language model, thereby ensuring that the subsequent language model can more accurately understand the user's intention through the standard text, thereby providing a more accurate response result. Specifically, the text response method is usually installed in a text response device in the form of a computer program, and the text response device is usually set in a computer device in the form of a processor. The text response device in the computer device executes the text response method provided in the embodiment of the present application by running the computer program corresponding to the text response method.

[0062] like Figure 1 As shown, Figure 1 A flowchart of a text answering method provided in an embodiment of the present application, specifically, comprising steps S110 to S130:

[0063] S110, obtaining the text to be processed.

[0064] In the embodiment of the present application, combined with the application scenario of the text answering method provided above, it can be known that the text to be processed usually refers to the text information entered by the user in the input bar of the model when using the language model. Generally speaking, the text to be processed here includes texts containing rhetoric, such as metaphors, exaggerations, etc., which are easily misunderstood by the language model, such as the aforementioned "My family is always in chaos, what should I do?", and of course, texts that do not contain rhetoric but can be understood by the language model.

[0065] S120, processing the text to be processed according to a text normalization model to obtain a normalized text corresponding to the text to be processed.

[0066] In the embodiment of the present application, the text normalization model generally refers to a model obtained by pre-training that can replace texts that are not easy to understand with modifiers, etc. with easy-to-understand normalized texts. For example, taking the aforementioned "There is always chaos at home, what should I do?" as an example, the processed text is processed based on the trained text normalization model, and the normalized text with the following content can be obtained: "The house is always messy, things are messy, clothes and daily necessities are everywhere, and people are upset. What should I do?" That is, the word "chicken flying and dog jumping" containing rhetoric in the text to be processed is processed into "messy", "things are messy", "clothes and daily necessities are everywhere", "people are upset", and other normalized descriptions that are easy for the language model to understand. Of course, the above-mentioned content is only used to describe the difference between the text to be processed and the normalized text, and is not used as a limitation on the text normalization model. In fact, the normalized text obtained by the text normalization model processing the text to be processed can be obtained by training with appropriate training samples based on actual needs.

[0067] Specifically, the text normalization model provided in the embodiments of the present application generally refers to a model that is pre-trained based on machine learning. Of course, considering that the effect of normalization processing on the text to be processed will affect the processing effect of the language model on the standard text, and affect the output of the final language model, therefore, in order to ensure the processing effect of the language model on the standard text, as a feasible embodiment of the present application, a training scheme for obtaining a text normalization model based on reinforcement learning is proposed. Specifically, by specifying the source of the training text used in the training scheme, and limiting the machine scoring reward function and loss function in the reinforcement learning process, it is possible to ensure that the trained text normalization model can achieve the effect of normalization processing on the text to be processed. For the specific implementation scheme, please refer to the subsequent Figure 5 and its explanatory contents.

[0068] Furthermore, considering that in certain specific domain scenarios, some words and sentences input by users may often have specific meanings, that is, in different specific domain scenarios, the standardized description of the same word or sentence may also be different. For example, the meaning of "leverage effect" in the financial field is completely different from that in physics. Therefore, as a feasible embodiment of the present application, in the process of training a specific text normalization model, a text normalization model corresponding to the scenario domain can be trained based on the domain scenario information of the training text and using the specific training text in the specific domain scenario information, thereby further improving the processing effect of the text normalization model on the text to be processed in the corresponding domain scenario. For specific implementation schemes, please refer to the subsequent Figure 2 and its explanatory contents.

[0069] In addition, considering that the text answering method provided in the embodiment of the present application is mainly to provide processing for some texts input by users that are easily misunderstood by the model, therefore, as a feasible embodiment of the present application, after obtaining the text to be processed input by the user, it can be determined based on text semantic recognition whether there are key words with special parts of speech in the text, so as to determine whether the text to be processed is a target text that needs to be planned and processed, so as to facilitate the subsequent normalization of the text to be processed. Specifically, semantic recognition processing is performed on the text to be processed to obtain the part-of-speech information of each word in the text to be processed, and the relevant steps are performed only when it is determined that the part-of-speech information contained in the text to be processed is the target part of speech to be standardized. For the specific implementation scheme, please refer to the subsequent Figure 7 and its explanatory notes.

[0070] Of course, in addition to the above-mentioned method based on text semantic recognition to determine whether the text to be processed is the target text that needs to be standardized, other methods can also be used to determine whether the text to be processed needs to be standardized. For example, as a common solution, an option for standardized input can be synchronously provided on the interface of the input bar that provides the language model. When the user enters the text to be processed in the input bar, the normalization of the text to be processed can be completed based on the selection instruction of the option. Of course, after the language model completes the processing of the text to be processed and obtains the corresponding output result, the normalization of the text to be processed can be completed again based on the user's feedback operation instruction on the output result.

[0071] S130, inputting the standard text into a preset language model to obtain a response text corresponding to the text to be processed.

[0072] In an embodiment of the present application, after completing the normalization processing of the text to be processed and obtaining a standard text that is easy for the language model to understand and does not contain any modification techniques, the standard text is input into the language model that the user wants to input, and a response text that is more in line with the intention of the text to be processed can be obtained.

[0073] Of course, considering that some noise may be introduced in the process of processing the text to be processed into the standard text, which may affect the accuracy of the finally generated response text, therefore, as a feasible embodiment of the present application, in the process of inputting the standard text into the preset language model for processing, the original text to be processed will also be input into the language model for processing at the same time, and finally a more accurate response text will be determined based on the processing results of the text to be processed and the processing results of the standard text. For the specific implementation scheme, please refer to the subsequent Figure 3 and its explanatory contents.

[0074] It should be noted that the language model here can be a language model that can realize human-computer dialogue provided by other Internet manufacturers in an open source or non-open source manner. Of course, considering that the model architecture, training method and training samples of the language models provided by different Internet manufacturers are different, different language models will also have different understanding capabilities of the text intentions input by users. Therefore, as a feasible embodiment of the present application, in the process of the text normalization model obtained by the aforementioned pre-training, it is also possible to train a suitable text normalization model for different language models. For example, based on the response result of a certain language model, the training text for training the text normalization model is screened out to train a text normalization model corresponding to this language model, so as to facilitate the user to use the language model in the process of human-computer dialogue. When the text input by the user is normalized and preprocessed by the corresponding trained text normalization model, it can ensure that the language model more accurately understands the text intention of the user input, thereby outputting a more accurate response result.

[0075] The text response method provided in the embodiment of the present application, after obtaining the text to be processed input by the user, will first process the text to be processed based on a trained text normalization model to obtain the standard text after the text to be processed is normalized, and then input the standard text into a preset language model. Since the standard text is obtained based on the pre-trained text normalization model for the text to be processed, the text description in the standard text is more standardized than that of the text to be processed. When it is input into the language model for processing, it is more conducive to the language model to understand the user's intention, thereby more accurately outputting the corresponding response information.

[0076] like Figure 2 As shown, Figure 2 A schematic flow chart of a process for processing a text to be processed based on scene domain information provided in an embodiment of the present application, specifically, comprising steps S210 to S220:

[0077] S210, according to the scene domain information corresponding to the text to be processed, obtaining a target text normalization model corresponding to the scene domain information.

[0078] In the embodiment of the present application, the target text normalization model is pre-trained based on the training text corresponding to the scene domain information. Specifically, the target text normalization model is usually pre-trained based on machine learning. The implementation scheme for training the target text normalization model can be the same as the aforementioned step S120. For details, refer to the subsequent Figure 5 The content provided.

[0079] Furthermore, after obtaining a text normalization model associated with the scene domain information based on training text corresponding to the scene domain information, and storing the text normalization model in a preset database in association with the scene domain information, the text response device can query the preset database based on the scene domain information corresponding to the text to be processed, thereby obtaining the target text normalization model corresponding to the scene domain information.

[0080] S220, processing the text to be processed according to the target text normalization model to obtain a normalized text corresponding to the text to be processed.

[0081] In an embodiment of the present application, since the target text normalization model is trained based on training text corresponding to the scene domain information of the text to be processed, it can better complete the normalization processing of words related to specific scene domains in the text to be processed, thereby obtaining a standardized text that is easier for the language model to understand.

[0082] like Figure 3 As shown, Figure 3 A schematic flow chart of steps for synchronously inputting a text to be processed into a language model for processing to obtain a response text is provided in an embodiment of the present application, specifically, steps S310 to S320:

[0083] S310, inputting the text to be processed into a preset language model for processing to obtain a first response text, and inputting the standard text into the language model for processing to obtain a second response text.

[0084] On the basis of the solution provided in the aforementioned step S130, the embodiment of the present application will input the original text to be processed and the standardized text after normalization into the language model for processing. Specifically, if the language model can understand the non-standard description information in the text to be processed, the language model can process the text to be processed to obtain an accurate first response result. On the contrary, if the language model cannot understand the non-standard description information in the text to be processed, the language model will output an erroneous first response result. For the standardized text, although the risk of the language model being unable to understand the non-standard description information is avoided, some noise is introduced, which will reduce the accuracy of the second response result output by the language model.

[0085] S320: According to the similarity between the first response text and the second response text, determine at least one of the first response text and the second response text as the response text corresponding to the text to be processed.

[0086] In the embodiment of the present application, combined with the aforementioned related description, it can be known that the similarity between the first response text and the second response text can, to a certain extent, characterize whether the language model has successfully identified the non-standard description information in the text to be processed. Therefore, based on the similarity between the first response text and the second response text, the more accurate one of the first response text and the second response text can be determined as the response text corresponding to the text to be processed, wherein the similarity between the first response text and the second response text can be calculated based on the cosine similarity between the feature vectors corresponding to the texts. For the specific implementation scheme, please refer to the subsequent Figure 4 and its explanatory contents.

[0087] like Figure 4 As shown, Figure 4 A schematic flow chart of a step of determining a response text provided in an embodiment of the present application, specifically, comprising steps S410 to S420:

[0088] S410: If the similarity between the first response text and the second response text is greater than a preset similarity threshold, the first response text is determined as the response text corresponding to the text to be processed.

[0089] In the embodiment of the present application, after obtaining the text feature vectors corresponding to the first response text and the second response text, the cosine similarity between the two can be used to describe the semantic similarity between the first response text and the second response text. When the semantic similarity between the first response text and the second response text is high, for example, higher than a preset similarity threshold, it can be considered that the language model can well understand the non-standard description information in the text to be processed. Therefore, in order to avoid introducing noise and reducing the accuracy of the output response result, the first response text obtained by processing the text to be processed can be selected as the final output response text.

[0090] S420: If the similarity between the first response text and the second response text is less than a preset similarity threshold, the second response text is determined as the response text corresponding to the text to be processed.

[0091] In the embodiment of the present application, different from the aforementioned step S410, when the semantic similarity between the first response text and the second response text is low, for example, lower than a preset similarity threshold, it can be considered that the language model cannot well understand the non-standard description information in the text to be processed, thereby generating an erroneous response result. Therefore, at this time, the second response text obtained by processing the standard text can be selected as the final output response text.

[0092] like Figure 5 As shown, Figure 5A flowchart of the steps for obtaining a text normalization model based on training of specific training text pairs is provided in an embodiment of the present application, which is described in detail as follows.

[0093] In an embodiment of the present application, an implementation scheme for training a text normalization model based on a supervised machine learning method is provided, wherein the supervised machine learning relies on a training sample pair consisting of a training sample and a training label. Therefore, in order to improve the training effect of the text normalization model, an implementation scheme for constructing a training sample pair for training the text normalization model is proposed, specifically, comprising the following steps:

[0094] S510, obtaining training text.

[0095] In the embodiment of the present application, the training text is usually some text containing embellishments that are not conducive to the understanding of the language model from the user's history input. Specifically, the training text can be uploaded by the user or collected based on network technology. The embodiment of the present application does not limit the method of obtaining the training text.

[0096] For example, as a feasible implementation scheme, when a user inputs a text to be processed into a language model for processing, if the user believes that the response result provided by the language model does not match the text to be processed, the user can upload the text, so that the text response device can collect the text as a training text for subsequent model training and generate a text normalization type.

[0097] Furthermore, in combination with the above-mentioned solution, it can be seen that, considering that different language models may have different abilities to understand the intention of the text input by the user, the user can also upload the language model identifier simultaneously when uploading the text. After collecting texts carrying different language model identifiers, the text response device can regard the text with the same language model identifier as the training text corresponding to this language model, and through the subsequent model training process, the text normalization type corresponding to this language model can be trained.

[0098] In addition, combined with the relevant descriptions provided above, it can be seen that text normalization models in different domain scenarios can be trained based on training texts in different domain scenarios. Therefore, as a feasible embodiment of the present application, after obtaining the training text, the training text can also be classified based on the domain scenario of the training text, and subsequent training processes can be performed separately based on the training texts in different domain scenarios to train the text normalization model for the corresponding domain scenario.

[0099] Of course, as another feasible embodiment of the present application, after obtaining the training text, usually, the training text can also be cleaned to remove the training text containing bad information.

[0100] S520, determining target words in the training text based on part-of-speech tagging information of each word in the training text and / or a preset named entity recognition model.

[0101] In the embodiment of the present application, considering that the text normalization model is mainly used to normalize the text containing modifiers that is difficult to understand into easy-to-understand text without modifiers, the training sample pairs composed of the two texts will affect the training effect of the text normalization model. Among them, since the text containing modifiers is mainly due to the inclusion of some adjectives or special proper nouns in the text, the text is easily misunderstood by the language model. Therefore, as an optional embodiment of the present application, the target words that may have confusing meanings in the training text can be determined based on the part-of-speech tagging information of each word in the training text, and / or using a preset named entity recognition model. Specifically, the part-of-speech tag information of each word in the training text can be annotated in advance through manual annotation. Of course, in the case of some training texts that have not been annotated with the part-of-speech tag information of each word, the existing named entity recognition model can also be used to identify the named entities in the training text, so as to determine the target words that may have confusing meanings in the training text. For example, taking the aforementioned "My family is in chaos, what should I do" as an example, "chicken flying and dog jumping" is the annotated adjective with modifying techniques, which will be regarded as the target word with confusing meanings in the training text.

[0102] S530: Process the target words in the training text to obtain a label text corresponding to the training text.

[0103] In the embodiment of the present application, after determining that there are target words with confusing meanings in the training text, by further processing the target words, a label text corresponding to the training text can be obtained. Specifically, as a feasible implementation scheme, in the process of processing the target words in the training text, you can choose to call the API (Application Programming Interface) of encyclopedias such as Wikipedia to perform word meaning replacement processing on the target words. For example, replace the aforementioned "chicken flying and dog jumping" with "messy", "things messy", "clothes and daily necessities everywhere", "it's annoying to see" and other descriptive texts, so as to obtain the corresponding label text.

[0104] Through the above method, the collected training text can be processed quickly and efficiently, and the corresponding label text can be generated, thereby improving the training efficiency of the text normalization model.

[0105] S540: Generate a text normalization model based on the training text and the label text training.

[0106] In the embodiment of the present application, based on the aforementioned training text and the easy-to-understand label text corresponding to the training text, the label text is regarded as the target of text normalization processing of the training text, that is, the training text and the label text form a corresponding training text pair, and the text normalization model can be further trained and generated. Specifically, for the convenience of subsequent description, the training text is recorded as q, and the label text corresponding to the training text is recorded as ε. At this time, each set of training text q and label text ε can constitute a set of training corpus pairs.<q,ε> , and these training corpora are<q,ε> This constitutes the final training corpus dataset Φ.

[0107] Specifically, as a feasible embodiment of the present application, in the process of generating a text normalization model by training the training text and the label text, the present application embodiment provides an implementation scheme for training a text normalization model based on reinforcement learning. For details, please refer to the subsequent Figure 3 and its explanatory contents.

[0108] like Figure 6 As shown, Figure 6 A flowchart of steps for obtaining a text normalization model based on training text provided in an embodiment of the present application, specifically, including steps S610 to S630:

[0109] S610: Train a pre-trained model based on a first training text in the training texts and a first label text in the label texts to generate an initialization model.

[0110] In order to improve the efficiency of model training and ensure that the model is deployed simply and quickly, the text normalization model provided in the embodiment of the present application can adopt the architecture of an existing pre-trained model. For example, as a feasible embodiment of the present application, the open source T5 (Text-to-Text Transfer Transformer, an architecture of a text pre-training model) can be used as the model framework, and some training corpus pairs in the training text, that is, the first training text q1 and the corresponding first label text ε1 in the label text, are used to initialize the weight parameters in the T5 model framework, thereby generating a corresponding initialized model.

[0111] S620, based on the output text obtained by inputting the second training text in the training text into the initialization model, and the second label text in the label text, training the preset initialization scoring model to generate a target scoring model.

[0112] Considering that reinforcement learning is a machine learning method that acts based on feedback from the environment, the training object is continuously adjusted by relying on the feedback given by the environment, such as rewards or punishments, that is, the model training can be guided by a quantized feedback function (reward function). Therefore, as a feasible embodiment of the present application, a scheme based on a scoring (reward) model as a feedback function in reinforcement learning for model training is proposed. Specifically, the target scoring model can be trained based on the difference between the output text obtained by inputting the training text into the initialization model and the label text. The specific implementation scheme is as follows:

[0113] 1) Input the second training text in the training text into the initialization model, and then input the output text obtained by inputting it into the preset initialization scoring model to obtain a first prediction score; wherein, the scoring model is used as a reward function, which is mainly used to evaluate the difference between the output result obtained by processing the training text using the initialization model and the label text. Therefore, the second training text q2 in the training text can be first input into the initialization model for processing to obtain the corresponding output text δ, and then the output text δ is input into the initialization scoring model to obtain the reward score of the output text, that is, the first prediction score, denoted as r δ . The second training text here refers to the training text other than the first training text used to train the initialization model. Specifically, as a feasible embodiment of the present application, the scoring model can adopt the last network layer of the decoding layer in the T5 model architecture provided above;

[0114] 2) Input the second label text in the label text into the initialization scoring model to obtain a second prediction score; specifically, in addition to inputting the output text obtained by inputting the second training text into the initialization model and inputting it into the preset initialization scoring model for processing, it is also necessary to input the second label text ε2 corresponding to the second training text in the label text into the initialization scoring model and obtain the corresponding reward score, that is, the second prediction score r ε ;

[0115] 3) Based on the difference between the first prediction score and the second prediction score, the initialization scoring model is updated to obtain an updated scoring model; specifically, considering that the second prediction score is obtained by inputting the second label text corresponding to the second training text into the scoring model for processing, and the first prediction score is obtained by inputting the training text into the initialization model for processing and then inputting the output text into the scoring model for processing, that is, the second prediction score is often better than the first prediction score. Therefore, the difference between the first prediction score and the second prediction score can be used as the loss function, and the gradient descent algorithm can be used to update and optimize the initialization scoring model to obtain an updated and optimized scoring model. Specifically, the loss function of the scoring model is constructed as follows:

[0116] loss = -∑log(sigmod(r ε -r δ ))

[0117] Among them, r ε The predicted score obtained by inputting the second label text ε2 into the scoring model, and r δ That is, the predicted score obtained by inputting the output text δ into the scoring model. Sigmod is an S-type function, which is a commonly used activation function in the model.

[0118] 4) Until the updated prediction score obtained by inputting the output text and the second label text into the updated scoring model meets the preset training conditions, the currently obtained scoring model is determined as the target scoring model; specifically, on the basis of the aforementioned updated scoring model, by further inputting the output text and the second label text into the updated scoring model, the corresponding updated prediction scores and can be further obtained. On this basis, when the updated prediction scores and meet the preset training conditions, for example, when the updated loss value calculated by the above-mentioned calculation loss function is less than the preset loss value, that is, when the difference between the updated prediction scores and is large enough, it can be considered that the scoring model has been trained and optimized. At this time, the currently obtained scoring model can be determined as the target scoring model to be used as the reward function for subsequent reinforcement learning.

[0119] S630: Training a preset initial normalization model based on the initialization model and the target scoring model to obtain a text normalization model.

[0120] Based on the aforementioned target scoring (reward) model that can be used as a feedback function in reinforcement learning, the embodiment of the present application further provides a reinforcement learning method based on PPO (Proximal Policy Optimization). By constructing an instance model of the initialization model as an initial normalized model, and giving the behavior provided by the initialization model and the rewards and penalties provided by the target scoring model to train the instance model, the training of the initial normalized model can be completed, thereby obtaining a text normalized model. The specific implementation scheme is as follows:

[0121] 1) Input the sample text into the initialization model to obtain the first prediction output, and input the sample text into the preset initial normalization model to obtain the second prediction output; specifically, the initial normalization model here is obtained by initializing the T5 pre-trained model based on the initialization model. By collecting the input text actually input by the user, the sample text can be obtained, and the sample text can be output to the initialization model and the initial normalization model built based on the initialization model respectively, and the first prediction output can be obtained respectively. And the second prediction output τ. Among them, the first prediction output The difference between the first prediction output τ and the second prediction output τ can describe the difference between the initial normalized model and the initialization model, ensuring that the trained normalized model does not deviate too far from the initialization model. Specifically, the first prediction output and the KL divergence between the second prediction output τ to describe the difference between the regularized model and the initialized model;

[0122] 2) Inputting the second prediction output into the target scoring model to obtain a prediction score; specifically, based on the second prediction output τ obtained above, further inputting the second prediction output τ into the target scoring model used as the reward function obtained above, the prediction score r can be obtained. τ , where the prediction score can reflect the normalization processing effect of the normalization model;

[0123] 3) According to the prediction score and the difference between the first prediction output and the second prediction output, the initial normalized model is trained to obtain an updated normalized model; specifically, based on the above, the initial normalized model can be further optimized and updated using the prediction score that can reflect the normalization processing effect of the normalized model, and the first prediction output and the second prediction output that describe the difference between the initial normalized model and the initialization model, to obtain an updated normalized model. For example, the prediction score, the first prediction output and the second prediction output are input into the following loss function to obtain the loss value Loss corresponding to the normalized model. RL :

[0124]

[0125] Among them, r τ is the prediction score, and τ are the first prediction output and the second prediction output respectively, β is the preset KL divergence coefficient, which can be set based on actual needs. RL Afterwards, the normalized model is trained using the gradient ascent algorithm to obtain an updated normalized model;

[0126] 4) After the updated prediction output and the updated prediction score obtained by inputting the sample text into the updated normalized model meet the preset training conditions, the currently obtained normalized model is determined as the text normalized model. Specifically, based on the above-mentioned updated text normalized model, by further inputting the sample text into the updated text normalized model, the corresponding updated prediction output τ′ and the updated prediction score r can be further obtained. τ ′, on this basis, when updating the prediction scores τ′ and rτ ' satisfies the preset training conditions, for example, the updated loss value Loss calculated by the above loss function RL ′ is greater than the preset loss value, it can be considered that the text normalization model has been trained and optimized. At this time, the currently obtained normalization model can be determined as the final text normalization model to be used for processing the user input text in the subsequent text response process.

[0127] To facilitate understanding of the schematic diagrams of various models provided in the training process of the embodiment of the present application, as shown in FIG. Figure 7(a) to Figure 7(c) As shown, Figure 7(a) is a schematic diagram of the model structure of a trained initialization model provided in an embodiment of the present application, Figure 7(b) is a schematic diagram of the model structure of a trained target scoring model provided in an embodiment of the present application, and Figure 7(c) is a schematic diagram of the model structure of a trained text normalization model provided in an embodiment of the present application, as described in detail below.

[0128] As shown in Figure 7(a), by inputting the training text into the encoding block (i.e., encoder block) in the T5 pre-training model, and then inputting the encoding result and the label text into the decoding block (decoder block) in the T5 pre-training model, after being processed by the fully connected layer, the output text can be obtained. Based on the difference between the output text and the label text, it can be used to complete the training of the T5 pre-training model and generate the corresponding initialization model. Specifically, for the convenience of subsequent description, the initialization model can be replaced by the PIM module.

[0129] Furthermore, in the model structure diagram of the initialization model shown in Figure 7(a), the output result obtained by inputting the training text into the initialization model (that is, the PIM module) is input into the scoring model constructed by the decoding block in the T5 pre-training model for processing, and the label text output is processed in the scoring model constructed by the decoding block in the T5 pre-training model, and different results can be obtained respectively. By training the decoding block in the T5 pre-training model based on the score loss function provided above, the final target scoring model can be obtained. For the convenience of subsequent description, the target scoring model can be replaced by the PSM module.

[0130] Furthermore, based on the above, the output results obtained by inputting the user's training text into the initialization model (PIM) and the scores obtained after inputting into the preset initialization text model and then processed by the target scoring module (PSM) are further used to calculate the RL loss function, and then the preset initialization text model is updated to obtain the final text normalization model. That is to say, the T5 pre-trained model obtained by the final training in Figure 7(c), that is, the model composed of the encoding block and the decoding block in the figure is the text normalization model.

[0131] like Figure 8 As shown, Figure 8 A schematic flow chart of a step of normalizing a text to be processed based on a semantic recognition result of the text to be processed provided in an embodiment of the present application, specifically, comprising steps S810 to S820:

[0132] S810, performing semantic recognition processing on the text to be processed to obtain part-of-speech information of each word in the text to be processed.

[0133] In the embodiment of the present application, processing the text to be processed usually refers to using a trained NLP (Natural Language Processing) related model to process the text to be processed, and as one of the most commonly used language processing methods, semantic recognition processing refers to using semantic analysis related technologies to perform part-of-speech tagging on each word in the text to be processed based on language logic, and processing the words in the text to be processed into words with nouns, verbs, adjectives, adverbs, prepositions and other part-of-speech tag information. Of course, in addition to the above-mentioned part-of-speech information, words can also carry label information such as metaphors and exaggerations. This type of label information related to rhetoric can also be considered as the part-of-speech information of the words. Specifically, the above-mentioned semantic recognition processing of the text can be implemented based on a trained neural network model. Of course, the training of the neural network model needs to rely on labeled sample text.

[0134] S820: If the text to be processed contains words to be standardized whose part of speech information is the target part of speech, the text to be processed is processed according to a text normalization model to obtain a standardized text corresponding to the text to be processed.

[0135] In the embodiments of the present application, it is found in actual scenarios that words that are generally related to parts of speech such as special nouns and adjectives, or words that involve rhetorical devices such as metaphors and exaggerations are often easily misunderstood by the language model. Therefore, these words that are easily misunderstood by the model can be considered as words to be standardized that need to be standardized. That is, after obtaining the part-of-speech information of each word in the text to be processed as mentioned above, it can be determined whether there are words with parts of speech such as special nouns and adjectives, or rhetorical devices such as metaphors and exaggerations in the text to be processed, that is, it can be determined whether the text to be processed contains words to be standardized whose part-of-speech information is these target parts of speech, so as to determine whether the text to be processed needs to be standardized. That is, when the text to be processed contains words to be standardized whose part-of-speech information is the target part of speech, the text to be processed needs to be processed according to the text normalization model to obtain the standardized text corresponding to the text to be processed.

[0136] In order to better implement the text response method provided in the embodiment of the present application, on the basis of the text response method provided in the embodiment of the present application, a text response device is also provided in the embodiment of the present application, such as Fig. 9 As shown, the text response device 900 includes:

[0137] An acquisition module 910 is used to acquire the text to be processed;

[0138] A processing module 920 is used to process the text to be processed according to a text normalization model to obtain a normalized text corresponding to the text to be processed;

[0139] The response module 930 is used to input the standard text into a preset language model to obtain a response text corresponding to the text to be processed.

[0140] In some embodiments of the present application, the processing module 920 is also used to obtain a target text normalization model corresponding to the scene domain information according to the scene domain information corresponding to the text to be processed; the target text normalization model is pre-trained based on a training text corresponding to the scene domain information; the text to be processed is processed according to the target text normalization model to obtain a normalized text corresponding to the text to be processed.

[0141] In some embodiments of the present application, the response module 930 is also used to input the text to be processed into a preset language model for processing to obtain a first response text, and input the text to be processed into the language model for processing to obtain a second response text; based on the similarity between the first response text and the second response text, at least one of the first response text and the second response text is determined as the response text corresponding to the text to be processed.

[0142] In some embodiments of the present application, the response module 930 is also used to determine the first response text as the response text corresponding to the text to be processed if the similarity between the first response text and the second response text is greater than a preset similarity threshold; if the similarity between the first response text and the second response text is less than a preset similarity threshold, determine the second response text as the response text corresponding to the text to be processed.

[0143] In some embodiments of the present application, the processing module 920 is also used to obtain training text; determine the target words in the training text based on the part-of-speech tagging information of each word in the training text, and / or a preset named entity recognition model; process the target words in the training text to obtain a label text corresponding to the training text; and generate a text normalization model based on the training text and the label text training.

[0144] In some embodiments of the present application, the processing module 920 is also used to train a pre-trained model based on the first training text in the training text and the first label text in the label text to generate an initialization model; based on the output text obtained by inputting the second training text in the training text into the initialization model, and the second label text in the label text, train a preset initialization scoring model to generate a target scoring model; based on the initialization model and the target scoring model, train a preset initial normalization model to obtain a text normalization model.

[0145] In some embodiments of the present application, the processing module 920 is also used to perform semantic recognition processing on the text to be processed to obtain the part-of-speech information of each word in the text to be processed; if the text to be processed contains words to be standardized whose part-of-speech information is the target part-of-speech, the text to be processed is processed according to the text normalization model to obtain the standardized text corresponding to the text to be processed.

[0146] The specific definition of the text response device can be found in the definition of the text response method above, which will not be repeated here. Each module in the above text response device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0147] In some embodiments of the present application, the text response device 900 can be implemented in the form of a computer program. The computer program can be used in Fig.10 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the text response device 900, for example, Fig. 9 The acquisition module 910, the processing module 920 and the response module 930 are shown. The computer program composed of various program modules enables the processor to execute the steps of the text response method of each embodiment of the present application described in this specification.

[0148] For example, Fig.10 The computer device shown can be Fig. 9 The acquisition module 910 in the text answering device 900 shown executes step S110. The computer device can execute step S120 through the processing module 920. The computer device can execute step S130 through the answering module 930. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external computer device through a network connection. When the computer program is executed by the processor, a text answering method is implemented.

[0149] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0150] In some embodiments of the present application, a computer device is provided, comprising one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the following steps:

[0151] Get the text to be processed;

[0152] Processing the text to be processed according to the text normalization model to obtain a normalized text corresponding to the text to be processed;

[0153] The standard text is input into a preset language model to obtain a response text corresponding to the text to be processed.

[0154] In some embodiments of the present application, a computer-readable storage medium is provided, which stores a computer program. The computer program is loaded by a processor, so that the processor performs the following steps:

[0155] Get the text to be processed;

[0156] Processing the text to be processed according to the text normalization model to obtain a normalized text corresponding to the text to be processed;

[0157] The standard text is input into a preset language model to obtain a response text corresponding to the text to be processed.

[0158] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0159] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0160] The above is a detailed introduction to a text response method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A text answering method, characterized in that: include: Get the text to be processed; Processing the text to be processed according to the text normalization model to obtain a normalized text corresponding to the text to be processed; The standard text is input into a preset language model to obtain a response text corresponding to the text to be processed.

2. The text response method according to claim 1, characterized in that: The step of processing the text to be processed according to the text normalization model to obtain a normalized text corresponding to the text to be processed includes: According to the scene domain information corresponding to the text to be processed, a target text normalization model corresponding to the scene domain information is obtained; the target text normalization model is pre-trained based on the training text corresponding to the scene domain information; The text to be processed is processed according to the target text normalization model to obtain a normalized text corresponding to the text to be processed.

3. The text response method according to claim 1, characterized in that: The step of inputting the standard text into a preset language model to obtain a response text corresponding to the text to be processed includes: Inputting the text to be processed into a preset language model for processing to obtain a first response text, and inputting the standard text into the language model for processing to obtain a second response text; According to the similarity between the first response text and the second response text, at least one of the first response text and the second response text is determined as the response text corresponding to the text to be processed.

4. The text response method according to claim 3, characterized in that: The step of determining at least one of the first response text and the second response text as the response text corresponding to the text to be processed according to the similarity between the first response text and the second response text includes: If the similarity between the first response text and the second response text is greater than a preset similarity threshold, determining the first response text as the response text corresponding to the text to be processed; If the similarity between the first response text and the second response text is less than a preset similarity threshold, the second response text is determined as the response text corresponding to the text to be processed.

5. The text response method according to claim 1, characterized in that: The text normalization model is obtained through the following steps: Get training text; Determine the target word in the training text based on the part-of-speech tagging information of each word in the training text and / or a preset named entity recognition model; Processing the target words in the training text to obtain label text corresponding to the training text; A text normalization model is generated based on the training text and the label text training.

6. The text response method according to claim 5, characterized in that: The generating a text normalization model based on the training text and the label text training includes: Training the pre-trained model based on the first training text in the training text and the first label text in the label text to generate an initialization model; Based on the output text obtained by inputting the second training text in the training text into the initialization model and the second label text in the label text, training the preset initialization scoring model to generate a target scoring model; The preset initial normalization model is trained based on the initialization model and the target scoring model to obtain a text normalization model.

7. The text response method according to any one of claims 1 to 6, characterized in that: Before the step of processing the text to be processed according to the text normalization model to obtain the normalized text corresponding to the text to be processed, the method further includes: Performing semantic recognition processing on the text to be processed to obtain part-of-speech information of each word in the text to be processed; If the text to be processed contains words to be standardized whose part of speech information is the target part of speech, the step of processing the text to be processed according to the text normalization model to obtain a standardized text corresponding to the text to be processed is performed.

8. A text response device, characterized in that: include: An acquisition module is used to obtain the text to be processed; A processing module, used for processing the text to be processed according to a text normalization model to obtain a normalized text corresponding to the text to be processed; The response module is used to input the standard text into a preset language model to obtain a response text corresponding to the text to be processed.

9. A computer device, characterized in that: The computer device comprises: one or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the text answering method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the text answering method according to any one of claims 1 to 7.