Unlock the Power of Frozen LLMs in Knowledge Graph Completion

Bo Xue, Yi Xu, Yunchong Song, Yiming Pang, Yuyang Ren, Jiaxin Ding, Luoyi Fu, Xinbing Wang · OpenReview

Abstract

Traditional knowledge graph completion (KGC) methods rely solely on structural information, struggling with the inherent sparsity of knowledge graphs (KGs). Large Language Models (LLMs) learn extensive knowledge from large corpora with powerful context modeling, making them promising for mitigating the limitations of previous methods. Directly fine-tuning LLMs offers great capability but comes at the cost of huge time and memory consumption, while utilizing frozen LLMs yields suboptimal results. In this work, we aim to leverage LLMs for KGC effectively and efficiently. We capture the context-aware hidden states of knowledge triples by employing prompts to stimulate the intermediate layers of LLMs. We then train a data-efficient classifier on these hidden states to harness the inherent capabilities of frozen LLMs in KGC. Additionally, to reduce ambiguity and enrich knowledge representation, we generate detailed entity descriptions through subgraph sampling on KGs. Extensive experiments on standard benchmarks demonstrate the efficiency and effectiveness of our approach. We outperform traditional KGC methods across most datasets and, notably, achieve classification performance comparable to fine-tuned LLMs while enhancing GPU memory efficiency by $188\times$ and accelerating training and inference by $13.48\times$.

Introduction

Knowledge Graph Completion (KGC) is the critical task of predicting missing links within a graph—for instance, determining the relationship between "Berlin" and "Germany" based on existing knowledge like "Paris is in France." While traditional methods rely on the mathematical structure of the graph, they often falter when data is sparse.

Large Language Models (LLMs) are a natural fit for KGC due to their vast internal world knowledge. However, researchers face a difficult trade-off: zero-shot prompting is computationally cheap but prone to hallucinations and poor alignment with graph logic, while full fine-tuning provides high accuracy but is prohibitively expensive in terms of GPU memory and time. The FLAME (Framework for Leveraging frozen llMs for kg complEtion) framework addresses this by extracting the accuracy of fine-tuned models without altering a single parameter of the underlying LLM.

The FLAME Architecture

FLAME bridges the gap between expensive fine-tuning and inaccurate prompting through a multi-stage pipeline designed to "read the mind" of a frozen LLM.

Overview of the FLAME framework, illustrating the pipeline from subgraph generation to representation extraction and classification.

1. Subgraph Entity Description Generator

LLMs often struggle with raw, symbolic graph data. FLAME addresses this by sampling an entity's local "neighborhood" (one-hop triples) and using an LLM (such as GPT-3.5) to rewrite these into a "model-friendly narrative." This translates symbolic graph data into natural language that the frozen LLM can process more effectively.

2. Representation Extraction

Instead of asking the LLM to generate text (which can lead to hallucinations), FLAME feeds a stimulation prompt into the frozen LLM and extracts the hidden states—the internal vector representations—from the intermediate layers. The authors use Sliced Mutual Information (SMI) to mathematically validate that these internal layers contain sufficient task-relevant information to rival fine-tuned models.

3. Lightweight Classifier

These extracted vectors are fed into a tiny, trainable Multi-Layer Perceptron (MLP) classifier. Only this small probe is trained, while the massive backbone LLM remains entirely frozen, ensuring extreme resource efficiency.

Experimental Results

The researchers evaluated FLAME on six standard KGC benchmarks, including FB13, WN11, and specialized datasets like UMLS (medical terminology).

Triple classification accuracy across multiple benchmarks, comparing FLAME against traditional and LLM-based baselines.

Performance and Efficiency

As shown in the results table, FLAME (w/ GPT) achieves state-of-the-art performance, often outperforming or matching fully fine-tuned models like KG-LLaMA-7B. Notably, FLAME achieves a 47% relative improvement over standard non-fine-tuned LLM baselines.

Beyond accuracy, the efficiency gains are transformative:

  • Memory Efficiency: FLAME is 188x more efficient during training (0.078G vs 14.68G GPU memory).
  • Speed: It offers 26.11x faster training and inference cycles.
  • Data Efficiency: On the FB13 dataset, FLAME reached 97.2% of its peak performance using only 500 training samples, representing just 0.079% of the total available data.

Discussion and Insights

The "Hidden" Knowledge

A key insight of this work is that LLMs already possess the necessary relational knowledge deep within their intermediate layers. Fine-tuning is not required to "teach" the model the graph; rather, a better extraction method is needed to leverage existing internal representations.

Domain Sensitivity

Interestingly, the "narrative" approach is not a universal solution. On the medical dataset (UMLS), adding descriptions actually decreased performance. This suggests that for highly technical fields, the LLM’s internal representations of specific terms are already precise, and adding natural language descriptions introduces unnecessary noise.

Conclusion

FLAME demonstrates that frozen LLMs can be highly effective for KGC when their internal representations are properly stimulated and decoded. By combining subgraph-based narratives with lightweight probing, FLAME offers a scalable, efficient, and accurate path for utilizing massive language models in specialized knowledge graph tasks.

Summary updated

BibTeX
@misc{xue2024unlock,
  author = {Bo Xue and Yi Xu and Yunchong Song and Yiming Pang and Yuyang Ren and Jiaxin Ding and Luoyi Fu and Xinbing Wang},
  title = {{Unlock the Power of Frozen LLMs in Knowledge Graph Completion}},
  year = {2024},
  eprint = {2408.06787},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.06787},
}
Figure