Text generation method and device, electronic equipment, storage medium and program product
By performing entity recognition and user data query on the text generated by the robot agent, the false information generated by the model is corrected, thereby improving the accuracy of text generation and customer trust.
Patent Information
- Application Number
- CN202510100574.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-09-23
AI Technical Summary
Robot agents may provide incorrect information when communicating with customers, misleading customers and reducing the service experience.
By performing entity recognition on the generated text, obtaining the attributes and values of the text, and querying the real values in the user data, the false information generated by the model is updated.
It improves the accuracy of text generation, avoids misleading false information, and enhances customer trust.
Smart Images

Figure CN120687546A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and in particular to a text generation method, device, electronic device, storage medium and program product. Background Art
[0002] In the service industry, it's increasingly common to replace human agents with robot agents to communicate with customers, in order to save manpower and improve response efficiency. After receiving customer input, robot agents can generate text responses to answer questions or respond to customer requests.
[0003] If the robot agent provides incorrect information to the customer during the communication process, it is likely to mislead the customer and reduce the service experience. Summary of the Invention
[0004] The embodiments of the present application provide a text generation method, device, electronic device, storage medium and program product, which can improve the accuracy of generated text content.
[0005] In a first aspect, an embodiment of the present application provides a text generation method, comprising: Inputting the first text of the first user into the model to generate text to obtain a second text; Performing entity recognition on the second text to obtain a recognition result, the recognition result including the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; querying the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; If the second value is different from the first value, the first value is updated to the second value.
[0006] In a second aspect, an embodiment of the present application provides a text generation device, comprising: A generating unit, configured to input a first text of a first user into a model to generate text, thereby obtaining a second text; a recognition unit, configured to perform entity recognition on the second text to obtain a recognition result, wherein the recognition result includes a first attribute of the second text, a second attribute of the second text, and a first value of the second attribute; a query unit, configured to query the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; An updating unit is configured to update the first value to the second value if the second value is different from the first value. In a third aspect, an embodiment of the present application provides an electronic device comprising: a processor; and a memory configured to store computer-executable instructions, wherein the computer-executable instructions, when executed, cause the processor to perform the text generation method described in the first aspect.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, implement the text generation method as described in the first aspect.
[0008] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the text generation method as described in the first aspect.
[0009] It can be seen that in the embodiment of the present application, first, the first text of the first user is input into the model for text generation to obtain the second text; then, entity recognition is performed on the second text to obtain a recognition result, which includes the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; then, the second value of the second attribute is queried in the user data of the first user based on the first attribute and the second attribute; finally, if the second value is different from the first value, the first value is updated to the second value. Considering that the second text generated by the model may include false information fabricated by the model, if the text content representing the numerical value is incorrect, it may cause serious misleading to the first user. By performing entity recognition on the second text, the first attribute of the second text, the second attribute of the second text and the first numerical value of the second attribute can be obtained. When the user data may include multiple similar attributes, the first attribute and the second attribute are used together to query the second numerical value of the second attribute in the user data of the first user. Compared with data querying only through the second attribute, this is conducive to avoiding confusion between multiple similar attributes and improving data query accuracy. The data content of the user data is more authentic and reliable than the text generated by the model. Therefore, by updating the first numerical value to the second numerical value when the first numerical value is different from the second numerical value, the authentic and reliable user data can be used to correct the false information fabricated by the model, thereby improving the accuracy of the text content generated by the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present application 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 only some embodiments described in this specification. Those skilled in the art can also derive other drawings based on these drawings without inventive work. Figure 1 A schematic diagram of an implementation environment of a text generation method provided in an embodiment of the present application; Figure 2 A processing flow chart of a text generation method provided in an embodiment of the present application; Figure 3 A processing flow chart of another text generation method provided in an embodiment of the present application; Figure 4 A processing flow chart of another text generation method provided in an embodiment of the present application; Figure 5 A schematic diagram of a text generation device provided in an embodiment of the present application; Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0011] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0012] In service scenarios, it is very common to respond to customers through text generated by robot agents.
[0013] Considering that customers are real people and their language expressions are very diverse, the same question may be asked in a variety of ways. If you respond to customers by detecting keywords, you may not understand the topics that customers care about, or you may misunderstand the customer's intentions and answer the wrong question.
[0014] The Large Language Model (LLM) has excellent natural language communication capabilities, can capture user intent well, and give responses that are very similar to real humans. It has very significant advantages and is therefore attracting more and more attention.
[0015] However, if LLM is used for robot agents, there may be the following problems: the model may fabricate false data and mislead customers during the text generation process.
[0016] Therefore, in order to solve the above problems, an embodiment of the present application provides a text generation method.
[0017] The text generation method provided in one or more embodiments of this specification may be applicable to an implementation environment of the text generation method, which implementation environment at least includes a server 101 for text generation.
[0018] The server 101 may be a single server, or a server cluster consisting of several servers, or one or more cloud servers in a cloud computing platform, for text generation.
[0019] In this implementation environment, during the text generation process, the server 101 first inputs the first text of the first user into the model to generate text and obtain a second text; then, entity recognition is performed on the second text to obtain a recognition result, which includes the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; then, based on the first attribute and the second attribute, the second value of the second attribute is queried in the user data of the first user; finally, if the second value is different from the first value, the first value is updated to the second value. Considering that the second text generated by the model may include false information fabricated by the model, if the text content representing the numerical value is incorrect, it may cause serious misleading to the first user. By performing entity recognition on the second text, the first attribute of the second text, the second attribute of the second text and the first numerical value of the second attribute can be obtained. When the user data may include multiple similar attributes, the first attribute and the second attribute are used together to query the second numerical value of the second attribute in the user data of the first user. Compared with data querying only through the second attribute, this is conducive to avoiding confusion between multiple similar attributes and improving data query accuracy. The data content of the user data is more authentic and reliable than the text generated by the model. Therefore, by updating the first numerical value to the second numerical value when the first numerical value is different from the second numerical value, the authentic and reliable user data can be used to correct the false information fabricated by the model, thereby improving the accuracy of the text content generated by the model.
[0020] Figure 2 This is a processing flow chart of a text generation method provided in an embodiment of the present application. Figure 2 The text generation method provided in this embodiment specifically includes steps S202 to S208.
[0021] Step S202: input the first text of the first user into the model to generate text, thereby obtaining a second text.
[0022] Before executing step S202 , a first text of the first user may be obtained.
[0023] The first user can be any user. The first text can be any text. The number of first texts can be one or more.
[0024] The ordinal numbers such as "first" and "second" appearing in this specification are used to distinguish different technical features and have no actual meaning and will not be elaborated below.
[0025] The first text of the first user may be a first text input by the first user, or may be a first text obtained by performing speech-to-text conversion on voice data of the first user.
[0026] In a specific implementation, the first text may be a question text. Question text refers to text used to express an inquiry, query, or request for information. Question text appears in the form of a question sentence and is intended to obtain a specific answer or information from a dialogue system, search engine, question-answering system, or other information source.
[0027] For example, the first text 1 is: What is the deadline for activity A? The first text may also be a request text. A request text is a text used to express a request, demand, or instruction. A request text takes the form of an imperative sentence and is intended to instruct the dialogue system, virtual assistant, or other information source to perform a specific action or provide a specific service.
[0028] For example, the first text 2 is: Tell me the processing conditions of business B.
[0029] The first text can also be sentimental text. Sentimental text refers to text that expresses emotions, feelings, or attitudes. Sentimental text contains explicit sentimental words, phrases, or sentences that convey the author or speaker's emotional state.
[0030] For example, the first text 3 is: Your employee C speaks so annoyingly.
[0031] The above-mentioned question text, request text and emotional text are merely examples. The first text may also be other types of text, which can be specifically configured and determined according to the actual scenario. The embodiments of this application do not limit this.
[0032] The first text is input into the model for text generation processing to obtain a second text.
[0033] Text generation refers to the use of natural language processing technology to automatically generate text content that meets grammatical and semantic requirements by learning and understanding large amounts of text data and mastering language patterns. Text generation is an important application area of natural language processing technology.
[0034] The model in the embodiments of the present application can be any language model with text generation capabilities, such as the GPT-3 (Generative Pre-trained Transformer-3) model, the Bloom model, and so on.
[0035] Language models accumulate knowledge during training. When generating text to answer user questions, they essentially leverage their own knowledge to complete the text of the question. As some language models grow to tens of billions of parameters, they become large models. This large model can create the illusion of artificial intelligence (AI) when performing text completion.
[0036] AI hallucinations occur when a language model provides seemingly plausible answers that are completely false. These inaccurate answers aren't intentional lies, but rather occur because the training data used to train the model lacks the necessary information to correctly answer the question. In some cases, the language model may explicitly indicate it doesn't know the answer, while in other cases, it may generate completely fabricated answers. This fabricated answer is what creates AI hallucinations.
[0037] On this basis, the text content of the second text may be completely true, or the second text may include a portion of false information fabricated by the text generation model.
[0038] In a specific implementation, the first text of the first user is input into the model for text generation. Before obtaining the second text, the text generation method also includes: performing intent recognition on the third text of the first user to obtain a second intent recognition result; if the second intent recognition result belongs to a preset intent set, generating a text template corresponding to the third text based on the second intent recognition result and a pre-established mapping relationship between the intent and the text template; if the second intent recognition result does not belong to the preset intent set, determining the third text as the first text.
[0039] The third text may be any text. For specific examples, please refer to the corresponding description part of the aforementioned first text.
[0040] Before performing intent recognition on the third text, the third text may be acquired first. For details, please refer to the corresponding description of acquiring the first text of the first user in the above text.
[0041] In the process of performing intent recognition on the third text of the first user and obtaining the second intent recognition result, any intent recognition method can be used, for example, identifying intent using pre-configured keywords and phrases; using a supervised learning algorithm to train a classification model to map the third text to predefined intent categories; using Bayes' theorem to calculate the probability that the third text belongs to a certain intent and selecting the intent with the highest probability as the second intent recognition result; analyzing the dependency relationships between words in the third text to identify the core structure of the third text and thus infer the intent, etc. The embodiments of the present application do not limit the intent recognition method.
[0042] A preset intent set includes one or more intents.
[0043] Each intent in the pre-defined intent set can be a risk intent. A risk intent refers to the behavioral tendency or purpose of an individual or organization in a specific situation that could lead to negative consequences or losses. Risk intent typically involves the recognition, assessment, and response strategies of potential risks, aiming to identify and prevent possible adverse consequences.
[0044] Preset intent sets can be customized based on actual scenarios. For example, in a customer service scenario, you can add "complaint" and "threat" intents to the preset intent set.
[0045] The second intent recognition result may be an intent in the preset intention set, or an intent outside the preset intention set.
[0046] The correspondence between intent and template text can be established in advance.
[0047] Template text refers to pre-designed text with a fixed structure and format.
[0048] For example, the preset intent set includes the intent Figure 1 ,meaning Figure 2 And Figure 3 . Establish a corresponding relationship in advance, which includes: Figure 1 Corresponding template text 1; meaning Figure 2 Corresponding template text 2; meaning Figure 3 Corresponding template text 3.
[0049] If the second intent recognition result belongs to the preset intent set, query processing is performed based on the second intent recognition result in the pre-established correspondence between intent and template text to obtain the template text corresponding to the second intent recognition result, that is, the text template corresponding to the third text.
[0050] If the second intent recognition result does not belong to the preset intent set, the third text is determined as the first text.
[0051] The reason why intent recognition is performed first and then the third text whose second intent recognition result does not belong to the preset intent set is determined as the first text is because we are sensitive to responding to texts with risky intentions and should try to avoid exacerbating conflicts. It is difficult to predict what reaction the text generated by the model will bring to the first user. Therefore, it is safer to use a fixed template text.
[0052] For example, when the intention is recognized that the third text has a complaint intention, a template text corresponding to the third text is determined, and the template text is used to appease the first user and guide the first user to transfer to manual service.
[0053] In addition, the third text can also be subjected to intent recognition to obtain a second intent recognition result; determine whether the second intent recognition result belongs to a preset intent set; if the second intent recognition result belongs to the preset intent set, generate a preset text; if the second intent recognition result does not belong to the preset intent set, determine the third text as the first text.
[0054] The preset text can be a custom-configured unified response. For example, the preset text is: I'm sorry I can't resolve your issue. I suggest you transfer it to manual processing.
[0055] In a specific implementation method, intent recognition is performed on the third text of the first user to obtain a second intent recognition result, including: performing entity recognition on the third text to obtain a first entity text in the third text; matching the third text with intent keywords based on the first entity text; and determining the intent keywords that match the third text as the second intent recognition result of the third text.
[0056] Named Entity Recognition (NER) is a key task in Natural Language Processing (NLP). It aims to identify meaningful entities from text and classify them into predefined categories. These entities typically include names of people, places, organizations, dates, times, currencies, percentages, and more.
[0057] Entity text refers to text containing an entity. Specifically in this implementation, each fifth entity text is a text containing an entity in the fifth text.
[0058] For example, the third text is: ABCDEFG. Entity recognition is performed on the third text to obtain the first entity text "BC" and the second entity text "EFG".
[0059] In a third text, the number of first entity texts can be one or more.
[0060] Intent keywords are specific words or phrases used to identify user intent. These keywords are often directly related to the user's intent and help the system quickly understand the user's request or purpose. Intent keywords play a vital role in intent recognition, improving the system's accuracy and responsiveness.
[0061] Based on the first entity text, the third text is matched with the intended keyword. The first entity text and the intended keyword can be compared. If the first entity text is the same as the intended keyword, it is determined that the third text matches the intended keyword; otherwise, it is determined that the third text does not match the intended keyword.
[0062] Based on the first entity text, the third text is matched with the intended keyword. Alternatively, the text similarity between the first entity text and the intended keyword is calculated. If the text similarity is less than a preset similarity threshold, it is determined that the third text matches the intended keyword; otherwise, it is determined that the third text does not match the intended keyword.
[0063] The intent keyword matching the first entity text is determined as a second intent recognition result of the third text.
[0064] In a specific implementation, the intent keyword includes a first character and a second character; the first entity text includes one character; based on the first entity text, the third text is matched with the intent keyword, including: determining the third arrangement number of the character in the first entity text in the third text; the third arrangement number represents the position information of the corresponding character in the third text; based on the second entity text, the third arrangement number of the first entity text and a preset number interval threshold, the third entity text is determined in the first entity text, and the second entity text is the first entity text with the same first character; if there is a third entity text with the same second character, it is determined that the third text matches the intent keyword; if there is no third entity text with the same second character, it is determined that the third text does not match the intent keyword.
[0065] In this implementation, entity recognition is performed on the third text to obtain the first entity text in the third text; the third text is matched with the intent keyword based on the first entity text; the intent keyword matched with the third text is determined as the second intent recognition result of the third text; wherein, in the process of matching the third text with the intent keyword based on the first entity text, the following steps are performed: determining the third arrangement number of the character in the first entity text in the third text; the third arrangement number represents the position information of the corresponding character in the third text; based on the second entity text, the third arrangement number of the first entity text and the preset number interval threshold, the third entity text is determined in the first entity text, and the second entity text is the first entity text with the same first character; if there is a third entity text with the same second character, it is determined that the third text matches the intent keyword; if there is no third entity text with the same second character, it is determined that the third text does not match the intent keyword.
[0066] In this implementation, entity recognition is performed on the third text to obtain the first entity text in the third text. Entity recognition can be performed on the third text to obtain multiple entity texts, and the first entity text is determined based on the number of characters in each entity text in the multiple entity texts; the first entity text includes one character.
[0067] For example, the third text is: ABCDEFG, and entity recognition is performed on the third text to obtain: Entity text 1: "AB", entity type 1, location information [0, 1]; Entity text 2: “D”, entity type 2, location information [3]; Entity text 3: “G”, entity type 3, location information [6].
[0068] Among them, the number of characters in entity text 1 is 2, the number of characters in entity text 2 is 1, and the number of characters in entity text 3 is 1, then entity text 2 is determined as a first entity text, and entity text 3 is determined as a first entity text.
[0069] A third permutation sequence number of a character in the first entity text in the third text is determined; the third permutation sequence number represents position information of the corresponding character in the third text.
[0070] For example, the third text is: ABCDEFG. The position information of the character "D" in the first entity text 1 in the third text can be represented by text[3], that is, the third permutation sequence number of "D" is 3; the position information of the character "G" in the first entity text 2 in the third text can be represented by text[6], that is, the third permutation sequence number of "G" is 6.
[0071] In practical applications, entity recognition operations can be performed through a pre-trained entity recognition model. Specifically, the third text is input into the pre-trained entity recognition model for entity recognition to obtain the first entity text and the third arrangement serial number of the first entity text.
[0072] For example, input the third text "I want to lodge a complaint against you" into the pre-trained entity recognition model for entity recognition, and obtain: [First entity text "lodge", text[2]], [First entity text "complaint", text[4]]. Here, text[2] indicates that the third arrangement serial number of the first entity text "lodge" is 2; text[4] indicates that the third arrangement serial number of the first entity text "complaint" is 4.
[0073] Another example, the third text is: Isn't my repayment date the Xth day of Y month? Why do you say it's the Xth day of Z month? I want to lodge a complaint against you. Input this third text into the pre-trained entity recognition model for entity recognition, and obtain: Entity text 1: "repayment date", entity type 1, text[a1, a2]; Entity text 2: "the Xth day of Y month", entity type 2, text[b1, b2]; Entity text 3: "the Xth day of Z month", entity type 2, text[c1, c2]; Entity text 4: "lodge", entity type 3, text[d1]; Entity text 5: "complaint", entity type 3, text[e1].
[0074] According to the character count of each entity text, entity text 4 can be determined as a first entity text, and entity text 5 can be determined as a first entity text.
[0075] Furthermore, it can be determined that the third arrangement serial number of the characters in the first entity text "lodge" in the third text is d1, and it can be determined that the third arrangement serial number of the characters in the first entity text "complaint" in the third text is e1.
[0076] This implementation manner takes the intention keyword including the first character and the second character as an example for exemplary illustration. In the case where the number of characters included in the intention keyword is greater than or equal to three, the corresponding description part of this implementation manner can be referred to.
[0077] In the process of determining the third entity text in the first entity text according to the second entity text, the third arrangement serial number of the first entity text, and the preset serial number interval threshold, for any one first entity text, if the difference between the third arrangement serial number of this first entity text and the third arrangement serial number of the second entity text is less than or equal to the preset serial number interval threshold and this difference is greater than 0, then this first entity text can be used as a third entity text.
[0078] In the process of determining the third entity text, the following operations can be performed: (a1) Determine a second entity text that is the same as the first character in the first entity text.
[0079] For example, the intent keyword is "complaint", the first character is "tóu", and the second character is "sù". The third text is: I want to complain about you. Entity recognition is performed on the third text, and the following 2 first entity texts are obtained: "tóu", "sù".
[0080] Among the above 2 first entity texts, the first entity text "tóu" that is the same as the first character "tóu" can be determined, and this first entity text "tóu" is used as the second entity text.
[0081] (a2) Determine the third arrangement serial number of the second entity text according to the third arrangement serial number of the first entity text and the second entity text.
[0082] The second entity text is one of the multiple first entity texts. Given the third arrangement serial numbers of each first entity text, the third arrangement serial number of the second entity text can be determined.
[0083] (a3) Determine the third entity text in the first entity text according to the third arrangement serial number of the second entity text and the preset serial number interval threshold.
[0084] The preset serial number interval threshold can be determined by the margin distance configured by the user. In the entity recognition task, the margin distance can be the distance between the predicted entity boundary and the true boundary of the entity recognition model. Specifically, the margin distance can be used to measure the difference between the predicted entity boundary of the model and the actually labeled entity boundary. In the specific embodiment of this application, the preset serial number interval threshold determined by the margin distance can be used to assist intent recognition.
[0085] For example, the intent keyword is "complaint", the first character is "tóu", and the second character is "sù". The third text is: I want to complain about you. Entity recognition is performed on the third text, and the following 2 first entity texts arranged in sequence are obtained: "tóu", "sù".
[0086] Among them, the second entity text is "投", the preset serial number interval threshold is 2. Counting backward from "投", the first character "啊" after "投" is not the first entity text. Also, the third entity text is one of the first entity texts, so the first character "啊" after "投" cannot be the third entity text. Counting backward from "投", the second character after "投" is a first entity text "诉". The third arrangement serial number of this first entity text "诉" satisfies that the difference between the third arrangement serial number of "诉" and the third arrangement serial number of "投" is less than or equal to the preset serial number interval threshold "2" and this difference is greater than 0. Therefore, the first entity text "诉" can be used as a third entity text.
[0087] If there is a third entity text that is the same as the second character, it is determined that the third text matches the intent keyword; if there is no third entity text, it can be determined that the third text does not match the intent keyword; if there is at least one third entity text and each third entity text is different from the second character, it can be determined that the third text does not match the intent keyword.
[0088] For example, the third text is: 我要投啊诉你. Among them, the second entity text is "投". According to the second entity text "投", the third arrangement serial number of the first entity text, and the preset serial number interval threshold, it is determined that there is a third entity text "诉" in the first entity text, and this third entity text "诉" is the same as the second character. Then it can be determined that the third text matches the intent keyword "投诉".
[0089] Another example, the third text is: 我在活动甲中为你投了一票. Among them, the second entity text is "投". According to the second entity text "投", the third arrangement serial number of the first entity text, and the preset serial number interval threshold, it is determined that there is no third entity text in the first entity text. Then it can be determined that the third text does not match the intent keyword "投诉".
[0090] Another example, the third text is: 我曾经投给律所简历但没有得到回复. Among them, the second entity text is "投". According to the second entity text "投", the third arrangement serial number of the first entity text, and the preset serial number interval threshold, it is determined that there is a third entity text: "律" in the first entity text, but this third entity text "律" is different from the second character "诉". Then it can be determined that the third text does not match the intent keyword "投诉".
[0091] When the first text is obtained by converting speech data into text, the first user in the speech data may have an accent, causing the first text to contain some meaningless modal particles, which in turn leads to semantic ambiguity in some parts of the first text. In this implementation, the characteristic that entity recognition can also be performed on individual characters is utilized to obtain one or more first entity texts from the third text. Then, in the process of matching the third text with the intended keywords, by configuring a preset sequence number interval threshold, the interference of meaningless modal particles in the matching of the third text and the intended keywords can be reduced, thereby improving the matching accuracy.
[0092] Step S204 : performing entity recognition on the second text to obtain a recognition result, where the recognition result includes the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute.
[0093] In the field of text processing, attributes refer to features or characteristics of text that can be used to describe, analyze, or process the text. Attributes can be content features of the text itself, or they can be statistical information, linguistic features, or other metadata extracted from the text.
[0094] Specifically in the embodiment of the present application, the first attribute can represent the characteristics of the first word in the second text, the second attribute can represent the characteristics of the second word in the second text, and the first value of the second attribute can represent the specific value of the second word in the second text.
[0095] The number of the first word in the second text may be one or more. The number of the second word in the second text may be one or more. The first word may be a pre-configured word used to assist in data query. The second word may be a word consisting of numerical data and a corresponding numerical unit.
[0096] For example, in a financial scenario, first attributes include, but are not limited to, the total repayment amount, repayment date, number of repayment periods, monthly interest rate, etc. In a consulting scenario, first attributes include, but are not limited to, event start time, event end time, product discount information, etc. In a transaction scenario, first attributes include, but are not limited to, order creation time, payment time, product price, total order amount, etc.
[0097] In addition, one or more first attributes may be pre-configured in combination with specific application scenarios.
[0098] For example, the second attribute can be a date, an amount, a resource quantity, etc.
[0099] Entity recognition is performed on the second text to obtain a first attribute of the second text, a second attribute of the second text, and a first value of the second attribute.
[0100] For example, the second text is: "Your total outstanding payment is RMB 10,000." Entity recognition is performed on the second text to obtain: the first attribute "total repayment amount" of the first word 1 "total outstanding payment"; the second attribute "amount" of the second word 1 "10,000 yuan"; and the first value "10,000" of the second attribute "amount."
[0101] For example, the second text is: "The event you inquired about ends on X month Y day." Entity recognition is performed on the second text to obtain: the first attribute "event end time" of the first term "event end date"; the second attribute "event end time" of the second term "X month Y day"; and the first value "X, Y" of the second attribute "event end time."
[0102] The text content of the second text may be real or fake. The reason for the fake text content is that the model may produce AI hallucinations in the process of generating the second text.
[0103] Entity recognition is performed on the second text to obtain a recognition result, and the second text may be input into a pre-trained entity recognition model to perform entity recognition to obtain a recognition result.
[0104] Specifically, the second text can be input into a pre-trained entity recognition model for entity recognition to obtain the entity text and the entity type of the entity text. For any entity text, if the entity type of the entity text belongs to the first entity type set, the entity type can be determined as the first attribute; if the entity type of the entity text belongs to the second entity type set, the entity type can be determined as the second attribute, and the numerical data in the entity text can be used as the first value of the second attribute.
[0105] For example, the second text "Your total repayment amount is 1,000 yuan" is input into the pre-trained entity recognition model for entity recognition, and the result is: Entity text 1: "Repayment total collection", entity type 1; Entity text 2: "1000 yuan", entity type 2.
[0106] In the case that the entity type 1 belongs to the first entity type set, the entity type 1 may be determined as a first attribute obtained from entity recognition in the second text.
[0107] In the case that entity type 2 belongs to the second entity type set, entity type 2 can be determined as a second attribute obtained by entity recognition from the second text, and the numerical data "1000" in entity text 2 "1000 yuan" can be used as the first numerical value of the second attribute "entity type 2".
[0108] The first entity type set may be pre-configured for the application scenario of the first text. For example, in a financial scenario, the first entity type set may include: total repayment amount, repayment date, number of repayment periods, monthly interest rate, etc. The second entity type set may be pre-configured for the application scenario of the first text. For example, in a financial scenario, the second entity type set may include: amount, date, ratio, etc.
[0109] The pre-trained entity recognition model may adopt a statistical model, or a neural network model based on deep learning, etc. The embodiment of the present application does not limit the model type of the pre-trained entity recognition model.
[0110] Entity recognition is performed on the second text to obtain a recognition result, or entity recognition is performed on the second text according to a pre-configured regular expression and / or dictionary to obtain a recognition result.
[0111] A regular expression (REX) is a pattern used to match character combinations within a string. It is a powerful tool widely used in tasks such as text search, replacement, validation, and extraction. A regular expression consists of common characters and special characters that define matching rules.
[0112] For example, in the process of performing entity recognition on the second text according to a pre-configured regular expression to obtain a recognition result, the regular expression can be used to match specific entity patterns, such as dates, telephone numbers, and the like.
[0113] A lexicon is a collection of words that represent a specific entity.
[0114] For example, in the process of performing entity recognition on the second text according to the pre-configured dictionary to obtain the recognition result, a predefined place name dictionary, personal name dictionary, etc. can be used to match entities in the second text.
[0115] Entity recognition is performed on the second text to obtain a recognition result. Alternatively, entity recognition can be performed on the second text through a knowledge graph to obtain a recognition result.
[0116] A knowledge graph is a graphical data structure used to represent and organize structured knowledge. It helps computers understand and reason about real-world knowledge by representing entities and their relationships in the form of a graph.
[0117] The above-mentioned entity recognition methods are merely exemplary. In the process of performing entity recognition on the second text, any other entity recognition method may be used. The specific configuration may be determined according to the actual scenario, and the embodiments of the present application are not limited thereto.
[0118] Step S206 : querying the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute.
[0119] The number of the first attributes may be one or more, the number of the second attributes may be one or more, and the number of the second attributes and the number of the first values may be the same.
[0120] When there are multiple first attributes, a third attribute associated with the second attribute can be determined from the multiple first attributes. Then, based on the second attribute and the third attribute associated with the second attribute, the second value of the second attribute can be queried in the user data of the first user.
[0121] For example, the second text is: Your total outstanding balance is RMB 10,000, RMB 1,000 is outstanding this month, and the repayment date is on X / Y.
[0122] The second text includes: The first attribute of the first term 1 "total amount to be repaid" is "total amount to be repaid"; The second attribute “amount” of the second word 1 “10,000 yuan” and the first value “10,000” of the second attribute “amount”.
[0123] The first attribute of the first word 2 "payment due this month" is "amount of repayment this month".
[0124] The second attribute “amount” of the second word 2 “1000 yuan” and the first value “1000” of the second attribute “amount”.
[0125] The first attribute "repayment date" of the first term 3 "repayment date"; The second attribute “date” of the second word 3 “X month Y day” and the first value “X, Y” of the second attribute “date”.
[0126] For the second attribute "amount" of the first word 1, the third attribute "total repayment amount" that is associated with the second attribute "amount" can be determined in the "total repayment amount", "this month's repayment amount" and "repayment date". Then, based on the second attribute "amount" and the third attribute "total repayment amount" that is associated with the second attribute, the second value of the second attribute "amount" of the first word 1 is queried in the user data of the first user.
[0127] For the second attribute "amount" of the first term 2, a third attribute "this month's repayment amount" associated with the second attribute "amount" can be determined from the "total repayment amount", "this month's repayment amount", and "repayment date". Then, based on the second attribute "amount" and the third attribute "this month's repayment amount" associated with the second attribute, the second value of the second attribute "amount" of the first term 2 is queried in the user data of the first user. In this embodiment of the present application, if the user data of the first user is authentic and reliable, the user data of the first user can be used to verify whether the text content generated by the model is authentic.
[0128] The user data may be any predetermined data related to the first user.
[0129] User data may include the transaction records of the first user. For example, user data 1 includes the transaction time, transaction item, transaction amount, order number, etc. of user 1.
[0130] The user data may also include resource lending information of the first user. For example, user data 2 includes the total amount of resources to be repaid by user 2 on the resource lending platform, overdue time, and the like.
[0131] The user data may also include the test scores of the first user. For example, user data 3 includes the score of user 3 in subject 1, the score of user 3 in subject 2, the score of user 3 in subject 3, the total score of user 3, and so on.
[0132] The above-mentioned transaction records, resource lending information and test scores are merely exemplary. The user data may also be other types of data related to the first user, which can be specifically configured and determined according to the actual scenario and is not limited in the embodiments of the present application.
[0133] Querying the second value of the second attribute in the user data of the first user based on the first attribute and the second attribute may be performed by determining a comprehensive attribute based on the first attribute and the second attribute, performing a data query in the user data of the first user based on the comprehensive attribute, and using the data query result as the second value of the second attribute.
[0134] The second value of the second attribute can be queried in the user data of the first user based on the first attribute and the second attribute. Alternatively, the user data of the first user can be filtered based on the second attribute. If the number of values in the filtered result is greater than one, the filtered result can be filtered a second time based on the first attribute, and the secondary filtering result can be used as the second value of the second attribute.
[0135] The method may further include querying the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute. Alternatively, the method may include obtaining a preset value range of the first attribute, querying the user data of the first user for a value of the second attribute based on the second attribute, and if the value of the second attribute falls within the preset value range of the first attribute, using the value of the second attribute as the second value of the second attribute. If the value of the second attribute does not fall within the preset value range of the first attribute, generating a prompt message to notify the user that the data query is abnormal.
[0136] The above step S206 can also be replaced by querying the second value of the second attribute in the business data based on the first attribute and the second attribute. This can be combined with other processing steps in the embodiment of the present application to form a new implementation.
[0137] Business data can be various data generated during the daily operations of an institution, enterprise, or organization, which reflects various aspects of business activities. There may be a corresponding relationship between the business data and the first user, or there may not be a direct relationship between the business data and the first user.
[0138] In an embodiment of the present application, when the business data is authentic and reliable, the business data can be used to verify whether the text content generated by the model is authentic.
[0139] Business data may include activity information, such as the start and end time of activity A, the content of activity A, how to participate in activity A, etc.
[0140] Business data may also include business guidance information, such as how to handle business B, how to cancel business B, and the materials required to handle business B.
[0141] The above-mentioned activity information and business guidance information are merely exemplary. Business data may also be other types of data related to a specified business, which may be specifically configured and determined according to the actual scenario and is not limited in the embodiments of the present application.
[0142] In addition, the business data in the above implementation can also be replaced by pre-configured knowledge. Knowledge can be structured information, which exists in the form of entities and their relationships.
[0143] For example, a knowledge graph in the field of mathematics is pre-configured. The knowledge graph includes multiple nodes and multiple edges, and each node describes knowledge in a mathematical field.
[0144] Query the knowledge graph for a second value of the second attribute based on the first attribute and the second attribute.
[0145] In an embodiment of the present application, when the knowledge graph is authentic and reliable, the knowledge graph can be used to verify whether the text content generated by the model is authentic.
[0146] In a specific implementation, the recognition result also includes first position information of the first attribute and second position information of the second attribute. After entity recognition is performed on the second text and the recognition result is obtained, the method also includes: determining the first arrangement number of the first character corresponding to the second attribute based on the second position information; the first arrangement number represents the position information of the first character in the second text; determining the second arrangement number of the last character corresponding to the first attribute based on the first position information; the second arrangement number represents the position information of the last character in the second text; if the difference between the first arrangement number and the second arrangement number is greater than or equal to zero and less than or equal to a preset difference threshold, and the first attribute is determined to be a third attribute that has an associated relationship with the second attribute; querying the second value of the second attribute in the user data of the first user based on the first attribute and the second attribute, including: querying the second value of the second attribute in the user data of the first user based on the second attribute and the third attribute that has an associated relationship with the second attribute.
[0147] The number of the first attribute can be one or more. The number of the second attribute can be one or more.
[0148] The first word corresponding to the first attribute may include one or more characters. The first position information of the first attribute may include an arrangement sequence number of each character in the first word.
[0149] The second word corresponding to the second attribute may include one or more characters. The second position information of the second attribute may include an arrangement sequence number of each character in the second word.
[0150] The arrangement sequence number is used to indicate the position information of the corresponding character in the second text.
[0151] For example, the second text is: Your total outstanding payment is RMB 10,000.
[0152] The second text includes the first word "total amount to be repaid" and the second word "10,000 yuan".
[0153] The first attribute of the first word is "total amount to be repaid," the second attribute of the second word is "amount," and the first value of the second word is "10000." The first position information of the first attribute may include the sequence number of each character in the first word "total amount to be repaid" in the second text: 3, 4, 5, 6, 7. The second position information of the second attribute may include the sequence number of each character in the second word "10000 yuan" in the second text: 9, 10, 11, 12, 13, 14.
[0154] Determining the first permutation number of the first character corresponding to the second attribute based on the second position information refers to determining the permutation number of the first character of the second term corresponding to the second attribute in the second text, among the multiple permutation numbers included in the second position information. For example, if the second position information of the second attribute includes the permutation numbers of each character in the second term "10000 yuan" in the second text: 9, 10, 11, 12, 13, 14, the first permutation number may be determined to be "9."
[0155] Determining the second permutation number of the last character corresponding to the first attribute based on the first position information refers to determining, among the multiple permutation numbers included in the first position information, the permutation number of the last character in the first term corresponding to the first attribute in the second text. For example, if the first position information of the first attribute includes the permutation numbers 3, 4, 5, 6, and 7 of each character in the first term "total amount to be repaid" in the second text, the second permutation number may be determined to be "7."
[0156] The preset difference threshold may be a custom-configured numerical threshold, for example, 2.
[0157] If the difference between the first arrangement number and the second arrangement number is greater than or equal to zero and less than or equal to a preset difference threshold, and the first attribute is determined to be a third attribute associated with the second attribute; based on the second attribute and the third attribute associated with the second attribute, a second value of the second attribute is queried in the user data of the first user.
[0158] For example, the preset difference threshold is 2, the first arrangement number is "9", and the second arrangement number is "7". If the difference between the first arrangement number and the second arrangement number is greater than or equal to zero and less than or equal to the preset difference threshold, the first attribute "total repayment amount" is determined as the third attribute associated with the second attribute "amount". Based on the second attribute "amount" and the third attribute "total repayment amount" associated with the second attribute, the second value of the second attribute "amount" is queried in the user data of the first user.
[0159] If the difference between the first and second arrangement numbers is less than zero, it means that the first word is located after the second word in the second text, and it can be considered that the first attribute is unrelated to the second attribute.
[0160] If the difference between the first arrangement number and the second arrangement number is greater than the preset difference threshold, it means that in the second text, although the first word is located before the second word, the first word and the second word are too far apart, and it can be considered that the first attribute is unrelated to the second attribute.
[0161] In this implementation, by determining the difference between the first arrangement number of the first character of the second word corresponding to the second attribute in the second text and the second arrangement number of the last character of the first word corresponding to the first attribute in the second text, it is possible to estimate whether the first attribute has an association relationship with the second attribute. Furthermore, in the process of data query, the second attribute and the first attribute that has an association relationship with the second attribute are used as query references together. When the first text includes multiple numerical values, the first attributes associated with each numerical value can be accurately distinguished, which is conducive to improving the accuracy of data query.
[0162] Step S208: If the second value is different from the first value, the first value is updated to the second value.
[0163] The second value is compared with the first value to obtain a comparison result. If the comparison result indicates that the second value is different from the first value, it can be determined that the model generated AI hallucinations during the generation of the second text, causing the first value to be incorrect. The first value is then updated to the second value. After the first value is updated to the second value, a fourth text can be obtained.
[0164] For example, the second text is: Your total outstanding balance is 10,000 yuan. The first value of the second attribute of the second text is "10,000" and the second value is "12,000". If the first value "10,000" is different from the second value "12,000", the first value is updated to the second value, resulting in the fourth text: Your total outstanding balance is 12,000 yuan.
[0165] In addition, if the comparison result indicates that the second value is the same as the first value, it can be determined that the model did not produce AI hallucinations in the process of generating the second text, and there is no need to perform an update operation.
[0166] In an interactive system such as a dialogue system, a chatbot, or a question-answering system, if the first text is a question text input by a first user, the fourth text may be a text generated by the interactive system to answer the question text.
[0167] In the case where the first text is generated based on the user input of the first user, after the first value is updated to the second value, a fourth text can be obtained, and then the fourth text can be returned to the first user. Alternatively, the fourth text can be subjected to text-to-speech processing to obtain voice data of the fourth text, and the voice data of the fourth text can be played to the first user.
[0168] In actual applications, when several different times / amounts appear in a sentence at the same time, different times may be confused together, or different amounts may be confused together. For example, the total amount owed "10,000 yuan" and the interest "300 yuan" are confused. These two values are both amount values. If the "10,000 yuan" in the second text is compared with the attribute value "350 yuan" of the attribute "interest" in the user data, it will obviously cause a misjudgment. In the process of entity recognition of the second text, the embodiment of the present application not only identifies the second attribute and the first value of the second attribute from the second text, but also identifies the first attribute that has an association relationship with the second attribute from the second text. Then, the first attribute and the second attribute can be combined to link the first value generated by the model with the second value in the user data. In this way, when the second text includes multiple amounts / times at the same time, the numerical confusion can be effectively reduced, and then it can be more accurately judged whether AI hallucinations have occurred during the text generation process, and the wrong numerical values can be corrected in time when AI hallucinations occur, thereby improving the accuracy of the generated text content.
[0169] In a specific implementation, the text processing method also includes: if the number of first numerical values in the recognition result is multiple and the number of first attributes is less than the number of first numerical values, dividing the second text into multiple sub-texts, each sub-text corresponds to a first numerical value; performing intent recognition on the sub-text to obtain a first intent recognition result of the sub-text; determining the fourth attribute of the sub-text based on the first intent recognition result; based on the fourth attribute of the sub-text, querying the third numerical value of the fourth attribute in the user data; if the third numerical value is different from the first numerical value, updating the first numerical value to the third numerical value.
[0170] In an embodiment of the present application, the recognition result includes a first attribute, a second attribute, and a first value of the second attribute. If the number of first attributes in the recognition result is greater than or equal to the number of second attributes, then in the process of performing data query in user data for each second attribute, the first attribute and the second attribute can be used together as the reference basis required for the query. However, in the case where the number of first attributes is less than the number of second attributes, it may happen that, for a part of the second attributes, the first attribute and the second attribute can be used together in the process of performing data query in user data for the second attribute, and for another part of the second attributes, there is no first attribute in the second text that has an association relationship with the second attribute. In this case, the present implementation method can be adopted.
[0171] If the number of the first numerical values in the recognition result is multiple and the number of the first attributes is smaller than the number of the first numerical values, the second text is divided into multiple subtexts, each subtext corresponding to one first numerical value.
[0172] For example, the second text is: Activity S will end on X month Y day. In addition, you still have N activity resources that have not been redeemed. Please pay attention.
[0173] The second text includes: a first numerical value 1 "X, Y" and a first numerical value 2 "N".
[0174] The second text is divided into a plurality of subtexts, each subtext corresponding to a first numerical value.
[0175] For example, the second text is: Activity S will end on X month Y day. In addition, you still have N activity resources that have not been redeemed. Please pay attention.
[0176] Divide the second text into multiple subtexts and get: Subtext 1: Activity S will end on X month Y day; Subtext 2: In addition, you still have N activity resources that have not been redeemed, please pay attention.
[0177] Subtext 1 corresponds to the first numerical value 1 "X, Y", and subtext 2 corresponds to the first numerical value 2 "N".
[0178] Perform intent recognition on the subtext to obtain a first intent recognition result of the subtext.
[0179] For example, the intent recognition is performed on the subtext 1 "Activity S will end on X month Y day", and the first intent recognition result of the subtext 1 is obtained: reminder of the end time of the activity.
[0180] The intent of sub-text 2 "In addition, you still have N activity resources that have not been redeemed, please pay attention" is recognized, and the first intent recognition result of sub-text 2 is obtained: "Unredeemed resource reminder".
[0181] Due to the similarity of concepts, the sub-text is subjected to intent recognition to obtain the first intent recognition result of the sub-text. The corresponding description part of the second intent recognition result obtained by referring to the aforementioned intent recognition of the third text of the first user can be referred to.
[0182] The intent recognition process can employ any of a variety of intent recognition methods, including, for example, identifying intent using preconfigured keywords and phrases; using a supervised learning algorithm to train a classification model and map subtexts to predefined intent categories; utilizing Bayes' theorem to calculate the probability that a subtext belongs to a particular intent and selecting the intent with the highest probability as the first intent recognition result; analyzing the dependencies between words in a subtext to identify the subtext's core structure and thereby infer intent, and so on. The embodiments of this application do not impose any restrictions on the intent recognition method.
[0183] A fourth attribute of the subtext is determined according to the first intention recognition result.
[0184] For example, the first intention recognition result of subtext 1 is: activity end time reminder. According to the first intention recognition result, it can be determined that the fourth attribute corresponding to subtext 1 is "activity end time".
[0185] The first intention recognition result of subtext 2 is “unredeemed resource reminder.” Based on the first intention recognition result, it can be determined that the fourth attribute corresponding to subtext 2 is “unredeemed resource quantity.”
[0186] In this implementation, the fourth attribute plays a similar role in data querying as the first and second attributes in step S206. Due to the similar concepts, the third value of the fourth attribute in the user data can be queried based on the fourth attribute of the subtext. Refer to the corresponding description of step S206 above.
[0187] Due to the similar concepts, if the third value is different from the first value, the first value is updated to the third value. Please refer to the corresponding description of the aforementioned step S208.
[0188] In this implementation, the second text is divided into multiple sub-texts, each sub-text corresponds to a first value, and the sub-text intention is identified to obtain the fourth attribute corresponding to the sub-text. The context information of each value is fully utilized to determine what attribute the value is related to, thereby improving the accuracy of data query.
[0189] In a specific implementation, the text generation method further includes: performing event extraction processing on the fourth text to obtain events of the fourth text; determining a subtext describing the event in the fourth text according to the event; and deleting the subtext of the event in the fourth text.
[0190] The fourth text may be the text obtained after executing the aforementioned steps S202 to S208 on the first text. For details, please refer to the corresponding description of step S208.
[0191] Event extraction is a key task in natural language processing (NLP). It aims to identify and extract structured event information from unstructured text. An event typically refers to a specific action, state change, or occurrence described in text. The goal of event extraction is to automatically identify these events and extract key elements such as the participants, time, location, cause, and outcome.
[0192] The fourth text is subjected to event extraction processing to obtain events in the fourth text. This may be performed by inputting the fourth text into a pre-trained event extraction model to perform event extraction to obtain events in the fourth text.
[0193] The event of the fourth text may be a historical event, or an event of one or more predetermined event types, and so on.
[0194] For example, the fourth text is: Regarding your bill, our customer service called you at 10 o'clock yesterday. Event extraction is performed on the fourth text to obtain the event: Customer service called you at 10 o'clock yesterday.
[0195] According to the event, a subtext describing the event is determined in the fourth text.
[0196] For example, the fourth text reads: "Your bill has not been settled yet, totaling 200 yuan. Our staff called you at 10:00 yesterday to remind you." Event extraction is performed on the fourth text to obtain the event: "Staff called you at 10:00 yesterday." Based on this event, the subtext describing the event in the fourth text is determined to be "Our staff called you at 10:00 yesterday to remind you."
[0197] Delete the subtext of the event in the fourth text.
[0198] For example, the fourth text is: Regarding question A, our staff called you yesterday. Can you give us an answer? The event of the fourth text is "the staff called yesterday", and the subtext describing the event is "our staff called you yesterday".
[0199] But in fact, the historical event "the staff called yesterday" may not exist, that is, the text generation model fabricated an event that did not happen. If the fourth text is directly replied to the customer, it is likely to cause customer dissatisfaction.
[0200] In the above example, if the subtext of the event is deleted in the fourth text, we get: Regarding question A, can you give an answer? Taking into account that when the text generation model is generating text, some specific types of events are prone to produce AI hallucinations, such as historical events. Taking historical events as an example, in some dialogue scenarios, historical events have no substantial impact on communication, but historical events with incorrect content may cause disgust to the other party in the dialogue. Therefore, the process of judging whether the content of the historical events is true can be skipped, and all parts related to the historical events can be deleted, thereby improving the accuracy of the text content of the fourth text.
[0201] In such Figure 2In the embodiment shown, first, the first text of the first user is input into the model for text generation to obtain a second text; then, entity recognition is performed on the second text to obtain a recognition result, which includes the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; then, the second value of the second attribute is queried in the user data of the first user based on the first attribute and the second attribute; finally, if the second value is different from the first value, the first value is updated to the second value. Considering that the second text generated by the model may include false information fabricated by the model, if the text content representing the numerical value is incorrect, it may cause serious misleading to the first user. By performing entity recognition on the second text, the first attribute of the second text, the second attribute of the second text and the first numerical value of the second attribute can be obtained. When the user data may include multiple similar attributes, the first attribute and the second attribute are used together to query the second numerical value of the second attribute in the user data of the first user. Compared with data querying only through the second attribute, this is conducive to avoiding confusion between multiple similar attributes and improving data query accuracy. The data content of the user data is more authentic and reliable than the text generated by the model. Therefore, by updating the first numerical value to the second numerical value when the first numerical value is different from the second numerical value, the authentic and reliable user data can be used to correct the false information fabricated by the model, thereby improving the accuracy of the text content generated by the model.
[0202] The following takes the application of a text generation method provided by this embodiment in a call scenario as an example, combined with Figure 3 The text generation method provided in the embodiment of the present application is further explained. Figure 3 A processing flow chart of another text generation method provided in an embodiment of the present application.
[0203] like Figure 3 As shown, step S302, obtain customer text.
[0204] In a call scenario, a robot agent conducts a call with a customer. Specifically, the call center can call multiple customers in batches. After any customer answers, the customer's voice data can be converted into text to obtain the customer's text.
[0205] The customer text may refer to the “first text” in the aforementioned method embodiment.
[0206] Step S304, initialization.
[0207] According to the customer information, the prepared customer data is extracted to initialize the large model.
[0208] There is a correspondence between the customer information and the customer text obtained in the previous step.
[0209] For example, the customer text is obtained by performing speech-to-text processing on the voice data of customer 1. The customer information may be customer ID 001 of customer 1. The customer data may include the total amount of repayment to be made by customer 1, "10,000 yuan", the number of repayment periods, "3 periods", the repayment time, "X year Y month Z day", and so on.
[0210] For the large model, please refer to the corresponding description part of the "model" in the aforementioned method embodiment.
[0211] Initializing the large model can be understood as preparing for the use of the large model.
[0212] Step S306: keyword interception.
[0213] If the customer text includes preset keywords, it can be determined that the customer text has high-risk intentions. In this case, the fallback words corresponding to the preset keywords can be used to reply to the customer and end the conversation.
[0214] Fallback scripts are pre-set text or strategies used in interactive systems like dialogue systems, chatbots, and intelligent customer service when the system fails to understand user input or cannot provide an accurate answer. The purpose of fallback scripts is to ensure that the system always provides meaningful responses when interacting with users, avoiding awkward silences or incorrect answers.
[0215] Step S308: Determine high risk.
[0216] That is, it is determined that the customer text has high-risk intent.
[0217] Step S310, intent recognition.
[0218] Perform intent recognition on the customer text to obtain an intent recognition result, based on which it can be determined whether the customer text contains high-risk intent.
[0219] Step S312, verify identity.
[0220] During the call, the robot agent can verify the customer's identity. If the verification is successful, it can announce the customer's pre-set request, for example, asking the customer whether they agree to participate in Activity A.
[0221] Step S314: Agree or not.
[0222] Determine whether the customer agrees to the preset request based on the customer's response text.
[0223] Step S316: Generate an approval tag.
[0224] If the customer agrees to the preset request, you can end the call and add an approval tag to the customer.
[0225] Step S318, return to the response script.
[0226] The robot agent reads the response script to the customer.
[0227] Step S320: hang up the phone after replying.
[0228] Step S322: The large model generates speech.
[0229] The large model in this step can refer to the corresponding description of the “model” in the aforementioned method embodiment. And this step can refer to the corresponding description of step S202 in the aforementioned method embodiment.
[0230] Step S324: hallucination detection.
[0231] Entity recognition is performed on some text generated by the large model, which may be uncertain whether it is real. For example, when recognizing amounts and names, the language generated by the large model may contain the risk of false positives. Therefore, it is necessary to make corrections based on the specific user to improve the accuracy of the large model's response. For example, if the large model generates a due payment of 1,034 yuan, but the actual due payment is 830 yuan, the corrected amount of 834 yuan should be returned to the customer.
[0232] This step may refer to the corresponding description parts of steps S204 to S210 of the aforementioned method embodiment.
[0233] Step S326: historical event detection.
[0234] Step S328: preset keyword detection.
[0235] Since the technical concept is the same, the description in this embodiment is relatively simple, and the relevant parts can refer to the corresponding description of the method embodiment provided above.
[0236] The following takes the application of a text generation method provided by this embodiment in a call scenario as an example, combined with Figure 4 The text generation method provided in the embodiment of the present application is further explained. Figure 4 A processing flow chart of another text generation method provided in an embodiment of the present application.
[0237] like Figure 4 As shown, step S402, obtain customer text.
[0238] The customer text may refer to the “first text” in the aforementioned method embodiment.
[0239] Step S404: pre-processing.
[0240] Step S406, intent recognition.
[0241] Step S408: whether it is high risk.
[0242] Step S410: identifying entities with high risk.
[0243] Step S412: The entity recognition model identifies a word that matches the dynamic vocabulary.
[0244] Step S414: Determine whether a high risk is triggered based on the preset distance information.
[0245] Step S416, determine the fallback words.
[0246] Step S418: whether to generate the speech through the big model.
[0247] The large model in this step can refer to the corresponding description part of the "model" in the aforementioned method embodiment.
[0248] Step S420: Generate speech through the big model.
[0249] This step may refer to the corresponding description of step S202 in the aforementioned method embodiment.
[0250] Step S422: hallucination detection.
[0251] Step S424: Identify hallucination attributes.
[0252] Step S426: Identify the starting position.
[0253] Step S428: Identify the end position.
[0254] Step S430: Modify the large model generation script.
[0255] Steps S422 to S430 may refer to the corresponding description parts of steps S204 to S208 of the aforementioned method embodiment.
[0256] Step S432: whether it can be corrected.
[0257] Step S434, combine the template vocabulary to process the large model and generate the speech.
[0258] Step S436, return text.
[0259] Step S438: convert text to speech.
[0260] Since the technical concept is the same, the description in this embodiment is relatively simple, and the relevant parts can refer to the corresponding description of the method embodiment provided above.
[0261] An embodiment of a text generation device provided in this specification is as follows: In the above-mentioned embodiment, a text generation method is provided. Based on the same technical concept, the embodiment of the present application also provides a text generation device, which is described below with reference to the accompanying drawings.
[0262] Figure 5 Schematic diagram of a text generation device provided in an embodiment of the present application. This embodiment provides a text generation device 500, comprising: A generating unit 502 is configured to input a first text of a first user into a model to generate text, thereby obtaining a second text; a recognition unit 504 configured to perform entity recognition on the second text to obtain a recognition result, wherein the recognition result includes a first attribute of the second text, a second attribute of the second text, and a first value of the second attribute; A query unit 506, configured to query the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; The updating unit 508 is configured to update the first value to the second value if the second value is different from the first value.
[0263] Optionally, the recognition result further includes first position information of the first attribute and second position information of the second attribute, and the text generation device 500 further includes: a determination unit; The determining unit is configured to determine a first permutation number of a first character corresponding to the second attribute based on the second position information; the first permutation number represents position information of the first character in the second text; The determining unit is further configured to determine, based on the first position information, a second permutation number of the last character corresponding to the first attribute; the second permutation number indicating position information of the last character in the second text; The determining unit is further configured to determine the first attribute as a third attribute associated with the second attribute if the difference between the first permutation number and the second permutation number is greater than or equal to zero and less than or equal to a preset difference threshold; When querying the user data of the first user for the second value of the second attribute based on the first attribute and the second attribute, the query unit 506 performs the following steps: According to the second attribute and a third attribute associated with the second attribute, a second value of the second attribute is queried in the user data of the first user.
[0264] Optionally, the text generation device 500 further includes: a division unit, an intention recognition unit, and a determination unit; The dividing unit is configured to divide the second text into a plurality of subtexts, each subtext corresponding to one of the first values, if the number of the first values in the recognition result is plural and the number of the first attributes is less than the number of the first values; The intention recognition unit is used to perform intention recognition on the subtext to obtain a first intention recognition result of the subtext; The determining unit is configured to determine a fourth attribute of the subtext according to the first intention recognition result; The query unit 506 is further configured to query the user data for a third value of the fourth attribute based on the fourth attribute of the subtext; The updating unit 508 is further configured to update the first value to the third value if the third value is different from the first value.
[0265] Optionally, the text generation device 500 further includes: an intention recognition unit and a determination unit; The intention recognition unit is configured to perform intention recognition on the third text of the first user to obtain a second intention recognition result; The generating unit 502 is further configured to generate a text template corresponding to the third text according to the second intent recognition result and a pre-established mapping relationship between intent and text template if the second intent recognition result belongs to a preset intent set; The determining unit is configured to determine the third text as the first text if the second intention recognition result does not belong to the preset intention set.
[0266] Optionally, when the intent recognition unit performs intent recognition on the third text of the first user and obtains a second intent recognition result, the unit performs the following steps: Performing entity recognition on the third text to obtain a first entity text in the third text; Matching the third text with the intended keyword based on the first entity text; An intent keyword matching the third text is determined as a second intent recognition result of the third text.
[0267] Optionally, the intent keyword includes a first character and a second character; the first entity text includes one character; and the intent recognition unit performs the following steps when matching the third text with the intent keyword based on the first entity text: Determine a third sequence number of a character in the first entity text in the third text; the third sequence number represents position information of the corresponding character in the third text; Determining a third entity text in the first entity text according to the second entity text, the third arrangement sequence number of the first entity text, and a preset sequence number interval threshold, wherein the second entity text is the first entity text having the same character as the first character; If the third entity text that is identical to the second character exists, determining that the third text matches the intended keyword; If the third entity text identical to the second character does not exist, it is determined that the third text does not match the intended keyword.
[0268] Optionally, the text generation device 500 further includes: an extraction unit, a determination unit, and a deletion unit; The extraction unit is configured to perform event extraction processing on the fourth text to obtain events of the fourth text; The determining unit is configured to determine, based on the event, a subtext describing the event in the fourth text; The deleting unit is configured to delete the subtext of the event from the fourth text.
[0269] In an embodiment of the present application, a text generation device includes: a generation unit, which is used to generate text from a first text input model of a first user to obtain a second text; a recognition unit, which is used to perform entity recognition on the second text to obtain a recognition result, and the recognition result includes a first attribute of the second text, a second attribute of the second text, and a first value of the second attribute; a query unit, which is used to query the second value of the second attribute in the user data of the first user based on the first attribute and the second attribute; and an update unit, which is used to update the first value to the second value if the second value is different from the first value. Considering that the second text generated by the model may include false information fabricated by the model, if the text content representing the numerical value is incorrect, it may cause serious misleading to the first user. By performing entity recognition on the second text, the first attribute of the second text, the second attribute of the second text and the first numerical value of the second attribute can be obtained. When the user data may include multiple similar attributes, the first attribute and the second attribute are used together to query the second numerical value of the second attribute in the user data of the first user. Compared with data querying only through the second attribute, this is conducive to avoiding confusion between multiple similar attributes and improving data query accuracy. The data content of the user data is more authentic and reliable than the text generated by the model. Therefore, by updating the first numerical value to the second numerical value when the first numerical value is different from the second numerical value, the authentic and reliable user data can be used to correct the false information fabricated by the model, thereby improving the accuracy of the text content generated by the model.
[0270] Corresponding to the above-described method for generating text, based on the same technical concept, an embodiment of the present application further provides an electronic device for executing the above-described method for generating text. Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0271] like Figure 6 As shown, electronic devices can vary significantly due to different configurations or performance. They may include one or more processors 601 and memory 602. Memory 602 may store one or more applications or data. Memory 602 may be either ephemeral or persistent. Applications stored in memory 602 may include one or more modules (not shown), each of which may include a series of computer-executable instructions within the electronic device. Furthermore, processor 601 may be configured to communicate with memory 602 to execute the series of computer-executable instructions within memory 602 on the electronic device. The electronic device may also include one or more power supplies 603, one or more wired or wireless network interfaces 604, one or more input / output interfaces 605, one or more keyboards 606, and the like.
[0272] In a specific embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the electronic device, and the one or more programs are configured to be executed by one or more processors, including computer-executable instructions for performing the following: Inputting the first text of the first user into the model to generate text to obtain a second text; Performing entity recognition on the second text to obtain a recognition result, the recognition result including the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; querying the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; If the second value is different from the first value, the first value is updated to the second value.
[0273] The computer-readable storage medium provided in this embodiment is used to store computer-executable instructions. When the computer-executable instructions are executed by a processor, the following process is implemented: Inputting the first text of the first user into the model to generate text to obtain a second text; Performing entity recognition on the second text to obtain a recognition result, the recognition result including the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; querying the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; If the second value is different from the first value, the first value is updated to the second value.
[0274] It should be noted that the embodiment of the computer-readable storage medium in this specification and the embodiment of the text generation method in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding method mentioned above, and the repeated parts will not be repeated.
[0275] Another embodiment of the present disclosure further provides a computer program product, the computer program product including a computer program, which implements the following process when executed by a processor: Inputting the first text of the first user into the model to generate text to obtain a second text; Performing entity recognition on the second text to obtain a recognition result, the recognition result including the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; querying the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; If the second value is different from the first value, the first value is updated to the second value.
[0276] The computer program product in the embodiment of the present disclosure can implement each process of the above-mentioned text generation method embodiment and achieve the same effects and functions, which will not be repeated here.
[0277] In an embodiment of the present application, first, the first text of the first user is input into a model for text generation to obtain a second text; then, entity recognition is performed on the second text to obtain a recognition result, which includes the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; then, based on the first attribute and the second attribute, the second value of the second attribute is queried in the user data of the first user; finally, if the second value is different from the first value, the first value is updated to the second value. Considering that the second text generated by the model may include false information fabricated by the model, if the text content representing the numerical value is incorrect, it may cause serious misleading to the first user. By performing entity recognition on the second text, the first attribute of the second text, the second attribute of the second text and the first numerical value of the second attribute can be obtained. When the user data may include multiple similar attributes, the first attribute and the second attribute are used together to query the second numerical value of the second attribute in the user data of the first user. Compared with data querying only through the second attribute, this is conducive to avoiding confusion between multiple similar attributes and improving data query accuracy. The data content of the user data is more authentic and reliable than the text generated by the model. Therefore, by updating the first numerical value to the second numerical value when the first numerical value is different from the second numerical value, the authentic and reliable user data can be used to correct the false information fabricated by the model, thereby improving the accuracy of the text content generated by the model.
[0278] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0279] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the embodiments of the present application may take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0280] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable electronic device to produce a machine, so that the instructions executed by the processor of the computer or other programmable electronic device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0281] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable electronic device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0282] These computer program instructions can also be loaded onto a computer or other programmable electronic device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0283] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0284] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0285] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can be implemented using any method or technology for information storage. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change RAM (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0286] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0287] The embodiments of the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0288] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
[0289] The foregoing description is merely an example of the present invention and is not intended to limit the present invention. Persons skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims herein.
Claims
1. A text generation method, characterized in that: include: Inputting the first text of the first user into the model to generate text to obtain a second text; Performing entity recognition on the second text to obtain a recognition result, the recognition result including the first attribute of the second text, the second attribute of the second text, and the first value of the second attribute; querying the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; If the second value is different from the first value, the first value is updated to the second value.
2. The method according to claim 1, characterized in that The recognition result further includes first position information of the first attribute and second position information of the second attribute. After performing entity recognition on the second text and obtaining the recognition result, the method further includes: Determining, based on the second position information, a first permutation number of a first character corresponding to the second attribute; the first permutation number represents position information of the first character in the second text; Determining, based on the first position information, a second permutation number of the last character corresponding to the first attribute; the second permutation number indicating position information of the last character in the second text; If the difference between the first permutation number and the second permutation number is greater than or equal to zero and less than or equal to a preset difference threshold, the first attribute is determined as a third attribute associated with the second attribute; The querying, in the user data of the first user according to the first attribute and the second attribute, for a second value of the second attribute includes: According to the second attribute and a third attribute associated with the second attribute, a second value of the second attribute is queried in the user data of the first user.
3. The method according to claim 1, characterized in that The method further comprises: If the number of the first values in the recognition result is multiple and the number of the first attributes is smaller than the number of the first values, dividing the second text into multiple subtexts, each subtext corresponding to one of the first values; Performing intent recognition on the subtext to obtain a first intent recognition result of the subtext; determining a fourth attribute of the subtext according to the first intent recognition result; According to the fourth attribute of the subtext, querying the user data for a third value of the fourth attribute; If the third value is different from the first value, the first value is updated to the third value.
4. The method according to claim 1, wherein Before inputting the first text of the first user into the model to generate text to obtain the second text, the method further includes: Performing intent recognition on the third text of the first user to obtain a second intent recognition result; If the second intent recognition result belongs to a preset intent set, generating a text template corresponding to the third text according to the second intent recognition result and a pre-established mapping relationship between intent and text template; If the second intent recognition result does not belong to the preset intent set, the third text is determined to be the first text.
5. The method according to claim 4, characterized in that The performing intent recognition on the third text of the first user to obtain a second intent recognition result includes: Performing entity recognition on the third text to obtain a first entity text in the third text; Matching the third text with the intended keyword based on the first entity text; An intent keyword matching the third text is determined as a second intent recognition result of the third text.
6. The method according to claim 5, characterized in that The intent keyword includes a first character and a second character; the first entity text includes one character; and matching the third text with the intent keyword based on the first entity text includes: Determine a third sequence number of a character in the first entity text in the third text; the third sequence number represents position information of the corresponding character in the third text; Determining a third entity text in the first entity text according to the second entity text, the third arrangement sequence number of the first entity text, and a preset sequence number interval threshold, wherein the second entity text is the first entity text having the same character as the first character; If the third entity text that is identical to the second character exists, determining that the third text matches the intended keyword; If the third entity text identical to the second character does not exist, it is determined that the third text does not match the intended keyword.
7. The method according to claim 1, characterized in that The method further comprises: performing event extraction processing on the fourth text to obtain events of the fourth text; determining, according to the event, a subtext describing the event in the fourth text; The subtext of the event is deleted from the fourth text.
8. A text generation device, characterized in that: include: A generating unit, configured to input a first text of a first user into a model to generate text, thereby obtaining a second text; a recognition unit, configured to perform entity recognition on the second text to obtain a recognition result, wherein the recognition result includes a first attribute of the second text, a second attribute of the second text, and a first value of the second attribute; a query unit, configured to query the user data of the first user for a second value of the second attribute based on the first attribute and the second attribute; An updating unit is configured to update the first value to the second value if the second value is different from the first value.
9. An electronic device, characterized in that: include: processor; and a memory configured to store computer-executable instructions, which, when executed, cause the processor to perform the text generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the text generation method according to any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that The invention comprises a computer program, which implements the text generation method according to any one of claims 1 to 7 when being executed by a processor.