Large model illusion relieving method and device, medium and product
By employing a joint framework based on reinforcement learning and knowledge graph embedding, high-quality samples are selected and local and global knowledge vectors are fused, thus solving the illusion problem of large language models and improving the accuracy and consistency of generated responses.
Patent Information
- Application Number
- CN202510930348.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-07
- Publication Date
- 2025-10-17
AI Technical Summary
Large language models are prone to hallucinations when generating content, resulting in inconsistencies between the generated content and real-world facts, making it impossible to effectively verify the accuracy of the output.
A sample filter based on reinforcement learning is used to filter meta-knowledge, and a knowledge graph embedding model is used for training. The local knowledge vector and the global knowledge vector are fused together, and the response with the highest probability is selected as the output through a re-ranker to reduce noise interference and improve the generation effect.
It effectively reduces the illusion problem of large models, provides a higher degree of control over the generated response, and enhances the reliability of the generation effect and model behavior.
Smart Images

Figure CN120806038A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a large model hallucination mitigation method, device, medium and product. BACKGROUND
[0002] The emergence of large language models (LLMs) marks a major breakthrough in natural language processing (NLP), leading to a paradigm shift in NLP and making unprecedented progress in language understanding and reasoning. However, in addition to these advances, there is a worrying trend with the rapid development of LLMs, which is the tendency to hallucinate, resulting in generated content that is inconsistent with the facts of the real world or user input. Hallucination generally refers to the phenomenon that the generated content appears ridiculous or not faithful to the source content provided. In general, hallucination in natural language generation tasks can be divided into two main types: internal hallucination and external hallucination. Specifically, internal hallucination refers to output that conflicts with the source content. In contrast, external hallucination refers to output that cannot be verified from the source content. SUMMARY
[0003] The purpose of the present application is to provide a large model hallucination mitigation method, device, medium and product, which can solve the hallucination problem of large language models in the prior art.
[0004] To solve the above problems, the present application provides a large model hallucination mitigation method, comprising:
[0005] obtaining an input sample, the input sample comprising meta-knowledge and a dialogue history;
[0006] using a sample filter based on reinforcement learning to filter the meta-knowledge, and using the filtered meta-knowledge to train a model to obtain a knowledge graph embedding model;
[0007] inputting the dialogue history into the knowledge graph embedding model to obtain a knowledge graph embedding vector output by the knowledge graph embedding model;
[0008] fusing a local knowledge vector and a global knowledge vector according to the knowledge graph embedding vector to obtain a fused knowledge graph vector;
[0009] embedding the fused knowledge graph vector into an encoder-decoder model to obtain a large model.
[0010] In some embodiments, the method further comprises:
[0011] obtaining a plurality of candidate responses output by the large model;
[0012] re-ranker, selecting a response with the highest probability as an output response of the large model.
[0013] In some embodiments, the meta-knowledge includes a plurality of multi-class triple sets classified according to semantic relationships, each triple set including one or more triples; and the reinforcement learning-based sample filter includes a reinforcement learning-based sample filtering agent corresponding to each triple set.
[0014] The filtering of the meta-knowledge using the reinforcement learning-based sample filter includes:
[0015] The initial data set of each triple set is input into the sample filtering agent corresponding to the triple set, and the sample filtering agent filters the initial data set to obtain a sampled data set of the triple set; and the sample quality of the triples in the sampled data set is higher than a target threshold.
[0016] The sample filtering agents corresponding to the triple sets sharing parameters.
[0017] In some embodiments, the model is trained using the filtered meta-knowledge samples to obtain a knowledge graph embedding model, including:
[0018] The model is trained using the sampled data sets corresponding to the multi-class triple sets to obtain the knowledge graph embedding model.
[0019] In some embodiments, the method further includes:
[0020] According to the performance of the knowledge graph embedding model, a delayed reward is obtained;
[0021] The delayed reward is fed back to the sample filtering agent, and the sample filtering agent updates the parameters of the sample filtering agent according to the delayed reward.
[0022] In some embodiments, before the fusion of the local knowledge vector and the global knowledge vector according to the knowledge graph embedding vector to obtain a fused knowledge graph vector, the method further includes:
[0023] The knowledge graph embedding vector is fused into a text embedding vector in the dialogue history through entity and relationship linking to obtain the local knowledge vector.
[0024] In some embodiments, before the fusion of the local knowledge vector and the global knowledge vector according to the knowledge graph embedding vector to obtain a fused knowledge graph vector, the method further includes:
[0025] drawing global dependency between the dialogue history and the knowledge graph embedding vector using an attention mechanism;
[0026] aggregating the knowledge graph embedding vector according to the global dependency to obtain the global knowledge vector.
[0027] In some embodiments, the re-ranker includes a session reasoning model and a sentence encoder;
[0028] The re-ranker is used to rank the plurality of candidate responses, and the response with the highest probability is selected as the output response of the large model, including:
[0029] The semantic embedding vector of the dialogue history and the plurality of candidate responses are obtained by the sentence encoder;
[0030] The semantic embedding vector, the plurality of candidate responses, and the knowledge graph embedding vector are input into the session reasoning model to obtain the probability of each candidate response output by the session reasoning model;
[0031] The plurality of candidate responses are ranked according to the probability, and the response with the highest probability is selected as the output response of the large model.
[0032] In some embodiments, before obtaining the plurality of candidate responses output by the large model, the method includes:
[0033] Obtaining the keywords of the query text input by the user;
[0034] Extracting the triplets of the keywords from the knowledge graph;
[0035] Inputting the triplets into a knowledge graph embedding model to obtain an embedding vector output by the knowledge graph embedding model;
[0036] Fusing the text embedding vector in the dialogue history and the embedding vector output by the knowledge graph embedding model to obtain the plurality of candidate responses.
[0037] Embodiments of the present application also provide a large model hallucination mitigation device, including a processor and a transceiver, the transceiver receives and sends data under the control of the processor, and the processor is used to perform the following operations:
[0038] Obtaining an input sample, the input sample including meta-knowledge and dialogue history;
[0039] Filtering the meta-knowledge using a reinforcement learning-based sample filter, and training a model using the filtered meta-knowledge to obtain a knowledge graph embedding model;
[0040] input the dialogue history into the knowledge graph embedding model, obtain a knowledge graph embedding vector output by the knowledge graph embedding model;
[0041] fuse the local knowledge vector and the global knowledge vector according to the knowledge graph embedding vector, to obtain a fused knowledge graph vector;
[0042] embed the fused knowledge graph vector into an encoder-decoder model, to obtain a large model.
[0043] In some embodiments, the processor is further configured to perform the following operations:
[0044] obtain a plurality of candidate responses output by the large model;
[0045] sort the plurality of candidate responses using a re-ranker, and select a response with the highest probability as an output response of the large model.
[0046] In some embodiments, the meta-knowledge includes a plurality of sets of multi-class triples classified according to semantic relationships, and each set of multi-class triples includes one or more triples; and the sample filter based on reinforcement learning includes a sample filter agent based on reinforcement learning corresponding to each set of multi-class triples.
[0047] The processor is further configured to perform the following operations:
[0048] input an initial data set of each set of multi-class triples into the sample filter agent corresponding to the set of multi-class triples, and the sample filter agent filters the initial data set to obtain a sampled data set of the set of multi-class triples; and the sample quality of the triples in the sampled data set is higher than a target threshold.
[0049] The sample filter agents corresponding to the sets of triples related by semantics share parameters.
[0050] In some embodiments, the processor is further configured to perform the following operations:
[0051] perform model training using the sampled data sets corresponding to the plurality of sets of multi-class triples respectively, to obtain the knowledge graph embedding model.
[0052] In some embodiments, the processor is further configured to perform the following operations:
[0053] obtain a delayed reward according to the performance of the knowledge graph embedding model;
[0054] feed back the delayed reward to the sample filter agent, and update the parameters of the sample filter agent according to the delayed reward.
[0055] In some embodiments, the processor is further configured to perform the following operations:
[0056] The knowledge graph embedding vector is fused into a text embedding vector in the dialogue history by entity and relationship linking to obtain the local knowledge vector.
[0057] In some embodiments, the processor is further configured to perform the following operations:
[0058] A global dependency relationship between the dialogue history and the knowledge graph embedding vector is drawn using an attention mechanism;
[0059] The knowledge graph embedding vector is aggregated according to the global dependency relationship to obtain the global knowledge vector.
[0060] In some embodiments, the re-ranker includes a session reasoning model and a sentence encoder;
[0061] The processor is further configured to perform the following operations:
[0062] A semantic embedding vector of the dialogue history and the plurality of candidate responses are obtained by the sentence encoder;
[0063] The semantic embedding vector, the plurality of candidate responses, and the knowledge graph embedding vector are input into a session reasoning model to obtain probabilities of the respective candidate responses output by the session reasoning model;
[0064] The plurality of candidate responses are ranked according to the probabilities, and a response with the highest probability is selected as an output response of the large model.
[0065] In some embodiments, the processor is further configured to perform the following operations:
[0066] A keyword of query text input by a user is obtained;
[0067] A triple of the keyword is extracted from a knowledge graph;
[0068] The triple is input into a knowledge graph embedding model to obtain an embedding vector output by the knowledge graph embedding model;
[0069] A text embedding vector in a dialogue history and the embedding vector output by the knowledge graph embedding model are fused to obtain the plurality of candidate responses.
[0070] Embodiments of the present application also provide a communication device including a memory, a processor, and a program stored in the memory and executable on the processor, wherein the processor implements the large model hallucination mitigation method as described above when executing the program.
[0071] The embodiment of the application further provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to realize the steps in the large model illusion alleviating method.
[0072] The embodiment of the application further provides a computer program product, which comprises computer instructions, and the computer instructions are executed by a processor to realize the steps in the large model illusion alleviating method.
[0073] The above technical solutions of the application have at least the following beneficial effects:
[0074] In the large model illusion alleviating method, device, medium and product of the embodiment of the application, a joint framework based on reinforcement learning and a knowledge graph embedding model is proposed, after inputting a sample into the joint framework, first, a sample filter based on reinforcement learning is used for noise filtering, and only high-quality training samples are reserved. The training set after filtering is used for model training to obtain a knowledge graph embedding model; the joint framework can reduce the interference of data noise on the knowledge graph embedding method; and the application further obtains a knowledge graph embedding vector through the knowledge graph embedding model, and the generation effect of the large model is enhanced through the fusion of local knowledge vectors and global knowledge vectors, a higher degree of control over the behavior of the large model is provided, and the illusion problem of the large model is alleviated. BRIEF DESCRIPTION OF DRAWINGS
[0075] Figure 1 A step flowchart of the large model illusion alleviating method provided by the embodiment of the application is shown;
[0076] Figure 2 An example diagram of the joint framework of the large model illusion alleviating method provided by the embodiment of the application is shown;
[0077] Figure 3 An example diagram of the sample filter based on reinforcement learning and the knowledge graph embedding model in the large model illusion alleviating method provided by the embodiment of the application is shown;
[0078] Figure 4 An example diagram of the re-ranker in the large model illusion alleviating method provided by the embodiment of the application is shown;
[0079] Figure 5 A structural schematic diagram of the large model illusion alleviating device provided by the embodiment of the application is shown. DETAILED DESCRIPTION
[0080] To make the technical problems, technical solutions and advantages of the application clearer, the following will be described in detail with reference to the drawings and specific embodiments.
[0081] As shown in Figure 1 the embodiment of the application provides a large model illusion alleviating method, comprising:
[0082] Step 101, obtaining an input sample, the input sample comprising meta-knowledge and a dialogue history;
[0083] Step 102, screening the meta-knowledge using a sample filter based on reinforcement learning, and training a model using the screened meta-knowledge to obtain a knowledge graph embedding model;
[0084] Step 103, inputting the dialogue history into the knowledge graph embedding model to obtain a knowledge graph embedding vector output by the knowledge graph embedding model;
[0085] Step 104, fusing a local knowledge vector and a global knowledge vector according to the knowledge graph embedding vector to obtain a fused knowledge graph vector;
[0086] Step 105, embedding the fused knowledge graph vector into an encoder-decoder model to obtain a large model.
[0087] The embodiment of the application fully considers the real scene demand of designing a more accurate large model in the era of large models in various fields, and proposes a large model illusion alleviation method based on reinforcement learning and knowledge graph embedding in view of the current widespread large model illusion problem.
[0088] Part of the illusion is only because the model falls into the mode of wanting to give a complete answer or does not know how to express uncertainty, so this kind of illusion can be easily solved. For example, some demonstrations showing that I don't know, my knowledge is limited to a certain date can be given when training the model, or some examples of questioning the user's question can be given, so that the model can at least express uncertainty. How to master this degree is a problem to be solved by reinforcement learning. If the model gives an answer, if it is a very confident correct answer, it will get a high reward; if it is a fuzzy correct answer, it will get a slightly worse reward; if it is an answer with no information, for example, I don't know, it will get some punishment; if it is a fuzzy wrong answer and a completely wrong answer, it will get more punishment. This is basically a proper scoring rule that can encourage the model to give a confident answer, and if it is too confident about the wrong answer, it will be given the corresponding punishment.
[0089] Among them, the knowledge graph (Knowledge Graph, KG) is an organized collection of data, including detailed information about entities (such as people, places, or objects), their characteristics, and their connections. It arranges data so that machines can understand the relationship and semantic meaning of the material. Knowledge graph provides a foundation for complex reasoning, data analysis and information retrieval. In order to deal with the illusion problem in generation, the representation of related entities and relationship predicates in the knowledge graph is used to generate more faithful responses. In order to improve the fidelity, local knowledge vectors and global knowledge vectors are introduced into the generation, and further reasoning models are used to reorder the generated responses. This method can help the model to effectively encode and inject knowledge information from related subgraphs, and give appropriate attention. Through various knowledge bases and reasoning techniques, the fusion and interaction between contexts are improved, and the illusion is further reduced.
[0090] Because of the existence of potential data noise in the knowledge graph and the display noise introduced during training, the quality of the vector representation is affected, which greatly reduces the performance of the model. The embodiment of the present application proposes a joint framework based on reinforcement learning and knowledge graph embedding model, aiming to improve the sample quality and the training effect of the knowledge graph embedding model. Reinforcement learning is widely used to improve the training quality of the model, and the embodiment of the present application proposes to combine reinforcement learning and knowledge graph embedding to build a joint framework. After the data set (i.e. input sample) is input into the joint framework, first, the reinforcement learning Agent filters the noise, and only the high-quality input sample is retained. The training set after filtering is input into the knowledge graph embedding model for training, and the training result of the model is fed back to the reinforcement learning Agent as the reward of the reinforcement learning strategy. Compared with other methods, this joint training framework can reduce the interference of data noise on the knowledge graph embedding method to a certain extent.
[0091] Optionally, the overall framework of the large model illusion alleviation method based on reinforcement learning and knowledge graph embedding model is as shown in Figure 2 The input (Input) includes meta-knowledge and dialogue history (Dialogue History, DH), specifically, the composition of the input sample is as follows: dialogue history, which is the record of previous interaction between the system and the user, contains the context information; meta-knowledge, this part of information provides the knowledge background related to the current dialogue, including triple entities, relationship information and other information in the knowledge graph. When processing these input samples, first, the embedding vector of the knowledge graph is obtained through the TransE (classic model for knowledge graph embedding) algorithm, and then the fusion of local knowledge vectors and global knowledge vectors is performed to enhance the knowledge base of text embedding.
[0092] In at least one embodiment of the present application, the method further comprises:
[0093] obtain a plurality of candidate responses of the large model output;
[0094] re-rank the plurality of candidate responses using a re-ranker to select a response with the highest probability as an output response of the large model.
[0095] To improve the knowledge base, first, a sample selector based on reinforcement learning is used to screen knowledge samples, and the knowledge graph embedding model is trained using the screened knowledge samples to obtain the knowledge graph embedding model. The training text is input into the knowledge graph embedding model to obtain the knowledge graph vector, which is stored in the knowledge graph KG embedding database. For local knowledge vectors, the corresponding knowledge graph vectors are embedded into the text embedding using entity / relation linking. For global knowledge vectors, the entire knowledge graph vector is aggregated in the memory bank through an attention mechanism to embed the text, so that the obtained knowledge graph vector receives all the context-related knowledge. The final knowledge graph vector is embedded in the encoder-decoder model to enhance the large model. Then, the encoder-decoder model generates several candidate responses. In the post-processing process, the re-ranker is used to re-rank the candidate responses. The re-ranker is trained based on the knowledge subgraph conditioned on the dialogue context to select the most reliable response as the final output.
[0096] The embodiments of the present application provide a joint framework and solve the large model hallucination problem through three mechanisms: local knowledge base, global knowledge base, and response re-ranking. This method can effectively reduce hallucination and also perform in-depth error analysis on the generated responses. Other mainstream methods, such as improving the decoding method, will introduce computational overhead, increasing the training time delay. This method not only enhances the generation effect of the model, but also provides a higher degree of control over the behavior of the model, greatly alleviating the hallucination problem.
[0097] As shown in Figure 3 The combination of reinforcement learning and knowledge graph embedding mainly includes two main components. The first part is a reinforcement learning-based sample selector, which samples and screens high-quality training samples by defining an agent for each type of relationship; the second part is a knowledge graph embedding model that evaluates the quality of the sampled samples after training and feeds back the delayed reward to the agent. Among them, Figure 3 The information in the table is as follows:
[0098] Parameters Shared Among Agents Parameters Shared Among Agents
[0099] Head and Tail Entities of Triples with Relationship r1 Head and Tail Entities of Triples with Relationship r1
[0100] Head and Tail Entities of Triples with Relationship r2 Head and Tail Entities of Triples with Relationship r2
[0101] Set of Triples with Relationship r1 Set of Triples with Relationship r1
[0102] Set of Triples with Relationship r2 Set of Triples with Relationship r2
[0103] Knowledge Graph Knowledge Graph
[0104] Initial Dataset for Relationship r1 Initial Dataset for Relationship r1
[0105] Initial Dataset for Relationship r2 Initial Dataset for Relationship r2
[0106] Input Input
[0107] Delayed Reward Delayed Reward
[0108] Sample Selection Agent1 Sample Selection Agent1
[0109] Sample Selection Agent2 Sample Selection Agent2
[0110] Select Select
[0111] Filter Filter
[0112] Action Action
[0113] Score Score
[0114] Sampled Dataset for Relationship r1 represents a sampled dataset for relationship r1;
[0115] Sampled Dataset for Relationship r2 represents a sampled dataset for relationship r2;
[0116] Knowledge Graph Embedding Model represents a knowledge graph embedding model.
[0117] In at least one embodiment of the present application, the meta-knowledge includes a plurality of sets of classified triples according to relationships, each set of classified triples including one or more triples; the sample filter based on reinforcement learning includes a sample filtering agent based on reinforcement learning corresponding to each set of classified triples; accordingly, the step 102 of filtering the meta-knowledge using the sample filter based on reinforcement learning includes:
[0118] inputting an initial dataset of each set of classified triples into the sample filtering agent corresponding to the set of classified triples, the sample filtering agent filtering the initial dataset to obtain a sampled dataset of the set of classified triples; wherein the sample quality of the triples in the sampled dataset is higher than a target threshold;
[0119] wherein the sample filtering agents corresponding to the sets of semantically related triples share parameters.
[0120] Further, the step 102 of using the filtered meta-knowledge samples for model training to obtain a knowledge graph embedding model includes:
[0121] using the sampled datasets corresponding to the plurality of sets of classified triples respectively for model training to obtain the knowledge graph embedding model.
[0122] Optionally, the method further includes:
[0123] obtaining a delayed reward according to the performance of the knowledge graph embedding model;
[0124] feeding back the delayed reward to the sample filtering agent, and updating the parameters of the sample filtering agent according to the delayed reward.
[0125] For example, Figure 3 The overall execution process of the model shown is as follows:
[0126] (1) The triples in the knowledge graph are classified according to the relationship and input into the filter as the learning environment of the reinforcement learning Agent. The sample filter defines a reinforcement learning Agent for each set of triples of the relationship to sample and filter the samples. Considering the semantic correlation between the relationships in the knowledge graph, part of the parameters between the Agents corresponding to the semantically related relationships are shared. Through parameter sharing, the Agent can learn more semantic information to better judge the quality of the candidate triples.
[0127] (2) The reinforcement learning Agent makes a decision on the candidate triple based on the current state, i.e. the vector representation of the relationship, head entity and tail entity of the triple, and the vector representation of the sampled triples. If the candidate triple is of high quality and is judged by the Agent to be able to optimize the training quality of the knowledge graph embedding model, the triple is retained for training of the knowledge graph embedding model; if the candidate triple is evaluated as low quality or judged as noise, the triple is filtered. For example, when sampling and processing all triples of a relationship, the Agent evaluates the quality of the triples by traversing all the triples. Each triple sampled by the sample filter is evaluated based on the scoring function of the knowledge graph embedding model, f(h, r, t) is the scoring function for calculating the quality of the sample, different knowledge graph embedding models have different scoring functions, such as TransE which performs vector operation on the rule h+r=t. The model does not tend to retain only a few high-score triples, ensuring a sufficient proportion of training samples, thereby ensuring the balance of the training data of the knowledge graph embedding model.
[0128] (3) After the reinforcement learning Agent completes the sampling and filtering of all triples of the same relationship, the knowledge graph embedding model is trained based on the cleaned training data set.
[0129] (4) The delayed reward is obtained according to the performance of the knowledge graph embedding model, the reward is fed back to the filter to update the corresponding reinforcement learning Agent parameters, and then step (2) is continued. Finally, in a complete training batch, the reinforcement learning-based sample filter completes the filtering of all triples in the knowledge graph.
[0130] (5) Repeat the above training process to obtain better reinforcement learning Agent performance for sample quality evaluation.
[0131] The model can effectively select high-quality samples from the triples in the knowledge graph, improve the signal-to-noise ratio of the data set, and thus optimize the training effect of the knowledge graph embedding model. The knowledge graph embedding model calculates the delayed reward feedback to the filter according to the quality of the filtered samples, thereby optimizing the performance of the reinforcement learning Agent and improving the accuracy of the sample quality evaluation.
[0132] In an implementation, high-quality training samples are obtained by defining an Agent for each type of relationship for sample sampling screening. The model models this sampling process as a Markov process, and constructs the core framework of the sample screening filter based on reinforcement learning. Specifically, the state transition process is as follows:
[0133] (1) s t represents the state at time t, which includes: the vector representation of the head entity, tail entity and relationship of the current triple, and the vector representation mean of the current sampled triple.
[0134] (2) a t represents the decision made by the Agent at time t according to the state s t The Agent learns how to choose the optimal action strategy according to the current state and the reward value obtained, so as to maximize the reward. After the action is executed, the state is transformed into s t+1 .
[0135] (3) R t represents the reward obtained after the action a t is executed at time t.
[0136] (4) s t+1 represents the state at time t+1.
[0137] The embodiments of the present application do not limit specific knowledge graph embedding models, so as to expand and adapt to mainstream knowledge graph embedding models such as TransE, DistMult, and ConvE. TransE is a knowledge graph embedding model based on a vector space model; DistMult is a knowledge graph embedding model based on tensor decomposition, which embeds each entity and relationship into a low-dimensional vector space and uses tensor multiplication for calculation; ConvE models the interaction between input entities and relationships through convolution layers and fully connected layers.
[0138] In at least one embodiment of the present application, before the fusion of the local knowledge vector and the global knowledge vector to obtain the fused knowledge graph vector according to the knowledge graph embedding vector, the method further comprises:
[0139] The knowledge graph embedding vector is fused into the text embedding vector in the dialogue history through entity and relationship links to obtain the local knowledge vector.
[0140] For example, a set of entity and relationship link mentions is obtained from the historical dialogue, and the knowledge graph embedding is as follows:
[0141] (1) The entity mention e H present in the dialogue history H is identified, which can be linked to the entity e in the subgraph G m.
[0142] (2) Since the relationship between entities is crucial for knowledge reasoning in PLM, the relationship in H is also mentioned in r m Link to G H The relational predicate r in .
[0143] (3) Use TransE to learn knowledge graph embeddings of entity and relation predicates from the entire graph.
[0144] Then, we get the local basis token embedding of any non-special token w in H. Where M(·) transforms the space from knowledge graph embedding to PLM token embedding. The typical way to implement M(·) is through a mapping matrix. Specifically, if dim(w) = dim(e G ), then M(·) can be further simplified to an identity mapping. substr(w,E H ) is a Boolean indicator if the current mark w is E H Any e m If it is a substring of local Fused into the common token embedding w, tokens related to specific entities or relation predicates can be grounded by their respective knowledge graph embeddings. This approach is local because w local It is only related to the knowledge graph embedding of the corresponding node.
[0145] In another optional embodiment of the present application, before fusing the local knowledge vector and the global knowledge vector based on the knowledge graph embedding vector to obtain the fused knowledge graph vector, the method further includes:
[0146] Using an attention mechanism to draw global dependencies between the conversation history and the knowledge graph embedding vector;
[0147] The knowledge graph embedding vectors are aggregated according to the global dependency to obtain the global knowledge vector.
[0148] In the embodiment of the present application, focusing only on a single token in the context and a single node in the graph is not enough to enhance the multi-hop reasoning capability of the dialogue system. In addition to the local basis (i.e., local knowledge vector), a global knowledge basis (i.e., global knowledge vector) is also proposed, which enriches the consideration of the entire subgraph G H semantics, thus providing the model with a comprehensive view of background knowledge.
[0149] This embodiment of the application uses an attention mechanism to draw the conversation history H and store G H The global dependency between all knowledge triples in memory. Let T H GH A set of all triples in the knowledge graph. The memory stores |T H | embedding vectors, where the i-th vector v i corresponds to the KG embedding of the i-th relation triple Tj. Here, all vectors are collected and further projected to a global knowledge embedding space.
[0150]
[0151] The formula W{proj} is a learnable projection matrix, and the i-th vector vi corresponds to the KG embedding of the i-th relation triple, where is a concatenation operator of vectors.
[0152] Based on the formula of K H , the attention degree of the current token w in H to each relation triple is calculated according to the semantic correlation, and the global basic token embedding w global is obtained.
[0153] Finally, the encoder sums up the normal token embedding w, the local basic embedding w local and the global basic embedding w global : w = w + w local + w global . During the training process, although w is updated quickly through back propagation, w local and w global are relatively fixed, and there are few trainable parameters.
[0154] Embodiments of the present application expand the knowledge graph in order to enhance the ability to reduce hallucinations, and train a conversation reasoning model in order to respond to re-ranking. If the generated response can be reasoned backward to the source, it can be assumed to be reliable. The conversation reasoning model is trained based on a long short-term memory network (LSTM) and learns the probability of walking based on a subgraph of the knowledge graph on a given dialogue history and possible responses. The conversation reasoning model is used to re-rank the generated candidate replies, selects the reply that best matches the knowledge graph subgraph as the final output, improves the reliability and consistency of the dialogue system by simulating possible walk paths on the knowledge graph and using the semantic embedding provided by the context sentence encoder to evaluate and re-rank the generated replies.
[0155] In an implementation manner, the re-ranker includes a conversation reasoning model and a sentence encoder;
[0156] The re-ranker is used to sort the plurality of candidate responses, and the response with the highest probability is selected as the output response of the large model, including:
[0157] The semantic embedding vector of the dialogue history and the plurality of candidate responses are obtained through the sentence encoder;
[0158] The semantic embedding vector, the plurality of candidate responses, and the knowledge graph embedding vector are input into a conversation inference model, and a probability of each candidate response output by the conversation inference model is obtained;
[0159] The plurality of candidate responses are ranked according to the probability, and a response with the highest probability is selected as an output response of the large model.
[0160] Optionally, the probability is a probability of walks based on a subgraph of a knowledge graph.
[0161] As shown in the following formula (1), Entity / Relation Linking refers to entity / relation linking, and KG Embedding refers to knowledge graph embedding. A semantic embedding (Textual Embedding) of a dialogue history H and a possible response R are obtained through a context sentence encoder (namely, Sentence Encoder). The conversation inference model is a decoder based on Bi-LSTM. Compared with a unidirectional LSTM network, since Bi-LSTM simultaneously considers forward and backward historical context information, not only forward information can be used to predict a current label, but also backward information can be used, so that context modeling can be more comprehensive for a sentence level task. It learns a probability p t of an action t t under the condition of a state s H of a given step t. Here, the action refers to a walking step on a graph G t , denoted as a S , which is a concatenation of a relationship and entity embedding derived from a knowledge graph and a semantic embedding based on Sentence-BERT.
[0162] e S and r t are semantic sentence embeddings of an entity e and a relationship predicate r respectively. The state s t-1 contains a representation of a dialogue history, and entities and relationships that have been traversed by an action history. It is defined as a tuple (H, (a1, a2,..., a H )). Therefore, the model explicitly simulates a G t traversal process conditioned on a dialogue history H and a possible response R. In the training process, each action a H made by the model is combined into a path, and a target path is a given context-related subgraph G N .
[0163] In the encoder-decoder model, N candidate responses {R1,..., RN}After that, the best response with the highest probability is selected from all generated responses as the output response of the large model.
[0164] In at least one embodiment of the present application, before obtaining the plurality of candidate responses output by the large model, the method further comprises:
[0165] Obtaining the keywords of the query text input by the user;
[0166] Extracting triples of the keywords from the knowledge graph;
[0167] Inputting the triples into a knowledge graph embedding model to obtain an embedding vector output by the knowledge graph embedding model;
[0168] Fusing the text embedding vector in the dialogue history and the embedding vector output by the knowledge graph embedding model to obtain the plurality of candidate responses.
[0169] For example, the large model can generate fluent and informative responses. However, these models are still prone to hallucinated responses that are not supported by the input source, which greatly hinders their application. The heterogeneity between external knowledge and dialogue context is one of the reasons for this phenomenon. For example, the system receives the user input: “I want to read a novel about rural themes”; identifies the keywords: “rural themes”, “novel”; extracts relevant triples from the knowledge graph according to the identified keywords; converts the extracted triples into embedding vector representation using the TransE algorithm; fuses the text embedding vector of the dialogue history with the embedding vector of the knowledge graph; generates a response; the system returns the generated response: “You can read “Red Sorghum”, which is a novel about rural themes written by Mo Yan”. According to automatic and manual evaluation, the method provided by the embodiments of the present application can effectively reduce hallucination.
[0170] In summary, the embodiments of the present application provide a large model based on reinforcement learning and knowledge graph embedding. On the one hand, the large model can effectively select high-quality samples from knowledge graph triples, improve the signal-to-noise ratio of the data set, and thus optimize the training effect of the knowledge graph embedding model. The knowledge graph embedding model feeds back the delay reward according to the quality of the selected samples to the filter, thereby optimizing the performance of the reinforcement learning, improving the accuracy of sample quality evaluation, and alleviating the hallucination problem caused by data quality as much as possible; on the other hand, three mechanisms are used to solve the hallucination problem of the large model: local knowledge base, global knowledge base and response reordering. This method can effectively reduce hallucination and also perform in-depth error analysis on the generated response, thereby providing a higher degree of control over the behavior of the model.
[0171] As Figure 5As shown, the embodiment of the present application also provides a large model hallucination mitigation device, comprising a processor 500 and a transceiver 510, the transceiver 510 receives and sends data under the control of the processor 500, and the processor 500 is used to perform the following operations:
[0172] Obtain an input sample, the input sample comprising meta-knowledge and a dialogue history;
[0173] Filter the meta-knowledge using a reinforcement learning-based sample filter, and train a model using the filtered meta-knowledge to obtain a knowledge graph embedding model;
[0174] Input the dialogue history into the knowledge graph embedding model to obtain a knowledge graph embedding vector output by the knowledge graph embedding model;
[0175] Fuse the knowledge graph embedding vector to obtain a fused knowledge graph vector according to the knowledge graph embedding vector;
[0176] Embed the fused knowledge graph vector into an encoder-decoder model to obtain a large model.
[0177] In some embodiments of the present application, the processor is further configured to perform the following operations:
[0178] Obtain a plurality of candidate responses output by the large model;
[0179] Sort the plurality of candidate responses using a re-ranker, and select a response with the highest probability as an output response of the large model.
[0180] In some embodiments of the present application, the meta-knowledge comprises a plurality of sets of multi-class triples classified according to relationships, and each set of multi-class triples comprises one or more triples; and the reinforcement learning-based sample filter comprises a reinforcement learning-based sample filtering agent corresponding to each set of multi-class triples;
[0181] The processor is further configured to perform the following operations:
[0182] Input an initial data set of each set of multi-class triples into the sample filtering agent corresponding to the set of multi-class triples, and the sample filtering agent filters the initial data set to obtain a sampled data set of the set of multi-class triples; wherein the sample quality of the triples in the sampled data set is higher than a target threshold;
[0183] Wherein, the sample filtering agents corresponding to the sets of triples related in semantics share parameters.
[0184] In some embodiments of the present application, the processor is further configured to perform the following operations:
[0185] perform model training on the sample data sets respectively corresponding to the multi-class triple sets, to obtain the knowledge graph embedding model.
[0186] In some embodiments of the present application, the processor is further configured to perform the following operations:
[0187] obtain a delayed reward according to the performance of the knowledge graph embedding model;
[0188] feed the delayed reward back to the sample screening agent, and update the parameters of the sample screening agent according to the delayed reward.
[0189] In some embodiments of the present application, the processor is further configured to perform the following operations:
[0190] fuse the knowledge graph embedding vector into a text embedding vector in the dialogue history through entity and relationship linking, to obtain the local knowledge vector.
[0191] In some embodiments of the present application, the processor is further configured to perform the following operations:
[0192] draw a global dependency relationship between the dialogue history and the knowledge graph embedding vector using an attention mechanism;
[0193] aggregate the knowledge graph embedding vector according to the global dependency relationship, to obtain the global knowledge vector.
[0194] In some embodiments of the present application, the re-ranker comprises a session reasoning model and a sentence encoder.
[0195] The processor is further configured to perform the following operations:
[0196] obtain a semantic embedding vector of the dialogue history and the plurality of candidate responses through the sentence encoder;
[0197] input the semantic embedding vector, the plurality of candidate responses, and the knowledge graph embedding vector into a session reasoning model, to obtain a probability of each candidate response output by the session reasoning model;
[0198] rank the plurality of candidate responses according to the probability, and select the response with the highest probability as the output response of the large model.
[0199] In some embodiments of the present application, the processor is further configured to perform the following operations:
[0200] obtain a keyword of the query text input by the user;
[0201] extract a triple of the keyword from a knowledge graph;
[0202] inputting the triple into a knowledge graph embedding model, and obtaining an embedding vector output by the knowledge graph embedding model;
[0203] fusing the text embedding vector in the dialogue history and the embedding vector output by the knowledge graph embedding model to obtain the plurality of candidate responses.
[0204] The embodiment of the present application provides a large model based on reinforcement learning and knowledge graph embedding. On the one hand, the large model can effectively select high-quality samples from knowledge graph triples, improve the signal-to-noise ratio of the data set, and thus optimize the training effect of the knowledge graph embedding model. The knowledge graph embedding model calculates a delay reward feedback to the filter according to the quality of the selected samples, thereby optimizing the performance of the reinforcement learning, improving the accuracy of the sample quality evaluation, and alleviating the illusion problem caused by the data quality as much as possible. On the other hand, the large model illusion problem is solved through three mechanisms: local knowledge base, global knowledge base, and response reordering. This method can effectively reduce the illusion and perform in-depth error analysis on the generated responses, thereby providing a higher degree of control over the model behavior.
[0205] It should be noted that the large model illusion alleviation device provided by the embodiment of the present application is a device capable of executing the above-mentioned large model illusion alleviation method, and all embodiments of the above-mentioned large model illusion alleviation method are applicable to the device and can achieve the same or similar beneficial effects. Here, it is not repeated.
[0206] The embodiment of the present application also provides a communication device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the program to realize each process in the embodiment of the large model illusion alleviation method described above and can achieve the same technical effect. To avoid repetition, it is not repeated here.
[0207] The embodiment of the present application also provides a computer readable storage medium having a computer program stored thereon. The program is executed by a processor to realize each process in the embodiment of the large model illusion alleviation method described above and can achieve the same technical effect. To avoid repetition, it is not repeated here. The computer readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0208] The embodiment of the present application also provides a computer program product including computer instructions. The computer instructions are executed by a processor to realize each process in the embodiment of the large model illusion alleviation method described above and can achieve the same technical effect. To avoid repetition, it is not repeated here.
[0209] Those skilled in the art will appreciate that embodiments of the application can be readily used as a method, apparatus or computer program product. Accordingly, the application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the application can take the form of a computer program product on one or more computer readable storage media (including, but not limited to, magnetic disks or optical storage) embodying computer program code thereon.
[0210] The present application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 The flowchart illustrations and / or block diagrams in accordance with embodiments of the application also illustrate the architecture, functionality, and operation of possible implementations of apparatuses and computer program products according to the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more
[0211] These computer program instructions can also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instructions which implement the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 The flowchart illustrations and / or block diagrams in accordance with embodiments of the application also illustrate the architecture, functionality, and operation of possible implementations of apparatuses and computer program products according to the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more Figure 1 The flowchart illustrations and / or block diagrams in accordance with embodiments of the application also illustrate the architecture, functionality, and operation of possible implementations of apparatuses and computer program products according to the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more
[0212] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 The flowchart illustrations and / or block diagrams in accordance with embodiments of the application also illustrate the architecture, functionality, and operation of possible implementations of apparatuses and computer program products according to the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more Figure 1 The flowchart illustrations and / or block diagrams in accordance with embodiments of the application also illustrate the architecture, functionality, and operation of possible implementations of apparatuses and computer program products according to the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more
[0213] The above description is the preferred embodiment of the present application. It is to be understood that the application need not be limited to one or more particular variants, modifications and / or alterations of the principles, concepts, and features described herein, as various changes can be made and still obtain a result within the scope of the application, without departing from the spirit and scope of the application.
Claims
1. A method for alleviating large model hallucinations, characterized in that: include: Obtaining an input sample, wherein the input sample includes: meta-knowledge and conversation history; Using a sample filter based on reinforcement learning to filter the meta-knowledge, and using the filtered meta-knowledge to train a model to obtain a knowledge graph embedding model; Inputting the conversation history into the knowledge graph embedding model to obtain the knowledge graph embedding vector output by the knowledge graph embedding model; According to the knowledge graph embedding vector, the local knowledge vector and the global knowledge vector are fused to obtain a fused knowledge graph vector; The fused knowledge graph vector is embedded into the encoder-decoder model to obtain a large model.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining multiple candidate responses output by the large model; The plurality of candidate responses are ranked using a re-ranker, and a response with the highest probability is selected as the output response of the large model.
3. The method according to claim 1, characterized in that The meta-knowledge includes multiple types of triple sets classified according to semantic relationships, and each type of triple set includes one or more triples; The sample filter based on reinforcement learning includes: a sample filter agent based on reinforcement learning corresponding to each type of triple set; The use of a sample filter based on reinforcement learning to filter the meta-knowledge includes: Inputting the initial data sets of each type of triple set into the sample screening agent corresponding to the triple set of that type, the sample screening agent screening the initial data sets to obtain a sample data set of the triple set of that type; wherein the sample quality of the triples in the sample data set is higher than the target threshold; Among them, parameters are shared between sample screening agents corresponding to semantically related triple sets.
4. The method according to claim 3, characterized in that The model is trained using the filtered meta-knowledge samples to obtain a knowledge graph embedding model, including: The model is trained using the sampling data sets corresponding to the multiple types of triple sets to obtain the knowledge graph embedding model.
5. The method according to claim 4, characterized in that The method further comprises: Obtaining delayed rewards based on the performance of the knowledge graph embedding model; The delayed reward is fed back to the sample screening agent, and the sample screening agent updates the parameters of the sample screening agent according to the delayed reward.
6. The method according to any one of claims 1 to 5, characterized in that Before fusing the local knowledge vector and the global knowledge vector based on the knowledge graph embedding vector to obtain the fused knowledge graph vector, the method further includes: The knowledge graph embedding vector is fused into the text embedding vector in the conversation history through entity and relationship links to obtain the local knowledge vector.
7. The method according to any one of claims 1 to 5, characterized in that Before fusing the local knowledge vector and the global knowledge vector based on the knowledge graph embedding vector to obtain the fused knowledge graph vector, the method further includes: Using an attention mechanism to draw global dependencies between the conversation history and the knowledge graph embedding vector; The knowledge graph embedding vectors are aggregated according to the global dependency to obtain the global knowledge vector.
8. The method according to claim 2, characterized in that The re-ranker includes a conversational reasoning model and a sentence encoder; The step of ranking the plurality of candidate responses using a reranker and selecting the response with the highest probability as the output response of the large model includes: Obtaining, by the sentence encoder, a semantic embedding vector of the conversation history and the plurality of candidate responses; Inputting the semantic embedding vector, the multiple candidate responses, and the knowledge graph embedding vector into a conversational reasoning model to obtain the probability of each candidate response output by the conversational pushing model; The multiple candidate responses are sorted according to the probabilities, and the response with the highest probability is selected as the output response of the large model.
9. The method according to claim 2, characterized in that Before obtaining a plurality of candidate responses output by the large model, the method includes: Get the keywords of the query text entered by the user; Extracting triples of the keywords from the knowledge graph; Input the triple into the knowledge graph embedding model to obtain the embedding vector output by the knowledge graph embedding model; The text embedding vectors in the conversation history are integrated with the embedding vectors output by the knowledge graph embedding model to obtain the multiple candidate responses.
10. A large model hallucination mitigation device comprising a processor and a transceiver, wherein the transceiver receives and sends data under the control of the processor, characterized in that: The processor is configured to perform the following operations: Obtaining an input sample, wherein the input sample includes: meta-knowledge and conversation history; Using a sample filter based on reinforcement learning to filter the meta-knowledge, and using the filtered meta-knowledge to train a model to obtain a knowledge graph embedding model; Inputting the conversation history into the knowledge graph embedding model to obtain the knowledge graph embedding vector output by the knowledge graph embedding model; According to the knowledge graph embedding vector, the local knowledge vector and the global knowledge vector are fused to obtain a fused knowledge graph vector; The fused knowledge graph vector is embedded into the encoder-decoder model to obtain a large model.
11. The device according to claim 10, characterized in that The processor is further configured to perform the following operations: Obtaining multiple candidate responses output by the large model; The plurality of candidate responses are ranked using a re-ranker, and a response with the highest probability is selected as the output response of the large model.
12. The device according to claim 10, characterized in that The meta-knowledge includes multiple triple sets classified according to semantic relationships, each triple set including one or more triples; the sample filter based on reinforcement learning includes: a sample filter agent based on reinforcement learning corresponding to each triple set; The processor is further configured to perform the following operations: Inputting the initial data sets of each type of triple set into the sample screening agent corresponding to the triple set of that type, the sample screening agent screening the initial data sets to obtain a sample data set of the triple set of that type; wherein the sample quality of the triples in the sample data set is higher than the target threshold; Among them, parameters are shared between sample screening agents corresponding to semantically related triple sets.
13. The device according to claim 12, characterized in that The processor is further configured to perform the following operations: The model is trained using the sampling data sets corresponding to the multiple types of triple sets to obtain the knowledge graph embedding model.
14. The device according to claim 13, characterized in that The processor is further configured to perform the following operations: Obtaining delayed rewards based on the performance of the knowledge graph embedding model; The delayed reward is fed back to the sample screening agent, and the sample screening agent updates the parameters of the sample screening agent according to the delayed reward.
15. The device according to any one of claims 10 to 14, characterized in that The processor is further configured to perform the following operations: The knowledge graph embedding vector is fused into the text embedding vector in the conversation history through entity and relationship links to obtain the local knowledge vector.
16. The device according to any one of claims 10 to 14, characterized in that The processor is further configured to perform the following operations: Using an attention mechanism to draw global dependencies between the conversation history and the knowledge graph embedding vector; The knowledge graph embedding vectors are aggregated according to the global dependency to obtain the global knowledge vector.
17. The device according to claim 11, characterized in that The re-ranker includes a conversational reasoning model and a sentence encoder; The processor is further configured to perform the following operations: Obtaining, by the sentence encoder, a semantic embedding vector of the conversation history and the plurality of candidate responses; Inputting the semantic embedding vector, the multiple candidate responses, and the knowledge graph embedding vector into a conversational reasoning model to obtain the probability of each candidate response output by the conversational pushing model; The multiple candidate responses are sorted according to the probabilities, and the response with the highest probability is selected as the output response of the large model.
18. The device according to claim 11, characterized in that The processor is further configured to perform the following operations: Get the keywords of the query text entered by the user; Extracting triples of the keywords from the knowledge graph; Input the triple into the knowledge graph embedding model to obtain the embedding vector output by the knowledge graph embedding model; The text embedding vectors in the conversation history are integrated with the embedding vectors output by the knowledge graph embedding model to obtain the multiple candidate responses.
19. A communication device comprising a memory, a processor, and a program stored in the memory and executable on the processor; When the processor executes the program, the large model hallucination mitigation method according to any one of claims 1 to 9 is implemented.
20. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the large model hallucination relief method according to any one of claims 1 to 9 are implemented.
21. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the large model hallucination mitigation method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Large language model output illusion correction method and system, medium and electronic equipment
CN118396118A
Cited By
Conditional storage system and method
CN122018824A