CN-122019736-A - Verifiable text generation method and device
Abstract
The invention discloses a verifiable text generation method and device, relates to the field of natural language processing, and aims to improve the illusion and the untrusted problem of the execution of a retrieval enhancement generation task. The method comprises the steps of receiving a text generation task, analyzing task types of the text generation task, extracting key information of the text generation task, evaluating uncertainty of a text generation model when each word element is generated, generating a search word and triggering evidence retrieval when a trigger condition is met, retrieving evidence according to the search word, enhancing a historical session of the retrieved evidence, generating a corresponding word element by the text generation model and generating a reply text based on the word element, associating the reply text with the evidence, checking consistency of the reply text and the associated evidence, and triggering rewriting of the reply text if the check is not passed. The invention solves the problems of searching and generating static disjoints, and improves the fact accuracy and traceability of the text.
Inventors
- Meng Hongyang
- WU HUAIGU
- ZHANG NANXIN
- ZHANG ZIJIAN
- YANG FEI
- CHEN HONGYING
Assignees
- 天府绛溪实验室
Dates
- Publication Date
- 20260512
- Application Date
- 20260414
Claims (10)
- 1. A verifiable text generation method, comprising: s1, receiving a text generation task, analyzing the task type of the text generation task, and extracting key information of the text generation task; S2, when the text generation model generates each word element for the text generation task, evaluating the uncertainty of the text generation model, and when the uncertainty reaches a trigger condition, generating a search term based on the key information and triggering evidence retrieval, wherein the trigger condition is associated with the task type; s3, retrieving evidence according to the retrieval word, enhancing a history session by utilizing the retrieved evidence, generating a corresponding word element by a text generation model according to the enhanced history session, and generating a reply text based on the word element; s4, checking consistency of the reply text and the associated evidence, and triggering rewriting of the reply text if the check is not passed.
- 2. The verifiable text generation method of claim 1, wherein evaluating the uncertainty of the text generation model comprises: Calculating an entropy value of prediction probability distribution of a current word element, judging whether the entropy value reaches a first preset threshold value, and if so, judging that the entropy value reaches a trigger condition; Or judging whether a preset entity exists in the reply text to which the current word element belongs, if so, judging that the trigger condition is reached, wherein the preset entity is determined by the task type; Or judging whether the semantic relativity of the answer text to which the current word element belongs and the historical session reaches a second preset threshold value, if not, judging that the trigger condition is reached, wherein the second preset threshold value is determined by the task type.
- 3. The verifiable text generation method of claim 1, wherein retrieving evidence from the term comprises: Carrying out multi-source parallel evidence retrieval according to the retrieval word; preprocessing the retrieved evidence, and respectively carrying out unique identification on each preprocessed evidence.
- 4. A verifiable text generation method as recited in claim 3 wherein preprocessing the retrieved evidence and uniquely identifying each preprocessed evidence, respectively, comprises: de-duplicating the retrieved evidence, and screening out a preset number of evidence which are in front of the correlation with the retrieval word; Dividing each evidence into sentences, and respectively distributing unique evidence identification for each divided sentence.
- 5. A verifiable text generation method as recited in claim 3 or 4 wherein enhancing the history session with the retrieved evidence comprises: Splicing the retrieved evidence with the history session and then encoding; or respectively encoding the retrieved evidence and the history session and then splicing; Or embedding the retrieved evidence into the history session through a preset identifier and then coding.
- 6. A verifiable text generation method as claimed in claim 3 or 4 wherein associating the reply text with evidence corresponding to the lemma comprises: evaluating the relevance of the word element to be generated and all evidences by using a cross attention mechanism, and screening the evidence with highest relevance to carry out implicit relevance on the word element; And when generating a reply text according to the word elements, generating an explicit traceability mark containing evidence associated with the word elements for the reply text according to the implicit association.
- 7. The verifiable text generation method of claim 1, wherein verifying the consistency of the reply text with the associated evidence comprises: And evaluating the contradictory risk of the reply text and the associated evidence, and if the contradictory risk reaches a third preset threshold, checking not to pass.
- 8. The verifiable text generation method of claim 7, wherein the contradictory risk assessment method comprises: Verifying a probability that an entity or relationship in the reply text contradicts the evidence; or checking the non-consistency proportion of the evidence associated with the multi-round retrieval of the reply text based on the same retrieval word.
- 9. A verifiable text generation method as recited in claim 7 or 8 wherein the training method of the text generation model comprises: Defining a reference reply text of the sample; inputting the sample into the text generation model, and respectively calculating language modeling loss and fact consistency loss of the text generation model, wherein the language modeling loss is cross entropy loss of the reference reply text and the reply text generated by the text generation model; Carrying out weighted summation on the language modeling loss and the fact consistency loss to obtain total loss; model parameters of the text generation model are optimized based on the total loss.
- 10. A verifiable text generation device comprising a processor and a storage medium, the storage medium storing computer instructions, the processor executing the computer instructions to perform a verifiable text generation method as recited in any one of claims 1-9.
Description
Verifiable text generation method and device Technical Field The invention relates to the technical field of natural language processing (Natural Language Processing, NLP), in particular to a verifiable text generation method and device. Background Text generation techniques have plentiful applications in natural language questions and answers, authoring, etc., and corresponding applications are typically implemented by means of a text generation model (generative artificial intelligence tool) represented by a large language model (Large Language Model, LLM). A common text generation model adopts a retrieval enhancement generation (RETRIEVAL-Augmented Generation, RAG) technology, the generation principle is that external knowledge retrieval is carried out on the basis of an input text generation task (such as a problem description or a task description and the like), the retrieved knowledge is called evidence, and then a reply text is generated by referring to the retrieved evidence and combining LLM. However, the above-described text generation model has been found by practice to produce a reply text that is acceptable when short text is produced, but in most cases, while the context is plausible, it is actually inconsistent with a given knowledge source or objective facts, and belongs to "dubbed" text when long text is produced. This phenomenon is referred to in the art as the "illusion" phenomenon. The existence of this phenomenon makes the application of known text generation models into serious scenes such as finance, medical treatment, law, science and technology, etc. a serious risk exists. In addition, the reply text generated by the text generation model lacks traceability, the authenticity of the reply text is difficult to verify, and the credibility cannot be guaranteed. The known optimization method focuses on the smoothness of the reply text and the relevance of the context, and does not effectively suppress the "illusion" problem and the credibility problem of the text generation model. Disclosure of Invention The invention aims to provide a verifiable text generation method and device aiming at all or part of the problems, so as to effectively restrain the 'illusion' problem of the execution of a search enhancement generation task and improve the reliability of a reply text. The technical scheme adopted by the invention is as follows: in a first aspect, the present invention provides a verifiable text generation method, comprising: s1, receiving a text generation task, analyzing the task type of the text generation task, and extracting key information of the text generation task; S2, when the text generation model generates each word element for the text generation task, evaluating the uncertainty of the text generation model, and when the uncertainty reaches a trigger condition, generating a search term based on the key information and triggering evidence retrieval, wherein the trigger condition is associated with the task type; s3, retrieving evidence according to the retrieval word, enhancing a history session by utilizing the retrieved evidence, generating a corresponding word element by a text generation model according to the enhanced history session, and generating a reply text based on the word element; s4, checking consistency of the reply text and the associated evidence, and triggering rewriting of the reply text if the check is not passed. Optionally, evaluating the uncertainty of the text generation model includes: Calculating an entropy value of prediction probability distribution of a current word element, judging whether the entropy value reaches a first preset threshold value, and if so, judging that the entropy value reaches a trigger condition; Or judging whether a preset entity exists in the reply text to which the current word element belongs, if so, judging that the trigger condition is reached, wherein the preset entity is determined by the task type; Or judging whether the semantic relativity of the answer text to which the current word element belongs and the historical session reaches a second preset threshold value, if not, judging that the trigger condition is reached, wherein the second preset threshold value is determined by the task type. Optionally, retrieving evidence according to the search term includes: Carrying out multi-source parallel evidence retrieval according to the retrieval word; preprocessing the retrieved evidence, and respectively carrying out unique identification on each preprocessed evidence. Optionally, preprocessing the retrieved evidence, and respectively uniquely identifying each preprocessed evidence, including: de-duplicating the retrieved evidence, and screening out a preset number of evidence which are in front of the correlation with the retrieval word; Dividing each evidence into sentences, and respectively distributing unique evidence identification for each divided sentence. Optionally, enhancing the historical session with the re