Reranking Answers of Large Language Models with Knowledge Graphs
Authors: Mikhail Salnikov, Hai Le, Olga Tsymboi, Ivan Lazichny, Dmitrii Iarosh, Egor Cheremiskin, Andrey Savchenko, Dmitry Simakov, Alexander Panchenko
Organizations: Artificial Intelligence Research Institute, Moscow, Russia · Skolkovo Institute of Science and Technology, Moscow, Russia · Sber AI Lab, Moscow, Russia · Moscow Institute of Physics and Technology, Moscow, Russia · Moscow State University, Moscow, Russia · Laboratory for Theoretical Foundations of AI Models, HSE University, Moscow, Russia
Answering natural language questions over knowledge graph data is challenging due to the vast number of facts, which can be difficult to process and navigate. One potential solution for this issue is to use mined subgraphs related to the query, although this process still requires extracting these subgraphs. This research presents a solution for extracting subgraphs related to entity candidates from a question-and-answer set, which can be obtained by inferring a large language model by calculating the shortest paths between entities. The proposed approaches detail various features that can be extracted from the subgraphs and reranking models to select the most probable answers from a list of candidates. Experiments were conducted on Wikidata to evaluate the effectiveness of the proposed approaches. This involved enumerating all the main feature types that can be extracted from mined subgraphs and a detailed analysis of the proposed features and reranking method combinations. In addition, a public web application that provides a useful web tool for studying the graph space between question and answer entities has been developed to work with subgraphs. This includes visualization of the extracted subgraph and automatic generation of natural language text to describe it.
Figures & tables
Figure 1: The motivation of our research: LLM’s top-1 QA prediction accuracy is often incorrect. However, the correct answer is often in the top 10-40 alternative generations. Thus, a better reranking, such as the one presented in this article, is required. Dependence of Hit@N metric on the size of answer pool N on Mintaka [ 32 ] full dataset and Mistral [ 11 ] , Mixtral [ 12 ] , T5-Large-SSM and T5-XL-SSM [ 26 ] tuned models using Diverse Beam Search [ 39 ] as an inference strategy.
Figure 2: The proposed method for reranking language model answers with KGs. The method includes subgraph extraction, features extraction, and various ranker approaches. The subgraphs consist of the shortest paths between question entities and answer candidates, as discussed in Section 3.1 . Various features were extracted for the ranker approaches, including text, graph, and Graph2Text Sequence Features, as discussed in Section 3.2 .
Figure 3: Extraction of subgraphs between question and answer in KG. We combine the extracted shortest paths into a single subgraph, adding links between intermediate nodes. Here, QEn is the Question Entities, A is the current answer candidate entity, and the colored nodes represent the intermediate entities.
Table 1: Statistics of the WebNLG 2.0 parallel knowledge graph-to-text dataset.
Subgraph
Corresponding Graph2Text
T5
GAP
Mount Rainier is located in North America.
The summit of North America is called Mount Rainier.
Louisa May Alcott and Ramona Quimby are both females.
Louisa May Alcott and Ramona Quimby are both men.
The United States of America is the location of the National Statuary Hall and the office of the President of the United States.
The National Statuary Hall is located in the United States of America, where the leader is known as the President. The country is the location of the US congress and has the President as its President.
The Harry Potter prequel is written in English, as is the Harry Potter book.
English is the language of both Harry Potter prequel and the English book.
Table 2: Examples of subgraphs and their corresponding generated texts for various feature extractors.
Figure 4: Comparative analysis of reranking methods applied to candidate pools generated by T5-Large-SSM, T5-XL-SSM, Mistral-7B, and Mixtral-8x7B. Bars represent the Hit@1 score of the top-ranked answer on Mintaka dataset. Methods are grouped by model architecture: Baseline (Without reranking, Majority Vote), RankGPT, Regression Baselines (Linear/Logistic), Gradient Boosting (CatBoost), and proposed Neural Ranker (MPNet). Error bars indicate standard deviation over 3 runs for non-deterministic methods.
Figure 5: Reranking performance on the MKQA dataset using candidate answers from T5-Large-SSM and T5-XL-SSM. Unlike Mintaka, MKQA requires entity linking for question entities, testing the pipeline’s robustness to noisy subgraph extraction.
Figure 6: Permutation importance of graph features for Linear and Logistic Regression rankers on answer candidates generated by T5-Large-SSM and by T5-XL-SSM
Figure 7: Permutation importance of graph features for Linear and Logistic Regression rankers on answer candidates generated by Mistral and by Mixtral
Figure 8: Permutation importance of graph, text, and G2T features for Catboost rankers on answer candidates generated by T5-Large-SSM and T5-XL-SSM
Figure 9: Permutation importance of graph, text, and G2T features for Catboost rankers on answer candidates generated by Mistral and Mixtral
Answers Source
Question Entities Accuracy
Answer Entities Accuracy
Graph2Text (T5)
T5-Large-SSM
TRAIN
0.995
0.833
TEST
0.954
0.835
T5-XL-SSM
TRAIN
0.955
0.827
TEST
0.955
0.829
Graph2Text (GAP)
Table 3: Graph2Text Accuracy of label generation for entities in texts generated from subgraphs.
Figure 10: Hit@N Metrics for Different N Values on Mintaka [ 32 ] full dataset for generated by Diverse Beam Search [ 39 ] answers by LLM tuned models with different reranking approaches.
Figure 11: A web application that visualizes subgraphs for given entities. Examples of the USA, China, and Yuri Gagarin are shown on the left side. On the right side are examples of James Bond and the United Kingdom. Both examples provide not only subgraphs but also their Graph2Text representation.
Figure 12: Web application for KGQA with extracted subgraph visualization for question “ Which movie is part of the Marvel Cinematic Universe and has Chadwick Boseman in the titular role? ”. Entity linker extracted entity Marvel Cinematic Universe (Q642878) and Chadwick Boseman (Q5066520) from question and language model predicted Daredevil (Q16977365) as a top-1 answer that is incorrect what is indirectly seen from the subgraph.
Figure 13: Subgraph for question “ Which movie is part of the Marvel Cinematic Universe and has Chadwick Boseman in the titular role? ” which include entities Marvel Cinematic Universe (Q642878) and Chadwick Boseman (Q5066520) in question. The correct answer for the question is entity Black Panther (Q23780734).
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Reranking Model
Features
Hit@1
Hit@2
Hit@3
Without reranking
0.2395
0.3580
0.4020
Full random
0.0278
0.0562
0.0828
Majority Vote
0.2213
0.3422
0.3875
Semantic reranking
Text
0.0298
0.0647
0.0965
RankGPT (Mistral)
Text
0.2442±0.0004
0.3237±0.0004
0.3864±0.0007
Text + G2T (Det. Lin.)
0.1984±0.0007
0.2904±0.0008
0.3613±0.0010
Appendix
Table 4: Hit@1-3 for all proposed reranking approaches and features after reranking the T5-Large-SSM generated answer candidates for Mintaka dataset.
Reranking Model
Features
Hit@1
Hit@2
Hit@3
Without reranking
0.3042
0.4298
0.4688
Full random
0.0235
0.0473
0.0723
Majority Vote
0.2677
0.4020
0.4417
Semantic reranking
Text
0.0245
0.0545
0.0830
RankGPT (Mistral)
Text
0.2501±0.0011
0.3356±0.0001
0.4017±0.0007
Text + G2T (Det. Lin.)
0.2083±0.0004
0.3058±0.0004
0.3791±0.0007
Appendix
Table 5: Hit@1-3 for all proposed reranking approaches and features after reranking the T5-XL-SSM generated answer candidates for Mintaka Dataset.
Reranking Model
Features
Hit@1
Hit@2
Hit@3
Without reranking
0.4655
0.5313
0.5590
Full random
0.0920
0.1585
0.2165
Majority Vote
0.4228
0.5020
0.5345
Semantic reranking
Text
0.0858
0.1393
0.1790
RankGPT (Mistral)
Text
0.3838±0.0007
0.4618±0.0002
0.5112±0.0004
Text + G2T (Det.Lin.)
0.3315±0.0006
0.4310±0.0005
0.4893±0.0005
Appendix
Table 6: Hit@1-3 for all proposed reranking approaches and features after reranking the Mistral generated answer candidates for Mintaka dataset.
Reranking Model
Features
Hit@1
Hit@2
Hit@3
Without reranking
0.5173
0.5628
0.5735
Full random
0.0580
0.1090
0.1455
Majority Vote
0.4858
0.5645
0.5930
Semantic reranking
Text
0.0303
0.0550
0.0715
RankGPT (Mistral)
Text
0.3958±0.0005
0.4733±0.0002
0.5233±0.0004
Text + G2T (Det. Lin.)
0.3430±0.0007
0.4422±0.0001
0.5012±0.0003
Appendix
Table 7: Hit@1-3 for all proposed reranking approaches and features after reranking the Mixtral generated answer candidates for Mintaka Dataset.
Reranking Model
Features
Hit@1
Hit@2
Hit@3
Without reranking
0.0925
0.1139
0.1317
Full random
0.0249
0.0391
0.0712
Majority Vote
0.0961
0.1281
0.1423
Semantic reranking
Text
0.0000
0.0000
0.0000
RankGPT (Mistral)
Text
0.0107±0.0000
0.0463±0.0000
0.0747±0.0000
Text + G2T (Det. Lin.)
0.0107±0.0000
0.0356±0.0000
0.0569±0.0000
Appendix
Table 8: Hit@1-3 for all proposed reranking approaches and features after reranking the T5 Large SSM generated answer candidates on MKQA dataset.
Reranking Model
Features
Hit@1
Hit@2
Hit@3
Without reranking
0.4306
0.4911
0.5267
Full random
0.2112
0.2871
0.3713
Majority Vote
0.4306
0.4982
0.5267
Semantic reranking
Text
0.1246
0.2562
0.3345
RankGPT (Mistral)
Text
0.1495±0.0000
0.2254±0.0017
0.2894±0.0017
Text + G2T (Det. Lin.)
0.1210±0.0000
0.1815±0.0000
0.2527±0.0000
Appendix
Table 9: Hit@1-3 for all proposed reranking approaches and features after reranking the T5 XL SSM generated answer candidates on MKQA Dataset.
Component
Requirements
Main consumer
CPU
AMD EPYC 7702 64-Core
Multithreading in graphs preprocessing
RAM
80GB (used by one thread, for multithreading 1TB was used)
Subgraphs extraction algorithm for loading knowledge graph into memory
GPU
2 x NVIDIA A100
Training and evaluation of Mistral/Mixtral models
Appendix
Table 10: Hardware requirements for evaluation of presented experiments
Knowledge Graph Question Answering answers natural-language questions by finding and reasoning over entities and relations in structured knowledge graphs.
Knowledge graph question answering (KGQA) requires navigating from topic entities to an answer several relations away. Recent methods prompt a frontier LLM to explore the graph through a retrieval tool, but their reliance on frontier-scale inference makes them costly to deploy. We present Search-on-Graph-R1 (\sogrone{}), which internalizes this navigation into a compact 8B model through supervised fine-tuning (SFT) followed by reinforcement learning (RL). Our central idea is to scaffold a frontier teacher with each question's gold SPARQL query, so the teacher traverses a known answer-bearing path with a live Search tool rather than having to discover the path itself. Since every call executes against a live Freebase server, the resulting trajectories are grounded in the knowledge graph by construction. On WebQSP, CWQ, and GrailQA, \sogrone{} at 8B surpasses every frozen frontier-LLM system in our comparison and posts the strongest results on CWQ of any system we compare against. It does so using no auxiliary module at inference and no LLM judge during training. Isolating each training stage shows that SFT and RL contribute complementary gains, our approach transfers across model families, and RL learns to reach answers in fewer Search calls than its SFT initialization.
Jia Ao Sun, Hao Yu, Fengran Mo +4
Université de Montréal · Mila – Québec AI Institute · McGill University +2
We present GRISP (Guided Recurrent IRI Selection over SPARQL Skeletons), a novel SPARQL-based question-answering method over knowledge graphs based on fine-tuning a small language model (SLM). Given a natural-language question, the method first uses the SLM to generate a natural-language SPARQL query skeleton, and then to re-rank and select knowledge graph items to iteratively replace the natural-language placeholders using knowledge graph constraints. The SLM is jointly trained on skeleton generation and list-wise re-ranking data generated from standard question-query pairs. We evaluate the method on common Wikidata and Freebase benchmarks, and achieve better results than other state-of-the-art methods in a comparable setting.
Sebastian Walter, Hannah Bast
University of Freiburg · Department of Computer Science · Freiburg im Breisgau, Germany
Textual graph question answering (GraphQA) and graph-based retrieval-augmented generation (GraphRAG) have gained increasing attention as a way to ground large language models (LLMs) on structured knowledge. Despite extensive efforts, existing methods still face two key gaps. The first is an architectural gap: existing methods typically fine-tune an LLM-based generator, but do not also make the retriever itself a learnable LLM for graph evidence selection within one end-to-end retrieve-then-generate pipeline. The second is a retrieval-supervision gap: existing retrievers rarely use gold answer signals to supervise evidence selection. As a result, they may fail to recall evidence nodes required for reasoning, resulting in insufficient coverage of the gold answer set; meanwhile, naive attempts to boost recall often introduce excessive irrelevant information that compromises compactness and overwhelms the LLM. To address these gaps, we propose TaLenT, an LLM-based end-to-end retriever-generator framework for textual GraphQA. To bridge the architectural gap, TaLenT pairs a learnable LLM-based retriever for evidence selection with a fine-tuned LLM-based generator within one unified retrieve-then-generate pipeline. To bridge the retrieval-supervision gap, we leverage gold answer signals as retriever supervision. Specifically, we stratify graph nodes into gold answers, answer-related nodes, and irrelevant noise. We then adopt a weighted pseudo-label loss to prioritize gold answers and preserve answer-related nodes for coverage, while discarding irrelevant noise for compactness. Experimental results across three GraphQA datasets demonstrate that TaLenT consistently improves downstream performance.
Kaifeng Jin, Yuchen Yan, Zhichen Zeng +4
University of Illinois Urbana-Champaign · Wayne State University · Meta