Text generation method and device based on automatic hallucination detection and large model
The construction of a knowledge database through automated hallucination detection technology solves the hallucination tendency problem of large language models in reasoning and generation tasks, and achieves the accuracy of generated text improvement.
Patent Information
- Application Number
- CN202510274880.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2025-04-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing large language models have hallucinations in inference and generation tasks, resulting in low accuracy of generated texts.
The knowledge database is constructed through automated hallucination detection technology, and the word participle is used to extract the vocabulary unit of the initial text, determine the similarity between the vocabulary unit and the knowledge fragment, and generate the target text based on the similarity.
Through an automated hallucination detection and recognition algorithm, low hallucination data is obtained from knowledge base data, and the probability distribution of candidate words during the decoding process is adjusted, the reliability of generated text is enhanced, and the accuracy of generated text is improved.
Smart Images

Figure CN119760049A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of large-model natural language processing, and in particular to a text generation method and device based on automatic hallucination detection and a large model. Background Art
[0002] In recent years, large language models have been widely used in scenarios such as dialogue, question and answer, and summarization due to their powerful knowledge expression and reasoning capabilities.
[0003] However, current large-scale language models have a certain tendency to hallucinate in tasks such as reasoning and generation, that is, they generate content that is inconsistent with the facts or is misleading. The frequency of "hallucination" problems is high, resulting in low accuracy of the final generated text.
[0004] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of the present invention is to provide a text generation method and device based on automatic hallucination detection and large models, aiming to solve the technical problem that the current large-scale language models have a certain tendency to hallucinate in tasks such as reasoning and generation, that is, they generate content that is inconsistent with the facts or is error-inducing, and the frequency of occurrence of the "hallucination" problem is high, resulting in low accuracy of the final generated text.
[0006] To achieve the above object, the present invention provides a text generation method based on automatic hallucination detection and large model, and the text generation method based on automatic hallucination detection and large model comprises the following steps: Get the initial text of the input; Extracting a number of vocabulary units of the initial text using a word segmenter; Using automated hallucination detection to construct a knowledge database, the knowledge database is composed of a number of knowledge fragments, each of which is associated with a number of candidate words; Determining the similarity between the plurality of vocabulary units and each knowledge fragment; Determine a number of target candidate words based on the similarity; A target text is generated based on the plurality of target candidate words.
[0007] In some embodiments, the extracting several vocabulary units of the initial text by using a word segmenter includes: Preprocessing the initial text to obtain a processed text; extracting a number of initial words from the processed text using a word segmenter; Filtering the initial words to obtain reference words; The reference words are processed into word units to obtain word units.
[0008] In some embodiments, the preprocessing of the initial text to obtain the processed text includes: determining the language type of the initial text; Determining stop words in the initial text according to the language type; Identifying high-frequency and low-frequency words in the initial text; The stop words and the high- and low-frequency words are removed from the initial text to obtain a processed text.
[0009] In some embodiments, the step of constructing a knowledge database using automated hallucination detection includes: Define and initialize the knowledge database; Set corresponding embedding vectors for each knowledge fragment in the knowledge database respectively; Determine the weight corresponding to each knowledge fragment based on a function of time and weight; Receive any sample input and set a corresponding query vector for the sample input; Determine a similarity score between the sample input and each knowledge fragment based on the embedding vector, the query vector and the weight; A subset of the knowledge database corresponding to any sample input is determined based on the similarity score, and the knowledge database is constructed by the subsets of multiple knowledge databases.
[0010] In some embodiments, the function based on time and weight determines the weight corresponding to each knowledge fragment, including: Determine the preset adjustment factor; The weight corresponding to each knowledge fragment is calculated based on the function of time, the function of weight and the preset adjustment factor. The calculation formula is: ,in, and are functions based on time and weight respectively, is the preset adjustment factor, d i For the corresponding knowledge fragment.
[0011] In some embodiments, determining the similarity scores between the sample input and each knowledge fragment based on the embedding vector, the query vector, and the weight includes: The similarity between the sample input and each knowledge fragment is calculated based on the embedding vector and the query vector. The calculation formula is: ,in, is the query vector, is the embedding vector; The similarity score is determined based on the weight and the similarity, and the calculation formula is F= .
[0012] In some embodiments, the method further comprises: In the process of reliable decoding of the autoregressive large model, several candidate words with the highest probability are selected from the rate distribution; For each candidate word to be generated, determining the distance between each candidate word to be generated and each knowledge fragment in the knowledge database; The probability distributions corresponding to all candidate words among the plurality of candidate words are adjusted based on the distance, and the associations between the candidate words and the respective knowledge fragments are added to the probability distributions of the candidate words to establish the associations between the candidate words and the knowledge fragments.
[0013] In addition, to achieve the above-mentioned purpose, the present invention also proposes a text generation device based on automatic hallucination detection and large model, and the text generation device based on automatic hallucination detection and large model comprises: The acquisition module is used to obtain the initial text input; An extraction module, used for extracting a plurality of vocabulary units of the initial text by using a word segmenter; A construction module, for constructing a knowledge database using automated hallucination detection, wherein the knowledge database is composed of a number of knowledge fragments, each of which is associated with a number of candidate words; A calculation module, used to determine the similarity between the plurality of vocabulary units and each knowledge fragment; A screening module, used for determining a number of target candidate words based on the similarity; An output module is used to generate a target text based on the target candidate words.
[0014] In some embodiments, the extraction module is used to pre-process the initial text to obtain a processed text; extracting a number of initial words from the processed text using a word segmenter; Filtering the initial words to obtain reference words; The reference words are processed into word units to obtain word units.
[0015] In some embodiments, the extraction module is used to determine the language type of the initial text; Determining stop words in the initial text according to the language type; Identifying high-frequency and low-frequency words in the initial text; The stop words and the high- and low-frequency words are removed from the initial text to obtain a processed text.
[0016] The present invention obtains an input initial text; uses a word segmenter to extract several vocabulary units of the initial text; uses automated hallucination detection to construct a knowledge database, the knowledge database is composed of several knowledge fragments, and each knowledge fragment is associated with several candidate words; determines the similarity between the several vocabulary units and each knowledge fragment; determines several target candidate words based on the similarity; and generates a target text based on the several target candidate words. In the above manner, low hallucination data is obtained from the knowledge base data through an automated hallucination detection recognition algorithm, and the data in the knowledge base is integrated to adjust the probability distribution of candidate words in the decoding process to enhance the reliability of the generated text, thereby improving the accuracy of the generated text. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flowchart of a first embodiment of a text generation method based on automatic hallucination detection and a large model of the present invention; Figure 2 It is a flow chart of the implementation of the hallucination mitigation technology based on the fusion of a large model and a knowledge base based on trusted decoding in the text generation method based on automated hallucination detection and a large model of the present invention; Figure 3 This is a structural block diagram of the first embodiment of the text generation device based on automatic hallucination detection and large models of the present invention.
[0018] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0019] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0020] The embodiment of the present invention provides a text generation method based on automatic hallucination detection and large model, referring to Figure 1 , Figure 1 The figure is a flow chart of a first embodiment of a text generation method based on automatic hallucination detection and large models of the present invention.
[0021] In this embodiment, the text generation method based on automatic hallucination detection and large model includes the following steps: Step S10: Obtain the input initial text.
[0022] In this embodiment, the executor of this embodiment is a text generation device based on automatic hallucination detection and large models, wherein the text generation device based on automatic hallucination detection and large models has functions such as data processing, data communication and program running. The text generation device based on automatic hallucination detection and large models can be a computer terminal device or other network device, and of course it can also be other devices with similar functions, and this embodiment does not limit this.
[0023] It should be noted that current large-scale language models have a certain tendency to hallucinate in tasks such as reasoning and generation, that is, they generate content that is inconsistent with the facts or is misleading. The "hallucination" problem occurs frequently, resulting in low accuracy of the final generated text.
[0024] In order to solve the above technical problems, in this embodiment, an initial input text is obtained; a word segmenter is used to extract several vocabulary units of the initial text; a knowledge database is constructed using automated hallucination detection, wherein the knowledge database is composed of several knowledge fragments, each knowledge fragment is associated with several candidate words; the similarity between the several vocabulary units and each knowledge fragment is determined; several target candidate words are determined based on the similarity; and a target text is generated based on the several target candidate words. In the above manner, low hallucination data is obtained from the knowledge base data through an automated hallucination detection and recognition algorithm, and the data in the knowledge base is integrated to adjust the probability distribution of candidate words in the decoding process to enhance the reliability of the generated text, thereby improving the accuracy of the generated text. Specifically, it can be implemented in the following manner.
[0025] It should be noted that in this embodiment, a hallucination mitigation technology based on the fusion of a large model and a knowledge base based on trusted decoding is first proposed. The specific technical process can be referred to Figure 2 As shown, in this embodiment, an automatic hallucination detection and recognition algorithm based on the knowledge base is designed to target the knowledge base data deviation used in the large model reasoning, and automatic hallucination detection is performed on the knowledge base data used in the large model generation process to improve the quality of large model text generation; subsequently, a large model text generation technology based on trusted decoding is designed.
[0026] In a specific implementation, it is necessary to first obtain the input initial text. In this embodiment, the following content is predicted based on the provided text fragment or text prompt, and a text corresponding thereto is generated, including but not limited to conversational text generation and completion text generation. For example, the input text is "I want to read a novel", and the output target text is "What type of novel do you want to read, or which author's novel?" For another example, the input text is a partial sentence of a poem, and the output text is the entire poem.
[0027] Step S20: extracting a number of vocabulary units of the initial text using a word segmenter.
[0028] In a specific implementation, in order to output text more accurately, it is necessary to first extract a number of vocabulary units from the initial text. Specifically, the initial text is preprocessed to obtain a processed text; a number of initial words are extracted from the processed text using a word segmenter; the number of initial words are filtered to obtain a number of reference words; and the number of reference words are processed into vocabulary units to obtain a number of vocabulary units.
[0029] It should be noted that the vocabulary filtering in this embodiment is based on the filtering of specific field vocabulary. Taking the specific field vocabulary in the publication field as an example, such as the vocabulary related to distribution and publication and the author, these specific field vocabulary are identified from the initial text, retained, and other vocabulary is filtered to obtain a number of reference vocabulary. The specific field vocabulary can be set according to actual needs, and this is not limited in this embodiment. The vocabulary unit processing in this embodiment includes stem processing and word form restoration. The stem processing and word form restoration are aimed at English, such as running becomes run, better becomes good, and the vocabulary unit processing for Chinese, such as university is a vocabulary, and big is the vocabulary unit of the vocabulary, and the corresponding vocabulary unit is determined according to the vocabulary.
[0030] Furthermore, in order to accurately extract vocabulary units, in this embodiment, before using the word segmenter to extract vocabulary units, the process of preprocessing the initial text is specifically to determine the language type of the initial text; determine the stop words in the initial text according to the language type; identify the high- and low-frequency words in the initial text; remove the stop words and the high- and low-frequency words from the initial text to obtain a processed text.
[0031] It should be noted that different language types correspond to different stop words. In this embodiment, the language type needs to be determined before removing stop words. The language types include but are not limited to Chinese and English. Chinese stop words include, for example, de, le, and shi, etc. English stop words include articles, prepositions, conjunctions, auxiliary verbs, such as by and and, etc. In addition, high- and low-frequency words need to be identified. High- and low-frequency words can be identified by comparing them with a number of preset high- and low-frequency words in the vocabulary database.
[0032] Step S30: constructing a knowledge database using automated hallucination detection.
[0033] In a specific implementation, in this embodiment, an automated hallucination detection algorithm can be used to construct a knowledge database, and the specific construction process is to define and initialize the knowledge database; set corresponding embedding vectors for each knowledge fragment in the knowledge database; determine the weight corresponding to each knowledge fragment based on a function of time and weight; receive any sample input and set a corresponding query vector for the sample input; determine the similarity score between the sample input and each knowledge fragment based on the embedding vector, the query vector and the weight; determine the subset of the knowledge database corresponding to any sample input based on the similarity score, and complete the construction of the knowledge database by subsets of multiple knowledge databases.
[0034] It should be noted that a knowledge fragment is a phrase or word group composed of multiple words. The embedding vector corresponding to each knowledge fragment can be determined based on the average vector of all vocabulary vectors. Any sample input, that is, text input, is also composed of multiple words. The corresponding query vector is determined in a similar way to the embedding vector, which will not be described in detail in this embodiment. The weight corresponding to each knowledge fragment is calculated based on the function of time, the function of weight, and the preset adjustment factor. The calculation formula is: ,in, and are functions based on time and weight respectively, is the preset adjustment factor, d i is the corresponding knowledge fragment, It can be an exponential decay function, such as (t)= , t is the difference between the creation time of the knowledge fragment and the current time, λ is the preset decay rate, and the source authority is considered to be a fixed function value. =W, W is a constant between 0 and 1. The above is only an example. In specific applications, other forms of function expressions can also be used.
[0035] Further, the similarity between the sample input and each knowledge fragment is calculated based on the embedding vector and the query vector. The calculation formula is: ,in, is the query vector, is the embedding vector; based on the weight and the similarity, the similarity score is determined, and the calculation formula is F= .
[0036] It should be further explained that additional entity extraction modules and attribute extraction modules are designed to obtain the entities and related attributes existing in the input data, and based on the entities in the input text, the entity-level matching condition probability of the knowledge in the knowledge database is calculated. Finally, a set of knowledge fragments that can still be used as input after passing through the hallucination evaluator is obtained, which is a subset of the knowledge database.
[0037] In this embodiment, after completing the construction of the knowledge database in the above manner, this embodiment uses the autoregressive large model to better eliminate hallucinations. In the process of trusted decoding of the autoregressive large model, several candidate words with the highest probability are selected from the rate distribution; for each candidate word to be generated, the distance between each candidate word to be generated and each knowledge fragment in the knowledge database is determined; based on the distance, the probability distribution corresponding to all candidate words among the several candidate words is adjusted, and the association between the candidate word and each knowledge fragment is added to the probability distribution of the candidate word to establish the association between the candidate word and the knowledge fragment.
[0038] It should be noted that the distance between each candidate word to be generated and each knowledge fragment in the knowledge database can be determined by first determining the vector of the candidate word to be generated, and then calculating the similarity with the embedding vector of the knowledge fragment. The above formula can also be referred to here, or the cosine similarity formula can be used for calculation, and then the probability distribution of the candidate word can be adjusted according to the calculation results, so that the candidate word has a stronger correlation with each knowledge fragment.
[0039] Step S40: Determine the similarity between the plurality of vocabulary units and each knowledge segment.
[0040] Step S50: determining a number of target candidate words based on the similarity.
[0041] The calculation of similarity in this embodiment can also refer to the above formula to determine the vector corresponding to the vocabulary unit, and then perform similarity calculation with the embedded vector of each knowledge fragment. According to the calculated similarity, at least one knowledge fragment with the greatest similarity can be determined. Each knowledge fragment in the knowledge database constructed above is associated with several candidate words, and the candidate word linked to at least one knowledge fragment with the greatest similarity is used as the target candidate word.
[0042] Step S60: Generate a target text based on the target candidate words.
[0043] In a specific implementation, after determining several target candidate words, in this embodiment, the target candidate words can be combined to obtain a target text, or several target candidate words can be integrated with the initial text to obtain the target text. These two methods correspond to the above-mentioned conversational text generation and completion text generation, respectively.
[0044] In this embodiment, an initial input text is obtained; a word segmenter is used to extract several vocabulary units of the initial text; a knowledge database is constructed using automated hallucination detection, wherein the knowledge database is composed of several knowledge fragments, each knowledge fragment is associated with several candidate words; the similarity between the several vocabulary units and each knowledge fragment is determined; several target candidate words are determined based on the similarity; and a target text is generated based on the several target candidate words. In the above manner, low hallucination data is obtained from the knowledge base data through an automated hallucination detection and recognition algorithm, and the data in the knowledge base is integrated to adjust the probability distribution of candidate words in the decoding process to enhance the reliability of the generated text, thereby improving the accuracy of the generated text.
[0045] Reference Figure 3 , Figure 3 This is a structural block diagram of the first embodiment of the text generation device based on automatic hallucination detection and large models of the present invention.
[0046] like Figure 3 As shown, the text generation device based on automatic hallucination detection and large model proposed in the embodiment of the present invention includes: An acquisition module 10 is used to acquire the input initial text; An extraction module 20, for extracting a plurality of vocabulary units of the initial text using a word segmenter; A construction module 30, for constructing a knowledge database using automated hallucination detection, wherein the knowledge database is composed of a number of knowledge fragments, each of which is associated with a number of candidate words; A calculation module 40, used to determine the similarity between the plurality of vocabulary units and each knowledge fragment; A screening module 50, for determining a number of target candidate words based on the similarity; The output module 60 is used to generate a target text based on the target candidate words.
[0047] In this embodiment, an initial input text is obtained; a word segmenter is used to extract several vocabulary units of the initial text; a knowledge database is constructed using automated hallucination detection, wherein the knowledge database is composed of several knowledge fragments, each knowledge fragment is associated with several candidate words; the similarity between the several vocabulary units and each knowledge fragment is determined; several target candidate words are determined based on the similarity; and a target text is generated based on the several target candidate words. In the above manner, low hallucination data is obtained from the knowledge base data through an automated hallucination detection and recognition algorithm, and the data in the knowledge base is integrated to adjust the probability distribution of candidate words in the decoding process to enhance the reliability of the generated text, thereby improving the accuracy of the generated text.
[0048] In some embodiments, the extraction module 20 is used to pre-process the initial text to obtain a processed text; extracting a number of initial words from the processed text using a word segmenter; Filtering the initial words to obtain reference words; The reference words are processed into word units to obtain word units.
[0049] In some embodiments, the extraction module 20 is used to determine the language type of the initial text; Determining stop words in the initial text according to the language type; Identifying high-frequency and low-frequency words in the initial text; The stop words and the high- and low-frequency words are removed from the initial text to obtain a processed text.
[0050] In some embodiments, the construction module 30 is used to define and initialize a knowledge database; Set corresponding embedding vectors for each knowledge fragment in the knowledge database respectively; Determine the weight corresponding to each knowledge fragment based on a function of time and weight; Receive any sample input and set a corresponding query vector for the sample input; Determine a similarity score between the sample input and each knowledge fragment based on the embedding vector, the query vector and the weight; A subset of the knowledge database corresponding to any sample input is determined based on the similarity score, and the knowledge database is constructed by the subsets of multiple knowledge databases.
[0051] In some embodiments, the construction module 30 is used to determine a preset adjustment factor; The weight corresponding to each knowledge fragment is calculated based on the function of time, the function of weight and the preset adjustment factor. The calculation formula is: ,in, and are functions based on time and weight respectively, is the preset adjustment factor, d i For the corresponding knowledge fragment.
[0052] In some embodiments, the construction module 30 is used to calculate the similarity between the sample input and each knowledge fragment based on the embedding vector and the query vector, and the calculation formula is: ,in, is the query vector, is the embedding vector; The similarity score is determined based on the weight and the similarity, and the calculation formula is F= .
[0053] In some embodiments, during the process of autoregressive large model credible decoding, a number of candidate words with the highest probability are selected from the rate distribution; For each candidate word to be generated, determining the distance between each candidate word to be generated and each knowledge fragment in the knowledge database; The probability distributions corresponding to all candidate words among the plurality of candidate words are adjusted based on the distance, and the associations between the candidate words and the respective knowledge fragments are added to the probability distributions of the candidate words to establish the associations between the candidate words and the knowledge fragments.
[0054] An embodiment of the present application also provides a text generation device based on automatic hallucination detection and large models, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus, and the memory is used to store a text generation program based on automatic hallucination detection and large models; the processor is used to implement the above-mentioned text generation method based on automatic hallucination detection and large models when executing the program stored in the memory.
[0055] The communication bus mentioned in the above-mentioned text generation device based on automatic hallucination detection and large models can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0056] The communication interface is used for communication between the above-mentioned text generation device based on automated hallucination detection and large models and other devices.
[0057] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0058] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0059] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0060] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0061] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0062] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
[0063] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0064] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0065] In addition, for technical details not described in detail in this embodiment, please refer to the text generation method based on automatic hallucination detection and large model provided in any embodiment of the present invention, which will not be repeated here.
[0066] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0067] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0068] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0069] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
[0070] It is understandable that the system provided by the embodiment of the present invention corresponds to the method provided by the embodiment of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the above method.
Claims
1. A text generation method based on automated hallucination detection and large models, characterized in that: The text generation method based on automatic hallucination detection and large model includes: Get the initial text of the input; Extracting a number of vocabulary units of the initial text using a word segmenter; Using automated hallucination detection to construct a knowledge database, the knowledge database is composed of a number of knowledge fragments, each of which is associated with a number of candidate words; Determining the similarity between the plurality of vocabulary units and each knowledge fragment; Determine a number of target candidate words based on the similarity; A target text is generated based on the plurality of target candidate words.
2. The text generation method based on automated hallucination detection and large models as claimed in claim 1, characterized in that: The extracting of a plurality of vocabulary units of the initial text by using a word segmenter comprises: Preprocessing the initial text to obtain a processed text; extracting a number of initial words from the processed text using a word segmenter; Filtering the initial words to obtain reference words; The reference words are processed into word units to obtain word units.
3. The text generation method based on automated hallucination detection and large models as claimed in claim 2, characterized in that: The preprocessing of the initial text to obtain a processed text includes: determining the language type of the initial text; Determining stop words in the initial text according to the language type; Identifying high-frequency and low-frequency words in the initial text; The stop words and the high- and low-frequency words are removed from the initial text to obtain a processed text.
4. The text generation method based on automated hallucination detection and large models as claimed in claim 1, characterized in that: The method of constructing a knowledge database using automated hallucination detection includes: Define and initialize the knowledge database; Set corresponding embedding vectors for each knowledge fragment in the knowledge database respectively; Determine the weight corresponding to each knowledge fragment based on a function of time and weight; Receive any sample input and set a corresponding query vector for the sample input; Determine a similarity score between the sample input and each knowledge fragment based on the embedding vector, the query vector and the weight; A subset of the knowledge database corresponding to any sample input is determined based on the similarity score, and the knowledge database is constructed by the subsets of multiple knowledge databases.
5. The text generation method based on automated hallucination detection and large models as claimed in claim 4, characterized in that: The function based on time and weight determines the weight corresponding to each knowledge fragment, including: Determine the preset adjustment factor; The weight corresponding to each knowledge fragment is calculated based on the function of time, the function of weight and the preset adjustment factor. The calculation formula is: ,in, and are functions based on time and weight respectively, is the preset adjustment factor, d i For the corresponding knowledge fragment.
6. The text generation method based on automated hallucination detection and large models as claimed in claim 5, characterized in that: The determining the similarity scores between the sample input and each knowledge fragment based on the embedding vector, the query vector and the weight includes: The similarity between the sample input and each knowledge fragment is calculated based on the embedding vector and the query vector. The calculation formula is: ,in, is the query vector, is the embedding vector; The similarity score is determined based on the weight and the similarity, and the calculation formula is F= .
7. The text generation method based on automated hallucination detection and large models as claimed in claim 4, characterized in that: The method further comprises: In the process of reliable decoding of the autoregressive large model, several candidate words with the highest probability are selected from the rate distribution; For each candidate word to be generated, determining the distance between each candidate word to be generated and each knowledge fragment in the knowledge database; The probability distributions corresponding to all candidate words among the plurality of candidate words are adjusted based on the distance, and the associations between the candidate words and the respective knowledge fragments are added to the probability distributions of the candidate words to establish the associations between the candidate words and the knowledge fragments.
8. A text generation device based on automated hallucination detection and large models, characterized in that: The text generation device based on automatic hallucination detection and large model includes: The acquisition module is used to obtain the initial text input; An extraction module, used for extracting a plurality of vocabulary units of the initial text by using a word segmenter; A construction module, for constructing a knowledge database using automated hallucination detection, wherein the knowledge database is composed of a number of knowledge fragments, each of which is associated with a number of candidate words; A calculation module, used to determine the similarity between the plurality of vocabulary units and each knowledge fragment; A screening module, used for determining a number of target candidate words based on the similarity; An output module is used to generate a target text based on the target candidate words.
9. The text generation device based on automatic hallucination detection and large model as claimed in claim 8, characterized in that: The extraction module is used to pre-process the initial text to obtain a processed text; extracting a number of initial words from the processed text using a word segmenter; Filtering the initial words to obtain reference words; The reference words are processed into word units to obtain word units.
10. The text generation device based on automatic hallucination detection and large model as claimed in claim 9, characterized in that: The extraction module is used to determine the language type of the initial text; Determining stop words in the initial text according to the language type; Identifying high-frequency and low-frequency words in the initial text; The stop words and the high- and low-frequency words are removed from the initial text to obtain a processed text.
Citation Information
Patent Citations
Large model question and answer result optimization method, system and device
CN117540010A
Method and system for generating business arrangement file in field of medical care and health care based on large model
CN118132518A
AI large model enterprise knowledge base system based on cue words
CN119106143A
Cited By
Zero-knowledge scene-oriented large model output content illusion detection method and system
CN120723907A