GT2Vec: Large Language Models for Knowledge Graph Augmented Text Embedding

Jiacheng Lin, Kun Qian, Haoyu Han, Nurendra Choudhary, Tianxin Wei, Zhongruo Wang, Sahika Genc, Edward W Huang, Sheng Wang, Karthik Subbian, Danai Koutra, Jimeng SunSKnow-LLM @ KDD 2025

TL;DR

This paper introduces GT2Vec, a novel framework that leverages Large Language Models (LLMs) to create richer embeddings by jointly processing text and knowledge graph data. By using an MLP adapter to project graph embeddings into the LLM's space and employing contrastive learning for alignment, GT2Vec significantly improves performance on tasks like question answering, classification, and retrieval.

What Problem Does This Paper Address?

Traditional methods for combining text and knowledge graph (KG) information into embeddings often rely on simpler models like MLPs or shallow transformers. While these methods can integrate graph structures to enhance NLP tasks (e.g., providing context for question answering), they struggle to fully capture the complex, heterogeneous relationships present in both modalities. This limitation leads to suboptimal joint embeddings. The authors aim to overcome this by harnessing the advanced representational power of LLMs, which have shown great success in multimodal tasks, to create more expressive and aligned text-graph embeddings.

Methods

GT2Vec's core innovation lies in its use of LLMs as powerful encoders for multimodal data. The framework consists of three main components:

  1. Graph Encoder: A Graph Neural Network (GNN), specifically a modified Graph Attention Network (GAT), is used to generate embeddings from the input knowledge graph. This involves initializing node embeddings, linking entities from the query to graph nodes, and introducing a "query node" to represent the query's connection to the graph.
  2. MLP Adapter: Graph embeddings are projected into the same embedding space as text embeddings using a two-layer MLP. This allows the LLM to process both modalities in a unified manner.
  3. LLM Backbone: The adapted graph embeddings are then fed into an LLM alongside text tokens. The LLM processes this combined input to produce joint embeddings.
  4. Contrastive Learning for Alignment: To ensure better integration, GT2Vec employs a contrastive learning strategy. This involves creating a dual-view architecture: one branch uses the original graph and text, while the other uses a textual description of the graph and the text. By minimizing the distance between positive pairs (aligned graph-text) and maximizing the distance between negative pairs (unaligned), the model explicitly aligns the graph and text embedding spaces.

Datasets

The authors evaluated GT2Vec on six datasets across three tasks:

  • KG-Contextualized QA: CommonsenseQA, OpenBookQA (with and without scientific facts), and MedQA-USMLE. These datasets involve answering questions using both textual context and a knowledge graph.
  • Graph-Text Pair Classification: WebNLG. This task assesses the model's ability to determine the relevance between a graph and its textual description.
  • Retrieval: SciFact and FiQA. These datasets involve retrieving relevant documents or sentences based on a query and its associated graph context.

Key Insights and Ideas

  • LLMs as Multimodal Encoders: The paper demonstrates that LLMs, typically used for generation, can be highly effective as encoders for multimodal tasks, significantly outperforming traditional methods.
  • Explicit Alignment is Crucial: The contrastive learning mechanism for aligning graph and text embeddings is key to GT2Vec's success. This explicit alignment helps the LLM better fuse information from both modalities.
  • Graph Context is Indispensable: Ablation studies show a significant performance drop when graph context is removed, highlighting its critical role in enhancing reasoning and understanding for complex tasks.
  • Flexibility in LLM Choice: GT2Vec shows robustness to different LLM backbones, with larger models generally yielding better performance, indicating the framework's adaptability.

Key Results

GT2Vec consistently outperformed existing baselines across all tested tasks and datasets.

  • KG-Contextualized QA: Achieved state-of-the-art results, with accuracies up to 81.39% on CommonsenseQA and 93.67% on OpenBookQA (with scientific facts).
  • Graph-Text Pair Classification: Outperformed baselines by at least 4.72%, reaching 89.70% accuracy on WebNLG.
  • Retrieval: Achieved the best performance on SciFact and FiQA datasets, demonstrating its effectiveness in retrieving relevant information.
  • Ablation Studies: Confirmed the importance of graph context and the contrastive alignment strategy, showing significant performance gains when these components are included.

Limitations and Future Work

  • LLM Backbone Choice: While GT2Vec is flexible, larger LLMs generally lead to better performance, which can increase computational costs. The paper notes that lighter models can still offer competitive results with reduced cost.
  • Graph Encoder Depth: The study found that the model is robust to variations in GAT layer depth, suggesting that further optimization in this area might yield diminishing returns.
  • Future Work: The authors suggest exploring GT2Vec for generative tasks and investigating more advanced graph encoding techniques. The paper also implies that further research into optimizing the balance between model performance and computational efficiency for different LLM backbones would be beneficial.

Summary updated

BibTeX
@inproceedings{lin2025gt,
  author = {Jiacheng Lin and Kun Qian and Haoyu Han and Nurendra Choudhary and Tianxin Wei and Zhongruo Wang and Sahika Genc and Edward W Huang and Sheng Wang and Karthik Subbian and Danai Koutra and Jimeng Sun},
  title = {{GT2Vec: Large Language Models for Knowledge Graph Augmented Text Embedding}},
  booktitle = {SKnow-LLM @ KDD},
  year = {2025},
  url = {https://openreview.net/forum?id=5iNnMqtFIp},
}
Figure