Abstract
Large Language Models (LLMs) present massive inherent knowledge and superior semantic comprehension capability, which have revolutionized various tasks in natural language processing. Despite their success, a critical gap remains in enabling LLMs to perform knowledge graph completion (KGC). Empirical evidence suggests that LLMs consistently perform worse than conventional KGC approaches, even through sophisticated prompt design or tailored instruction-tuning. Fundamentally, applying LLMs on KGC introduces several critical challenges, including a vast set of entity candidates, hallucination issue of LLMs, and under-exploitation of the graph structure. To address these challenges, we propose a novel instruction-tuning-based method, namely FtG. Specifically, we present a filter-then-generate paradigm and formulate the KGC task into a multiple-choice question format. In this way, we can harness the capability of LLMs while mitigating the issue caused by hallucinations. Moreover, we devise a flexible ego-graph serialization prompt and employ a structure-text adapter to couple structure and text information in a contextualized manner. Experimental results demonstrate that FtG achieves substantial performance gain compared to existing state-of-the-art methods.
Introduction
Knowledge Graph Completion (KGC) is the task of predicting missing links within a graph, such as identifying the tail entity in a triple like (Friedrich Gundolf, employer, ?). While Large Language Models (LLMs) excel at semantic reasoning, they face significant hurdles in KGC. First, the search space is massive, often containing tens of thousands of entities, leading to a "needle in a haystack" problem and frequent hallucinations. Second, LLMs are inherently optimized for linear text, making them "structurally blind" to complex graph topologies. Finally, traditional KGC models often struggle to distinguish between "hard" candidates that receive similar scores.
To bridge this gap, we introduce Filter-then-Generate (FtG), a framework that leverages LLMs as discriminators rather than simple generators, utilizing their internal world knowledge to break ties that purely structural models cannot.
Methodology: The FtG Framework
The FtG framework operates in two distinct stages: a lightweight filtering stage followed by a high-capacity generation stage.
1. The Filter Stage
A conventional KGC model (e.g., RotatE) first scores all entities in the graph. Only the top-$k$ (typically $k=20$) candidates are retained. This reduces the problem from an open-ended generation task to a manageable multiple-choice format, significantly mitigating hallucination risks.
2. The Generator Stage
An instruction-tuned LLM (LLaMA2-7B) is employed to select the correct entity from the filtered list. This stage includes several key innovations:
- Ego-graph Serialization: A "1-hop ego-graph" of the query entity is extracted and pruned based on embedding similarity to remove noise. This pruned graph is then converted into a text string via Breadth-First Search (BFS).
- Structure-Text Adapter: A trainable projection layer maps structural embeddings from the KGC filter into the LLM’s text embedding space as "soft tokens," allowing the model to process graph features alongside text.
- Instruction Tuning: The model is fine-tuned using Low-Rank Adaptation (LoRA) on a multiple-choice question format, preventing uncontrollable outputs.
Experimental Results
We evaluated FtG on three major benchmarks: FB15k-237 (general knowledge), CoDEx-M (hard negative triples), and NELL-995 (noisy, sparse data).
Performance Gains
FtG demonstrated substantial improvements over both traditional and LLM-based baselines. On FB15k-237, FtG achieved a Hits@1 of 0.321, outperforming the previous state-of-the-art PLM-based method, CSProm-KG (0.269), and the traditional RotatE (0.241). Notably, FtG is "plug-and-play," improving performance regardless of the underlying filter model used (e.g., TransE, ComplEx).
Hard Sample Resolution
A key advantage of FtG is its ability to resolve indistinguishable candidates. Visualization of the hidden states reveals that while traditional models often see "hard" candidates as an overlapping cluster, FtG successfully separates the target entity from distractors by leveraging its internal semantic knowledge.
Conclusion
The FtG framework effectively couples the structural efficiency of traditional KGC models with the semantic depth of LLMs. By treating the LLM as a discriminator and injecting structural information via a specialized adapter, we achieve new state-of-the-art results. Future work will address the "recall bottleneck"—where the LLM cannot recover if the correct entity is missed by the filter—and optimize inference latency for real-time applications.
Summary updated