Introduction
Knowledge Graph Question Answering (KGQA) involves translating natural language questions into structured queries, such as SPARQL, to retrieve information from large-scale databases like Wikidata. This task is inherently difficult due to the semantic gap between human language and formal data structures. Mapping a specific entity in a sentence to its unique identifier among millions of candidates (e.g., mapping "France" to Q142) represents a significant "needle in a haystack" challenge. Researchers from Skoltech propose addressing this by reframing query generation as a retrieval and ranking task, utilizing high-dimensional embeddings and efficient nearest-neighbor search.
Methodology
The proposed pipeline integrates transformer-based language modeling with metric learning to map questions and graph entities into a shared embedding space.
Embedding Generation and Metric Learning
The system employs a pre-trained BART (Bidirectional and Auto-Regressive Transformers) model, modified to produce a fixed-size vector representing the input question. To align these question embeddings with the correct Wikidata items and properties, the model is trained using a Triplet Margin Loss. This metric learning strategy ensures that a question's embedding is positioned closer to its corresponding positive entities and further from negative ones in the latent space. Hard negative mining is utilized to improve the model's ability to distinguish between semantically similar but incorrect entities.
Scalable Retrieval with ScaNN
Given the scale of Wikidata—containing over 4 million items and thousands of properties—efficient retrieval is paramount. The authors utilize Google’s ScaNN (Scalable Nearest Neighbors) algorithm. ScaNN employs score-aware quantization to perform high-speed searches across millions of vectors, enabling the system to identify the top candidate items and properties for a given question embedding nearly instantaneously.
Query Construction
During inference, the system retrieves the top three nearest neighbors for both items (Q) and properties (P). It then iterates through combinations of these candidates to construct a valid SPARQL query that yields results from the Wikidata endpoint.
Experimental Setup and Results
The approach was evaluated on the QALD-9 (Question Answering over Linked Data) challenge. The training set utilized Wikidata embeddings generated via the TransE algorithm and PyTorch-BigGraph (PBG), covering approximately 4.1 million items.
The system achieved a Macro F1-score of 0.4281 on the QALD-9 benchmark. Subsequent refinements, including the use of a more focused embedding pool (500,000 items) and reduced training epochs, improved the score to 0.5133. Comparative analysis indicated that BART consistently outperformed other architectures like DistilBERT and XLM-RoBERTa in minimizing training loss for this ranking task.
Discussion and Future Work
A key insight of this work is the scalability of the retrieval-based approach. The performance remained robust even as the search pool increased from 3 million to 4 million items, largely due to the efficiency of the ScaNN algorithm. Furthermore, while the current implementation is monolingual (English), the embedding-based framework is extensible to multilingual contexts through techniques like embedding rotation or the use of multilingual transformers.
However, limitations remain. The preprocessing of the QALD dataset resulted in a relatively small training set of 145 high-quality samples, which may limit generalization. Additionally, while effective for simple entity-property lookups, the system's performance on highly complex queries involving multiple hops or aggregations requires further investigation. Future work will focus on expanding the training data and exploring more complex query templates.
Summary updated