A prompt subgraph enhanced knowledge graph fact verification method and device and medium
By constructing a local cue subgraph and guiding a large language model to generate a restricted function query program, the problem of lack of contextual evidence in the knowledge graph is solved, thus improving the accuracy and efficiency of fact-checking of knowledge graphs.
Patent Information
- Application Number
- CN202610795240.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-04
- Publication Date
- 2026-07-10
AI Technical Summary
Existing knowledge graph fact-checking methods lack contextual evidence guidance, leading to problems such as the model easily creating arbitrary relation names, omitting intermediate entities, and query path mismatches.
By locating entities in factual statements to be verified, constructing local cue subgraphs, and inputting them as structured context into a large language model, a query program consisting of three types of restricted functions—SEARCH, MATCH, and VERIFY—is generated. Combined with heuristic bundle search and lightweight vocabulary overlap pre-screening, redundant information is reduced and the accuracy of the generated program is improved.
It improves the matching degree between the generated program and the real structure of the knowledge graph, reduces the computational overhead, and enhances the interpretability and transferability of the method.
Smart Images

Figure CN122364413A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of knowledge graph, natural language processing, and large language model technology, specifically to a method, apparatus, and medium for fact-checking knowledge graphs with enhanced cue subgraphs. Background Technology
[0002] Knowledge graphs, using entities, relations, and triples as basic units, organize scattered knowledge into a structured, queryable network. In recent years, knowledge graphs have been widely used to provide external evidence support for retrieval-enhanced generation systems, forming knowledge graph-enhanced retrieval-enhanced generation systems. However, in practical deployments, these systems still face the problem of inconsistencies between generated content and graph evidence: large language models may ignore key evidence, mix parameterized knowledge, or make excessive inferences when generating answers, thus generating seemingly reasonable factual statements that cannot be rigorously supported by the current knowledge graph. Therefore, conducting knowledge graph-oriented fact-checking on the generated results to determine whether the factual statements can be supported by the graph has significant practical value.
[0003] Existing knowledge graph fact-checking methods mainly include the following categories:
[0004] The first category is discriminative methods based on pre-trained language models. These methods use models such as BERT and Flan-T5 to encode factual claims and directly predict whether the claims are supported by the knowledge graph through supervised training. However, these methods do not explicitly model the entities, relationships, and their structured connections within the knowledge graph, making it difficult to fully utilize the structured evidence in the graph for reasoning.
[0005] The second category is based on large language model graph exploration methods, which enhance the model's utilization of graph evidence through entity recognition, relation filtering, and path search. However, when the graph is large, the number of candidate evidence expands rapidly, bringing significant pressure to evidence filtering and context construction.
[0006] The third category is based on programmatic generation methods, which transform statements into executable query programs and perform verification through an interpreter. These methods offer good interpretability, but the program generation process relies heavily on the statement text, lacking guidance from graph contextual evidence. This makes the model prone to fabricating relation names, omitting intermediate entities, or generating non-existent query paths. For example, while Hao and Wu's PGR (Programmatic Graph Reasoning) method establishes a programmatic graph reasoning framework, its program generation phase relies solely on factual statement text. When there are discrepancies between the natural language relation expressions in the statements and the canonical relation predicates in the knowledge graph, the model struggles to accurately map them, leading to program execution failures or incorrect support judgments.
[0007] Therefore, how to effectively utilize local graph structure information related to claims during the fact-checking process to guide large language models to generate executable verification programs that better conform to the real structure of knowledge graphs is a technical problem that urgently needs to be solved in current knowledge graph fact-checking research. Summary of the Invention
[0008] To address the shortcomings of existing procedurally generated fact-checking methods, such as the lack of contextual evidence to guide the process and the resulting susceptibility to fabricated relation names, omissions of intermediate entities, and query path mismatches, this invention provides a knowledge graph fact-checking method based on a prompting subgraph enhancement program. Specifically, it includes:
[0009] S1. Locate the entities of the factual statements to be verified, identify seed entities, and form a set of seed entities;
[0010] S2. Using seed entities as seed nodes, perform depth- and width-restricted heuristic beam search on the knowledge graph to construct a local hint subgraph for the factual statements to be verified.
[0011] S3. Input the prompt subgraph as a structured context into the large language model to guide the large language model to generate a query program composed of three types of restricted functions: SEARCH, MATCH, and VERIFY.
[0012] S4. Execute the query program on the knowledge graph through the interpreter, and output whether the factual statement to be verified is supported by the current knowledge graph based on the execution result.
[0013] Furthermore, in S2, it includes:
[0014] S21. Starting with the seed entity, initialize the bundle set.
[0015] S22. For each path in the current bundle set, obtain the adjacent triples of the end node of the current path from the knowledge graph as candidate triples.
[0016] S23. Calculate the lexical relevance score between each candidate triplet and the fact statement to be verified, and retain the highest-scoring triplet. Candidate triplet;
[0017] S24. Input the fact statement to be verified, the current path, the current node, and the candidate triples output in S23 into the large language model. Based on its semantic understanding of natural language and knowledge graph structures, the large language model selects the top-value triples that are semantically relevant to the statement from the candidate triples. Each edge is considered a candidate edge for expansion. The relevance score of each edge and a label indicating whether it is worth expanding further are returned. The candidate edges are then added to the current path to obtain a new candidate path, and the cumulative score of the new candidate path is updated.
[0018] S25. Add all candidate paths selected by the large language model at the current depth to the candidate path set of the current seed entity, and simultaneously add the path with the highest cumulative score that allows further expansion. Each path serves as the next layer of bundle set;
[0019] S26. Repeat steps S22 to S25 until the preset maximum search depth is reached to obtain the candidate path set of the current seed entity.
[0020] S27. Perform S21 to S26 for each seed entity to obtain a set of candidate paths for each type of sub-entity; merge all candidate path sets to obtain the hint subgraph. .
[0021] Furthermore, the vocabulary relevance score is defined as:
[0022]
[0023] in, This indicates a statement of facts pending verification. This represents the set of words obtained after text segmentation. The intersection operation represents two sets; Indicates candidate triples The name of the relationship in the middle; Indicates candidate triples In and the current node The name of the entity at the other end of the connection.
[0024] Furthermore, the matching weight 'a' for relation names is greater than the matching weight 'b' for adjacent entity names.
[0025] Furthermore, in S27, it is set that... Representing a path The triplet sequence is a path A subsequence of the triple sequence, and Then the shortest path Removed, leaving only the longer path with more complete information to reduce redundant information in the cue subgraph.
[0026] Furthermore, in S3, a fixed prompt template is used to guide the large language model to generate query programs. The prompt template includes: task description, function description, prompt subgraph usage rules, control instructions, generation example, prompt subgraph, and statement of facts to be verified.
[0027] Furthermore, (1) Task description: Clarify the generation goal of the large language model. The prompt word requires the model to use only three types of restricted functions: MATCH, SEARCH and VERIFY, and generate a complete program starting with "def program():".
[0028] (2) Function Description: Explain the functions of the three types. The SEARCH function is used to find candidate entities based on known entities and relational constraints. Its input is a triple template with one empty space (e.g., or The output is a list of candidate entities; the MATCH function is used to determine whether a given triple exists in the knowledge graph. Its input is a complete triple template, and its output is a boolean value; the VERIFY function is used to output the final verification label based on the logical combination of the MATCH results.
[0029] (3) Rules for using hint subgraphs: It is clear that hint subgraphs are only structural reference information and cannot directly replace the generation of query programs; when generating programs, the large language model can give priority to the useful relation names, intermediate entities and path structures in hint subgraphs, but cannot mechanically copy paths, nor can it give judgments directly based solely on hint subgraphs; even if hint subgraphs contain paths that seem to fully support or negate the declaration, the large language model must still generate complete SEARCH, MATCH and VERIFY programs;
[0030] (4) Control instructions: Constrain the output format of the model. SEARCH can only be used to generate intermediate entity variables, and its results cannot appear directly in VERIFY; only "and" and unary "not" are allowed in VERIFY; entity names must strictly maintain the standard form;
[0031] (5) Generate examples: Provide several mapping examples from fact statements to query procedures, covering different cases such as one-hop facts, multi-hop facts and negative facts;
[0032] (6) Hint subgraph: The hint subgraph obtained by explicitly adding S2 ;
[0033] (7) Input to be verified: Provide the statement of facts to be verified for the current sample. and the seed entity set output by S1 .
[0034] Furthermore, in S4, to reduce the coupling between the program execution logic and the underlying graph storage method, the interpreter completes entity query, adjacency triple acquisition, and triple matching through a unified graph access interface.
[0035] According to a second aspect of the present invention, a knowledge graph fact-checking device based on cue subgraph enhancement is provided, comprising:
[0036] The seed entity recognition module is used to segment the fact statement to be verified into words, obtain the entities in it as seed entities, and then form a seed entity set;
[0037] The hint subgraph construction module is used to perform depth- and width-restricted heuristic beam search on the knowledge graph to construct local hint subgraphs related to the fact statements to be verified.
[0038] The program generation module is used to input the prompt subgraph as a structured context into the large language model, guiding the model to generate a query program composed of three types of restricted functions: SEARCH, MATCH, and VERIFY.
[0039] The interpreter execution module is used to execute query programs on the knowledge graph and output whether the statement is supported by the graph.
[0040] According to a third aspect of the present invention, a computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the fact-checking method as described in the first aspect above.
[0041] The knowledge graph fact-checking method with enhanced hint subgraphs provided by this invention has the following advantages compared with the prior art:
[0042] (1) In view of the problem that existing program generative methods lack local graph structure prompts in the program generation stage, this invention proposes a prompt subgraph construction step. Local subgraphs related to the declaration are retrieved from the knowledge graph through heuristic bundle search and used as structured context input to the large language model. This enables the model to refer to the real relation names, intermediate entities and path structures in the graph when generating query programs, reducing problems such as arbitrarily created relation names and incorrect query paths, and improving the matching degree between the generated program and the real structure of the knowledge graph.
[0043] (2) The present invention designs a word overlap pre-screening mechanism, which performs lightweight screening before inputting adjacent triples into the large language model, greatly reducing the length of prompt words and the overhead of calling the large language model. At the same time, by giving higher weight to relation names, the integrity of the most critical relation information generated by the program is guaranteed.
[0044] (3) The present invention proposes a “collect all” strategy, which adds all candidate paths selected by the large language model at the current depth to the prompt subgraph, and only uses the path with the highest cumulative score as the next layer bundle set, which provides more structural reference information for program generation while controlling the computational overhead.
[0045] (4) This invention decouples the interpreter from the unified graph access interface, thereby achieving the portability of the method in different knowledge graph storage environments; and enhances the interpretability and auditability of the fact-checking process through traceable execution logs. Attached Figure Description
[0046] Figure 1 This is a flowchart illustrating a knowledge graph fact-checking method based on a prompt subgraph enhancement program according to an embodiment of the present invention.
[0047] Figure 2 This is a schematic diagram illustrating an example of how a prompt subgraph helps a large language model align relational predicates in a knowledge graph, according to an embodiment of the present invention.
[0048] Figure 3 This is a schematic diagram illustrating an example of how a prompt subgraph helps a large language model identify multi-hop reasoning structures, according to an embodiment of the present invention.
[0049] Figure 4 This is a schematic diagram of the prompt word structure according to an embodiment of the present invention;
[0050] Figure 5 This is a schematic diagram of the process for generating a prompt sub-graph according to an embodiment of the present invention;
[0051] Figure 6 This is a schematic diagram of the structure of a knowledge graph fact-checking device based on a prompting subgraph enhancement program according to an embodiment of the present invention. Detailed Implementation
[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0053] According to a first aspect of the present invention, a knowledge graph fact-checking method based on cue subgraph enhancement is proposed, such as... Figure 1 As shown, it includes:
[0054] S1. Locate the entities of the factual statements to be verified, identify seed entities, and form a set of seed entities;
[0055] S2. Using seed entities as seed nodes, perform depth- and width-restricted heuristic beam search on the knowledge graph to construct a local hint subgraph for the factual statements to be verified.
[0056] S3. Input the prompt subgraph as a structured context into the large language model to guide the large language model to generate a query program composed of three types of restricted functions: SEARCH, MATCH, and VERIFY.
[0057] S4. Execute the query program on the knowledge graph through the interpreter, and output the support tags of the factual statement to be verified based on the execution result to determine whether it is supported by the current knowledge graph.
[0058] In S1, the statement of facts to be verified Entity localization is performed on natural language text to identify explicitly mentioned entities within the knowledge graph. The entities existing in the set are used as seed entities, and together they form a set of seed entities. Seed entity As a starting point for subsequent heuristic beam search. Knowledge graph. ,in For a collection of entities, Let be a set of triples, and each triple is represented as: , For the head entity, For tail entities, It is a relation type.
[0059] For example, Figure 3 The statement "Lady Anne Monson was born in a unitary state" is first segmented into words, and then candidate entities "Lady_Anne_Monson" and "Unitary_state" are identified from them; then, the candidate entities are compared with the knowledge graph. Entity set in Perform a match. If the candidate entity exists... If it is in the middle, then add it to the seed entity set. In this example, the knowledge graph contains the entities "Lady_Anne_Monson" and "Unitary_state", so both are added. .
[0060] In S2, local structural information related to the fact statement to be verified is retrieved from the knowledge graph, providing graph context evidence for subsequent program generation. Heuristic bundle search refers to starting with a seed entity, expanding adjacency triples layer by layer, and retaining only the most relevant paths at each layer. This allows for the collection of local graph structures semantically related to the fact statement to be verified while controlling computational overhead. Specific steps are as follows... Figure 5 As shown, it includes:
[0061] S21. Starting with the seed entity, initialize the bundle set.
[0062] Bundle set refers to the set at the current search depth The following set of paths that can be further expanded is represented as:
[0063]
[0064] The width of a bundle set (i.e., the number of paths in the set) is called the "bundle width," denoted as . Beam width The maximum number of paths retained at each level is controlled. The value is set based on the density of the knowledge graph and computing resources: The larger the value, the more paths are retained, potentially capturing more structural information, but the computational cost is also greater. The smaller the value, the lower the computational cost, but important paths may be missed. Figure 3 In the case shown It is an empirical value selected after balancing effectiveness and efficiency. Indicates the first The first layer is reserved Each scalable path. Includes the sequence of triples already visited and the current node. Cumulative correlation score And a flag indicating whether further expansion is allowed. Initially, empty paths have a cumulative score of 0, and the set is as follows:
[0065]
[0066] by Figure 3 Taking the seed entity "Lady_Anne_Monson" as an example, during initialization, the bundle set... It contains only one empty path The triplet sequence for this path is empty; the current node... Cumulative score This allows for further expansion. For another seed entity "Unitary_state", a bundle set is also initialized, with the current node being "Unitary_state".
[0067] S22. For each path in the current bundle set, obtain the adjacent triples of the end node of the current path from the knowledge graph as candidate triples.
[0068] In the During layer search, for bundle sets Each path in The current node is Extract the node from the knowledge graph. Adjacent triples are used as candidate triples for subsequent word overlap pre-screening and semantic relevance judgment.
[0069] For candidate triplet , will with The other end of the connected entity is denoted as The relationship is denoted as Preferably, during the search process, used triples can be recorded and deduplicated to avoid collecting the same graph fact repeatedly across multiple paths.
[0070] by Figure 3 For example, when the current node is the seed entity "Lady_Anne_Monson", all its adjacent triples are retrieved from the knowledge graph. Assuming the knowledge graph contains triples such as (Lady_Anne_Monson, birthPlace, Kingdom_of_England) and (Lady_Anne_Monson, deathPlace, London), then... It contains these two triplets. For the first triplet, with... The other end entity connected =“Kingdom_of_England”, relation =“birthPlace”. For the second triplet... ="London", =“deathPlace”.
[0071] S23. Calculate the lexical relevance score between each candidate triplet and the fact statement to be verified, and retain the highest-scoring triplet. Candidate triplet.
[0072] Since some entities in a knowledge graph have a large number of adjacent edges, directly inputting all adjacent triples into a large language model would result in excessively long prompts and introduce a lot of noise. Therefore, this invention first uses a lightweight word overlap score to pre-screen candidate triples, thereby reducing the input length and computational overhead for subsequent calls to the large language model.
[0073] For candidate triplet Its vocabulary relevance score is defined as:
[0074]
[0075] in, This indicates a statement of facts pending verification (natural language text). This represents the set of words obtained after text segmentation. The intersection operation represents two sets; Indicates candidate triples The name of the relationship in the middle; Indicates candidate triples In and the current node The other end of the linked entity name. This score primarily measures the apparent relevance between the fact statement to be verified and the candidate relation name and candidate adjacent entity names. The matching weight 'a' for relation names is greater than the matching weight 'b' for adjacent entity names because the query generator is more sensitive to relation names.
[0076] After calculating the lexical relevance scores for all candidate triples, retain the lexical relevance scores. The highest front A candidate triplet, denoted as . Its function is to filter out triples that are clearly irrelevant to the semantics of the fact statement to be verified, thereby reducing the input length of subsequent large language model calls.
[0077] S24. Declaration of facts pending verification Current path Current node and the set of candidate triples output by S23 Inputting the data into a large language model, which, based on its semantic understanding of natural language and knowledge graph structures, selects top-value pairs from candidate triples that are relevant to the semantics of the declaration. Each candidate triple is considered as an expansion edge, and the relevance score and a label indicating whether it is worth expanding further are returned. Once a candidate triple is selected, it is called an expansion edge. A triple consists of a head entity, a relation, and a tail entity, and an edge also has two endpoint entities and a relation between the endpoints, with a one-to-one correspondence. No separate large language model needs to be trained; mainstream large language models already possess instruction-following capabilities. Top-relevant triples are selected from the candidate triples based on their semantic relevance to the declaration. The pre-defined candidate edges represent the semantic understanding capability of the large language model itself. Based on the input fact statements and candidate triples, the large language model uses its internal attention mechanism and semantic representation to determine which candidate edges are most relevant to the semantics of the statements, and then outputs them.
[0078] For each candidate expansion edge The large language model returns a relevance score between the edge and the fact statement to be verified, as well as a label indicating whether a new node reached along the edge is worth continuing to expand.
[0079]
[0080] in This represents the relevance score given by the large language model. Indicates whether the expanded path allows continuing the search to the next level. and These are all direct outputs from large language models and do not require separate training. Models like DeepSeek, after pre-training, inherently possess the ability to determine semantic relevance and follow instructions, and are guided to output these values by prompt words.
[0081] Candidate expanded edges Add path New candidate paths are obtained. The cumulative score for the new path is updated as follows:
[0082]
[0083] The cumulative score is only used as a heuristic ranking criterion to compare the overall relevance of different candidate paths to the statement of fact to be verified, and does not indicate that the path has constituted final evidence to support or refute the statement.
[0084] by Figure 3 For example, starting from the seed entity "Lady_Anne_Monson", the candidate extended edge (Lady_Anne_Monson, birthPlace, Kingdom_of_England) is selected by the large language model. The model returns a relevance score. , extended tag After adding this edge to the path, the new path's triple sequence is [(Lady_Anne_Monson, birthPlace, Kingdom_of_England)], the current node becomes "Kingdom_of_England", and the cumulative score is updated. .
[0085] S25. Add all candidate paths selected by the large language model at the current depth to the suggestion subgraph candidate set, and simultaneously add the path with the highest cumulative score that allows further expansion. Each path serves as the next layer of bundle set. .
[0086] In this invention, each layer of search employs a strategy combining local selection, global competition, and total collection. First, for the current bundle set... Each path in the model is expanded separately, and the large language model selects the top-level path for each path. The candidate expansion edges are selected; then, all selected new paths at the same depth are aggregated into a candidate set, and all candidate paths selected by the large language model at the current depth are added to the final candidate path set. After completing the candidate path collection, the path with the highest cumulative score that allows further expansion is selected. Each path serves as the next layer of bundle set.
[0087] The reason for this design is that the goal of the cue subgraph is to provide the program with as much structural information as possible, rather than retaining only a few paths that are most likely to constitute the final evidence. Therefore, even if some paths do not enter the next level of expansion due to low cumulative scores, as long as they are judged to be relevant to the fact statement to be verified in the current level, they will still be retained in the cue subgraph candidate set as reference information for subsequent program generation stages. At the same time, the width of the bundle set in the next level is limited. This controlled computational overhead.
[0088] S26. Repeat steps S22 to S25 until the preset maximum search depth is reached to obtain the candidate path set of the current seed entity.
[0089] S27. Perform S21 to S26 for each seed entity to obtain a set of candidate paths for various child entities. Merge all candidate path sets, remove duplicates, and remove short paths contained within longer paths to obtain the hint subgraph. That is, the hint subgraph is generated one seed node at a time. S21-S26 are performed on a seed entity to obtain the candidate path set for that seed entity; then S21-S26 are repeated for the next seed entity. Finally, S27 merges the candidate path sets of all seed entities, removes duplicates, and removes short paths to obtain the final hint subgraph.
[0090] set up Representing a path The triplet sequence is a path A subsequence of the triple sequence, and Then the shortest path Removed, leaving only the longer path with more complete information to reduce redundant information in the cue subgraph.
[0091] by Figure 3 For example, suppose we start from the seed entity "Lady_Anne_Monson" and obtain a two-hop path [(Lady_Anne_Monson, birthPlace, Kingdom_of_England), (Kingdom_of_England,governmentType, Unitary_state)]. Simultaneously, starting from another seed entity "Unitary_state", we might also obtain an equivalent two-hop path along the reverse relationship, such as [(Unitary_state, governmentType,Kingdom_of_England), (Kingdom_of_England, birthPlace, Lady_Anne_Monson)]. After deduplication, the system retains only one path because both paths describe the same subgraph structure. Furthermore, the one-hop path (Lady_Anne_Monson, birthPlace, Kingdom_of_England) is already included in the above two-hop path and is therefore removed, retaining only the more informative two-hop path.
[0092] In S3, the seed entity set output by S1 is... And the prompt subgraph output by S2 As a structured context input to the large language model, it guides the large language model to generate a query program composed of three types of restricted functions: SEARCH, MATCH, and VERIFY.
[0093] This step uses a fixed prompt template to guide the large language model in generating the query program, such as... Figure 4 As shown. The prompt template includes the following seven parts:
[0094] (1) Task Description: Clarify the generation goal of the large language model, that is, to generate a graph query program based on the fact statement to be verified, rather than directly outputting the judgment result. The prompt words require the model to use only three types of restricted functions: MATCH, SEARCH, and VERIFY, and to generate a complete program starting with "def program():".
[0095] (2) Function Description: Explain the functions of the three types. The SEARCH function is used to find candidate entities based on known entities and relational constraints. Its input is a triple template with one empty space (e.g., or The output is a list of candidate entities; the MATCH function is used to determine whether a given triple exists in the knowledge graph. Its input is a complete triple template, and its output is a boolean value; the VERIFY function is used to output the final verification label based on the logical combination of the MATCH results.
[0096] (3) Rules for using hint subgraphs: It is clear that hint subgraphs are only for structural reference information and cannot directly replace the generation of query procedures. When generating procedures, the model can give priority to referring to useful relation names, intermediate entities, and path structures in hint subgraphs, but cannot mechanically copy paths, nor can it make judgments directly based solely on hint subgraphs. Even if the hint subgraph already contains paths that seem to fully support or negate the declaration, the model must still generate complete SEARCH, MATCH, and VERIFY procedures.
[0097] (4) Control instructions: Constrain the output format of the model. SEARCH can only be used to generate intermediate entity variables, and its results cannot appear directly in VERIFY; only "and" and unary "not" are allowed in VERIFY; entity names must strictly maintain the standard form.
[0098] (5) Generate examples: Provide several mapping examples from fact statements to query procedures, covering different cases such as one-hop facts, multi-hop facts and negative facts.
[0099] (6) Hint subgraph: The hint subgraph obtained by explicitly adding S2 .
[0100] (7) Input to be verified: Provide the statement of facts to be verified for the current sample. and the seed entity set output by S1 .
[0101] by Figure 2 Taking the statement as an example, with the assistance of the cue subgraph, the large language model can align the natural language expression "originally published in" to the canonical relation predicate "mediaType" in the knowledge graph. The specific implementation process is as follows: The cue subgraph contains triples (The_Sword_in_the_Stone, mediaType, Hardcover) and (The_Sword_in_the_Stone, author, T_H_White). These real relation names come from the knowledge graph itself, retrieved in step S2. In S3, the model, leveraging its context learning ability, replaces the old relation names with the real relation names in the cue subgraph. The cue subgraph uses rules to tell the model "useful relation names in the cue subgraph can be prioritized," so when the large language model reads the cue subgraph, it observes that "mediaType" is the relation name used in the knowledge graph to represent the publishing medium, and uses "mediaType" instead of the old "originally published in" in the generation process. Simultaneously, the model also uses the direction of the triples in the cue subgraph (head entity is the work, tail entity is the author) to set the subject and object of the author relation to the correct order, instead of reversing it to author → work.
[0102] by Figure 3 Taking the statement as an example, with the assistance of the cue subgraph, the large language model can identify the implicit multi-hop reasoning structure in the statement by combining its own reasoning ability. The cue subgraph contains local relation clues such as (Lady_Anne_Monson, birthPlace,Kingdom_of_England) and (Kingdom_of_England, governmentType, Unitary_state). Based on this, the large language model determines that the statement cannot be verified by a one-hop match (directly taking Unitary_state as Lady_Anne_Monson's birthplace), but requires a two-hop verification: first, use SEARCH to find the person's birthplace, and then use MATCH to determine whether the government type of the birthplace is Unitary_state.
[0103] In S4, the interpreter executes the query program generated in S3 on the knowledge graph, and outputs whether the factual claims to be verified are supported by the current knowledge graph based on the execution results.
[0104] The interpreter executes the query program generated by the large language model and accesses the knowledge graph based on function calls within the program. The interpreter only allows programs to call three types of restricted functions: SEARCH, MATCH, and VERIFY. If an illegal function, unresolved parameter, or expression that does not meet the constraints is encountered in the program, the interpreter will terminate execution and log the error message.
[0105] The restricted graph query functions include the SEARCH, MATCH, and VERIFY functions. The SEARCH function searches for candidate entities in the knowledge graph that meet the given conditions based on known entities and relation constraints; its input is a triple template with one empty space. The MATCH function determines whether a given complete triple can be supported by the knowledge graph; its input is a complete triple template. The VERIFY function outputs the final verification label based on a logical expression composed of one or more MATCH results.
[0106] To reduce the coupling between the program execution logic and the underlying graph storage method, the interpreter performs operations such as entity querying, adjacency triple retrieval, and triple matching through a unified graph access interface. This "unified graph access interface" is an abstraction layer that encapsulates specific graph query languages and database access protocols, providing a unified API. For example, when the underlying knowledge graph is stored in the Neo4j graph database, this interface encapsulates the Cypher query language; when the knowledge graph is stored in Apache Jena in RDF format, this interface encapsulates the SPARQL query language. Therefore, when the knowledge graph is accessed by different databases (such as Neo4j, Amazon Neptune, JanusGraph) or through different query languages (SPARQL, Cypher, Gremlin), only the specific implementation of this interface needs to be replaced, without modifying the core logic of the interpreter. This interface itself is existing technology; this invention introduces it into the fact-checking process to decouple the interpreter from the underlying graph storage.
[0107] The interpreter records the input, output, relation alignment results, and related graph evidence for each function call, forming a traceable execution log. This log can be used to analyze the source of the verification results: when the result is unsupported, the reason for the lack of support under the current graph can be located, such as missing entities, failed relation alignment, non-existent triples, or unsatisfactory logical combinations; when the result is supported, it can also be seen which specific graph evidence supports the judgment.
[0108] According to a second aspect of the present invention, a knowledge graph fact-checking device based on cue subgraph enhancement is proposed, such as... Figure 6 As shown, it includes:
[0109] The seed entity recognition module is used to segment the fact statement to be verified into words, obtain the entities in it as seed entities, and then form a seed entity set;
[0110] The hint subgraph construction module is used to perform depth- and width-restricted heuristic beam search on the knowledge graph to construct local hint subgraphs related to the fact statements to be verified.
[0111] The program generation module is used to input the prompt subgraph as a structured context into the large language model, guiding the model to generate a query program composed of three types of restricted functions: SEARCH, MATCH, and VERIFY.
[0112] The interpreter execution module is used to execute query programs on the knowledge graph and output verification results on whether the statement is supported by the graph.
[0113] It should be noted that the fact-checking device provided in this embodiment of the invention is used to execute all the processes and steps of the fact-checking method in the above embodiments. The working principles and effects of the two are one-to-one, and will not be elaborated further here.
[0114] A third aspect of the present invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the fact-checking method provided in the above embodiments. The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a soft-distribution medium, etc.
[0115] Experimental verification
[0116] This invention was experimentally validated on the publicly available FactKG dataset. FactKG is a benchmark dataset built for fact-checking knowledge graphs, containing 108,674 natural language statements covering five reasoning types: one-hop, conjunction, existence, multi-hop, and negation. The experiments used the official test set, containing 9,041 statements. The experiments were conducted using DeepSeek-V3 as the base large language model, retaining the highest-scoring statements. Candidate triples, the beam width of the beam search is set to The number of expansion edges selected at each layer of the large language model The maximum search depth is .
[0117] Experimental results show that the method of this invention achieves an overall accuracy of 87.74%, surpassing the existing best methods PGR-d (85.83%) and SimGRAG (86.80%). In multi-hop inference, the accuracy of this method is 78.18%, an improvement of 6.36 percentage points compared to PGR-d (71.82%); in multi-claim conjunction, the accuracy is 95.11%, an improvement of 2.38 percentage points compared to PGR-d (92.73%); and in negation, the accuracy is 82.42%, an improvement of 2.51 percentage points compared to PGR-d (79.91%). Ablation experiments show that removing the cue subgraph reduces the multi-hop inference accuracy from 78.18% to 69.63%, directly demonstrating the effectiveness of the cue subgraph. Experiments on different large language models further demonstrate that the method of this invention outperforms existing methods on various models such as DeepSeek-V3, DeepSeek-V3.1, and Qwen3-Max, and has good versatility.
[0118] The method for using the knowledge graph fact-checking method based on the prompt subgraph enhancement program provided by the present invention is as follows: input the factual statement to be checked and the knowledge graph, and obtain the check conclusion of whether the statement is supported by the knowledge graph and the traceable execution log through the method of the present invention.
[0119]
[0120] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for fact-checking knowledge graphs with enhanced cue subgraphs, characterized in that, include: S1. Locate the entities of the factual statements to be verified, identify seed entities, and form a set of seed entities; S2. Using seed entities as seed nodes, perform depth- and width-restricted heuristic beam search on the knowledge graph to construct a local hint subgraph for the factual statements to be verified. S3. Input the prompt subgraph as a structured context into the large language model to guide the large language model to generate a query program composed of three types of restricted functions: SEARCH, MATCH, and VERIFY. S4. Execute the query program on the knowledge graph through the interpreter, and output whether the factual statement to be verified is supported by the current knowledge graph based on the execution result.
2. The fact-checking method according to claim 1, characterized in that, S2 includes: S21. Starting with the seed entity, initialize the bundle set; S22. For each path in the current bundle set, obtain the adjacent triples of the end node of the current path from the knowledge graph as candidate triples. S23. Calculate the lexical relevance score between candidate triples and the fact statement to be verified, and retain the highest-scoring triples. Candidate triplet; S24. Input the fact statement to be verified, the current path, the current node, and the candidate triples output in S23 into the large language model. Based on its semantic understanding of natural language and knowledge graph structures, the large language model selects the top-value triples that are semantically relevant to the statement from the candidate triples. Each edge is considered a candidate edge for expansion. The relevance score of each edge and a label indicating whether it is worth expanding further are returned. The candidate edges are then added to the current path to obtain a new candidate path, and the cumulative score of the new candidate path is updated. S25. Add all candidate paths selected by the large language model at the current depth to the candidate path set of the current seed entity, and simultaneously add the path with the highest cumulative score that allows further expansion. Each path serves as the next layer of bundle set; S26. Repeat steps S22 to S25 until the preset maximum search depth is reached to obtain the candidate path set of the current seed entity; S27. Perform S21 to S26 for each seed entity to obtain a set of candidate paths for each type of sub-entity; merge all candidate path sets to obtain the hint subgraph. .
3. The fact-checking method according to claim 2, characterized in that, The vocabulary relevance score is defined as: in, This indicates a statement of facts pending verification. This represents the set of words obtained after text segmentation. The intersection operation represents two sets; Indicates candidate triples The name of the relationship in the middle; Indicates candidate triples In and the current node The name of the entity at the other end of the connection.
4. The fact-checking method according to claim 3, characterized in that, The matching weight 'a' for relation names is greater than the matching weight 'b' for adjacent entity names.
5. The fact-checking method according to claim 2, characterized in that, In S27, let Representing a path The triplet sequence is a path A subsequence of the triple sequence, and Then the shortest path Removed, leaving only the longer path with more complete information to reduce redundant information in the cue subgraph.
6. The fact-checking method according to claim 1, characterized in that, In S3, a fixed prompt template is used to guide the large language model to generate query programs. The prompt template includes: task description, function description, prompt subgraph usage rules, control instructions, generation example, prompt subgraph, and statement of facts to be verified.
7. The fact-checking method according to claim 6, characterized in that: (1) Task description: Define the generation goal of the large language model. The prompt word requires the model to use only three types of restricted functions: MATCH, SEARCH and VERIFY, and generate a complete program starting with "def program():". (2) Function description: Explain the functions of the three types of functions; (3) Rules for using hint subgraphs: It is clear that hint subgraphs are only structural reference information and cannot directly replace the generation of query programs; when generating programs, the large language model can give priority to the useful relation names, intermediate entities and path structures in hint subgraphs, but cannot mechanically copy paths, nor can it give judgments directly based solely on hint subgraphs; even if hint subgraphs contain paths that seem to fully support or negate the declaration, the large language model must still generate complete SEARCH, MATCH and VERIFY programs; (4) Control instructions: Constrain the output format of the model. SEARCH can only be used to generate intermediate entity variables, and its results cannot appear directly in VERIFY. Only "and" and unary "not" are allowed in VERIFY. Entity names must strictly maintain the standard form. (5) Generate examples: Provide several mapping examples from fact statements to query procedures; (6) Hint subgraph: The hint subgraph obtained by explicitly adding S2; (7) Facts to be verified: Give the facts to be verified for the current sample and the seed entity set output by S1.
8. The fact-checking method according to claim 1, characterized in that, In S4, to reduce the coupling between the program execution logic and the underlying graph storage method, the interpreter completes entity query, adjacency triple acquisition and triple matching through a unified graph access interface.
9. A knowledge graph fact-checking device based on cue subgraph enhancement, characterized in that, include: The seed entity recognition module is used to segment the fact statement to be verified into words, obtain the entities in it as seed entities, and then form a seed entity set; The hint subgraph construction module is used to perform depth- and width-restricted heuristic beam search on the knowledge graph to construct local hint subgraphs related to the fact statements to be verified. The program generation module is used to input the prompt subgraph as a structured context into the large language model, guiding the model to generate a query program composed of three types of restricted functions: SEARCH, MATCH, and VERIFY. The interpreter execution module is used to execute query programs on the knowledge graph and output verification results on whether the statement is supported by the graph.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium resides to perform the fact-checking method as described in any one of claims 1 to 8.
