Abstract
Application of LLM to database queries on natural language sentences has demonstrated impressive results in both single and multi-hop scenarios. In existing methodologies, the requirement to re-encode query vectors at each stage for processing multi-hop queries presents a significant bottleneck to inference speed. This paper proposes VKGFR (Virtual Knowledge Graph based Fact Retriever) that leverages large language models to extract representations corresponding to a sentence's knowledge graph, significantly enhancing inference speed for multi-hop reasoning without performance loss. Given that both the queries and natural language database sentences can be structured as a knowledge graph, we suggest extracting a Virtual Knowledge Graph (VKG) representation from sentences with LLM. Over the preconstructed VKG, our VKGFR conducts retrieval with a tiny model structure, showing performance improvements with higher computational efficiency. We evaluate VKGFR on the WikiNLDB and MetaQA dataset, designed for multi-hop database reasoning over text. The results indicate 13x faster inference speed on the WikiNLDB dataset without performance loss.
Introduction
Natural Language Databases (NLDBs) store information as plain text rather than structured tables, offering flexibility but creating a massive reasoning challenge. To answer a complex query (e.g., "Who is the oldest writer living in New York?"), a system must perform "multi-hop" retrieval—finding one fact to unlock the next.
Existing state-of-the-art methods, such as the Support Set Generator (SSG), suffer from a major bottleneck: they use heavy Transformer models to re-encode the query at every single reasoning step. As the database grows from dozens to thousands of facts, this approach becomes computationally expensive. VKGFR (Virtual Knowledge Graph based Fact Retriever) addresses this "inference wall," seeking a way to maintain the reasoning depth of Transformers with the speed required for real-world database applications.
Methods
The core innovation is the Virtual Knowledge Graph (VKG). Instead of treating sentences as opaque strings, the authors use LLMs to "structure" the text into a graph-like format without losing the nuances of natural language.
Building the VKG
The construction process involves an Entity Encoder to extract and embed entity spans (e.g., "John," "New York") and a Relation Encoder (BERT-large) trained to represent the context between entities as a vector. Each sentence is converted into a set of triplets: (entity1, entity2, relation_vector). These are pre-indexed, meaning the heavy lifting of language understanding is done once, upfront.
The VKGFR Retriever
Instead of a massive Transformer, VKGFR uses a "tiny" RNN-based structure (only ~6.3 million parameters). For each hop, the retriever searches the pre-indexed VKG. The retrieved fact then informs the hidden state of the RNN for the next hop. This process continues until the model predicts an "End-of-Retrieval" (EoR) token.
Evaluation and Results
The authors evaluated VKGFR on two primary benchmarks: WikiNLDB, designed for database-style reasoning over text, and MetaQA, a standard multi-hop movie knowledge dataset.
Performance and Efficiency
On the WikiNLDB dataset, VKGFR achieved a 13x faster inference speed compared to the SSG baseline. At a database size of 1,000 facts, VKGFR processed ~12.8 queries per second, while SSG managed only ~1.46. Furthermore, VKGFR demonstrated superior accuracy as database size increased, achieving an F1 score of 51.6 on 1,000 facts, significantly higher than SSG (44.2) and other baselines like MDPR (35.7).
On MetaQA, VKGFR outperformed previous specialized models like DrKIT and OPQL across 1-hop, 2-hop, and 3-hop queries, reaching a Hit@1 of 92.1 on 3-hop tasks.
Discussion
By recognizing that both queries and database sentences can be modeled as graphs, VKGFR moves the computational burden from inference time to indexing time. One of the most significant findings is that a very small RNN can outperform massive Transformers in retrieval if the underlying data representation (the VKG) is high-quality.
However, the system relies on the ability to extract explicit entities and relations. If a fact is implied or entities are highly ambiguous, VKG construction might fail. Additionally, pre-indexing the VKG requires storage overhead (approximately 26MB for a 1,000-fact database), which could be a factor for extremely large-scale deployments. Future work may involve evolving relation encoding to capture more abstract or "fuzzy" connections.
Summary updated