GraphiT: Efficient Node Classification on Text-Attributed Graphs with Prompt Optimized LLMs

📄 arXiv: 2502.10522v1 📥 PDF

作者: Shima Khoshraftar, Niaz Abedini, Amir Hajian

分类: cs.AI, cs.LG

发布日期: 2025-02-14

备注: 6 pages, 2 figures


💡 一句话要点

GraphiT:利用提示优化LLM实现文本属性图上的高效节点分类

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 图神经网络 大型语言模型 节点分类 提示工程 图编码

📋 核心要点

  1. 现有方法难以有效地将图结构和特征编码为LLM可用的序列形式,限制了LLM在图数据上的应用。
  2. GraphiT通过将图数据编码为文本,并使用DSPy框架自动优化LLM提示,从而提升LLM在图预测任务中的性能。
  3. 实验表明,GraphiT在节点分类任务上优于LLM基线,且图编码方法在token使用量上更具优势。

📝 摘要(中文)

本文提出GraphiT(Graphs in Text),一个用于将图编码为文本格式并优化LLM提示以进行图预测任务的框架。该框架专注于文本属性图上的节点分类。GraphiT将每个节点及其邻域的图数据编码为简洁的文本,使LLM能够更好地利用图中的信息。此外,利用DSPy框架以编程方式优化LLM提示,从而实现自动化并提高效率和可重复性。实验结果表明,GraphiT在三个数据集上优于基于LLM的基线方法,并且优化步骤能够显著提高结果,无需手动调整提示。同时,该图编码方法在token使用量上更具优势,在同等任务下消耗更少。

🔬 方法详解

问题定义:论文旨在解决文本属性图上的节点分类问题。现有方法,特别是直接使用LLM的方法,面临着如何有效地将图结构信息融入到LLM的输入中,以及如何优化LLM的提示以获得最佳性能的挑战。手动调整提示既耗时又难以复现。

核心思路:论文的核心思路是将图数据(节点及其邻域信息)编码成简洁的文本描述,然后利用LLM进行节点分类。通过将图结构转化为文本,可以更好地利用LLM的上下文理解能力。此外,使用DSPy框架自动优化LLM的提示,避免了手动调整的繁琐过程。

技术框架:GraphiT框架包含两个主要阶段:图数据编码和提示优化。首先,对于每个节点,提取其文本属性和邻域信息,并将这些信息编码成一段文本。然后,将编码后的文本作为LLM的输入,并使用DSPy框架自动优化LLM的提示,以提高节点分类的准确性。

关键创新:GraphiT的关键创新在于结合了图编码和提示优化。通过将图数据编码成文本,使得LLM能够更好地理解图结构信息。同时,使用DSPy框架自动优化LLM的提示,避免了手动调整的繁琐过程,提高了效率和可重复性。

关键设计:图编码的关键在于如何选择和组织节点及其邻域的信息。提示优化的关键在于如何设计DSPy框架的目标函数和搜索策略,以找到最佳的提示。论文中没有详细说明具体的参数设置、损失函数或网络结构,这些细节可能依赖于具体的LLM和DSPy框架的配置。

🖼️ 关键图片

fig_0
fig_1

📊 实验亮点

GraphiT在三个文本属性图数据集上进行了评估,结果表明GraphiT优于基于LLM的基线方法。通过DSPy框架进行的提示优化能够显著提高节点分类的准确性,无需手动调整提示。此外,GraphiT的图编码方法在token使用量上更具优势,在同等任务下消耗更少。

🎯 应用场景

GraphiT可应用于社交网络分析、知识图谱推理、生物信息学等领域。例如,在社交网络中,可以利用GraphiT对用户进行分类,识别垃圾账号或恶意用户。在知识图谱中,可以利用GraphiT进行实体分类或关系预测。该研究有助于提升LLM在图数据上的应用效果,并降低人工干预成本。

📄 摘要(原文)

The application of large language models (LLMs) to graph data has attracted a lot of attention recently. LLMs allow us to use deep contextual embeddings from pretrained models in text-attributed graphs, where shallow embeddings are often used for the text attributes of nodes. However, it is still challenging to efficiently encode the graph structure and features into a sequential form for use by LLMs. In addition, the performance of an LLM alone, is highly dependent on the structure of the input prompt, which limits their effectiveness as a reliable approach and often requires iterative manual adjustments that could be slow, tedious and difficult to replicate programmatically. In this paper, we propose GraphiT (Graphs in Text), a framework for encoding graphs into a textual format and optimizing LLM prompts for graph prediction tasks. Here we focus on node classification for text-attributed graphs. We encode the graph data for every node and its neighborhood into a concise text to enable LLMs to better utilize the information in the graph. We then further programmatically optimize the LLM prompts using the DSPy framework to automate this step and make it more efficient and reproducible. GraphiT outperforms our LLM-based baselines on three datasets and we show how the optimization step in GraphiT leads to measurably better results without manual prompt tweaking. We also demonstrated that our graph encoding approach is competitive to other graph encoding methods while being less expensive because it uses significantly less tokens for the same task.