README.md

February 8, 2025 · View on GitHub

GraphAgent: Agentic Graph Language Assistant

📖 Paper at Arxiv · 🤗 GraphAgent Model · 🤗 Graph Tokenizer Model · 🤗 GraphAgent Datasets

📋 To-Do List

  • Release inference code
  • Release model checkpoints
  • Release training and evaluation datasets
  • Release training code

🌟 Overview

Real-world data is represented in both structured (e.g., graph connections) and unstructured (e.g., textual, visual information) formats, encompassing complex relationships that include explicit links (such as social connections and user behaviors) and implicit interdependencies among semantic entities, often illustrated through knowledge graphs. In this work, we propose GraphAgent, an automated agent pipeline that addresses both explicit graph dependencies and implicit graph-enhanced semantic inter-dependencies, aligning with practical data scenarios for predictive tasks (e.g., node classification) and generative tasks (e.g., text generation). GraphAgent comprises three key components: (i) a Graph Generator Agent that builds knowledge graphs to reflect complex semantic dependencies; (ii) a Task Planning Agent that interprets diverse user queries and formulates corresponding tasks through agentic self-planning; and (iii) a Task Execution Agent that efficiently executes planned tasks while automating tool matching and invocation in response to user queries. These agents collaborate seamlessly, integrating language models with graph language models to uncover intricate relational information and data semantic dependencies. Through extensive experiments on various graph-related predictive and text generative tasks on diverse datasets, we demonstrate the effectiveness of our GraphAgent across various settings.

🚀 Getting Started

Invoking GraphAgent (Inference)

Installation

# Clone the repository
git clone https://github.com/yourusername/GraphAgent.git
cd GraphAgent

# Create a conda environment
conda create -n graphagent python=3.11
conda activate graphagent

# Install requirements for GraphAgent inference
pip install -r GraphAgent-inference/requirements.txt

Get Pre-trained Models

We provide several pre-trained checkpoints on 🤗 Hugging Face to power the full potential of GraphAgent:

  • GraphAgent/GraphAgent-8B: Graph action model for GraphAgent as a multimodal llama3 that can take graph tokens as input.
  • GraphAgent/GraphTokenizer: A multimodal graph-text tokenizer for tokenizing graphs into continuous tokens.
  • sentence-transformers/all-mpnet-base-v2: The sentence transformer for text graph embedding.

You can download these checkpoints to a local dir and replace them in GraphAgent-inference/run.sh. Or, the program would also automatically download them for you.

Set the Planner and API Token

We utilize API-based LLM calls for task planning and graph generation. The default planner here is deepseek, where you can find in GraphAgent-inference/run.sh. Put your API key in

export OPENAI_API_KEY=""

that is corresponding to the planner.

Inference Examples

bash GraphAgent-inference/run.sh

>>> Please enter a user instruction or file path (or type 'exit' to quit):

# use GraphAgent-inference/demo/use_cases/teach_me_accelerate.txt as an example
>>> Please enter a user instruction or file path (or type 'exit' to quit): GraphAgent-inference/demo/use_cases/teach_me_accelerate.txt

Then you will have a close look on how GraphAgent works to achieve your task.

For more detailed and diverse examples on what GraphAgent can do for you, check out our use_cases directory.

GraphAgent Dataset (Coming Soon!)

IMDBACMArxiv-PapersICLR-Peer ReviewsRelated Work GenerationGovReport Summarization
Task TypePredictivePredictivePredictivePredictiveGenerativeGenerative
Sub-TaskNCNCPaper ClassificationPaper Judgement PredictionText GenerationText Summarization
Pre-defined Graph?××××
#Train Samples2,400-5,1753,1414,155-
#Eval Samples-1000500500500304
#Tokens10M0.8M30M45M93M2M
#Pre-defined Graph Nodes11,61610,942----
SKG SourcePeople EntitiesPaperPaperPaper, ReviewsMultiple PapersDocuments
#SKG Nodes57,12020,388153,555161,592875,92115,621

Training GraphAgent with Your Own Data (Coming Soon!)

The training code and procedures will be released in future updates. Stay tuned!

📊 Benchmarks

Zero-shot classification task on ACM-1000

MetricTrained onSAGEGATHANHGTHetGNNHiGPTGraphAgentImprv.
Micro-F1 (%)IMDB-132.93±4.1835.67±0.5334.07±1.1132.40±0.1437.43±4.3445.40±0.8951.21±1.3212.8%
IMDB-4031.73±0.0523.93±1.4426.97±1.9435.60±0.9931.80±0.1650.50±0.7774.98±1.2448.5%
Macro-F1 (%)IMDB-126.47±2.6929.08±1.3122.50±4.1616.31±0.0531.39±4.6841.77±1.2446.82±1.4312.1%
IMDB-4031.17±0.1721.41±0.7123.13±1.3227.49±1.2231.44±0.1745.85±0.8974.98±1.1263.5%
AUC (%)IMDB-149.34±2.4752.48±0.3851.28±0.8650.00±0.0053.18±2.9559.69±0.8264.10±1.257.4%
IMDB-4048.67±0.1343.20±1.0845.45±1.4651.48±0.4348.72±0.0663.60±0.5180.90±1.0127.2%

Complex graph predictive tasks on Arxiv-Papers and ICLR-Peer Reviews

MethodModel SizeArxiv-PapersICLR-Peer Reviews
Mi-F1Ma-F1AUCMi-F1Ma-F1AUC
Open-sourced LLMs
Llama3-8b8B0.5140.2890.5270.4020.3940.502
Mistral-Nemo12B0.5100.2920.6150.2720.2460.380
Llama3-70b70B0.6300.3300.6350.4340.4210.551
Qwen2-72b72B0.6320.4720.7000.3440.2770.509
API-based Commercial LLMs
Deepseek-Chat-V2236B→21B0.7460.5800.7570.3620.3120.516
GPT4o-mini-0.5920.3430.6340.692*0.5920.591
Gemini-1.5-Flash-0.7480.5040.7140.6840.4870.533
Finetuned LLMs
Llama3-8b Finetuned8B0.7940.5930.7360.6200.5540.553
GraphRAG Implementations
Llama3-8b + GraphRAG8B0.5160.2880.6010.4300.4270.517
Llama3-70b + GraphRAG70B0.6030.3240.6230.3080.2960.401
GraphAgent-Task Expert8B0.8200.6200.7680.6860.620*0.615*
GraphAgent-General8B0.840*0.621*0.769*0.6670.6040.607
GraphAgent-Zero-Shot8B0.7390.5120.7010.5380.5310.563
MethodModel SizePPL-Llama3-70bPPL-Qwen2-72b
MeanMaxMeanMax
Open-sourced LLMs
Llama3-8b8B7.01613.0617.49112.787
Mistral-Nemo12B7.36715.9676.87212.065
Llama3-70b70B6.16814.4365.87712.897
Qwen2-72b72B6.04311.6755.32511.302
API-based Commercial LLMs
Deepseek-Chat-V2236B→21B5.63213.4835.14410.337
GPT4o-mini-7.27715.4806.81813.267
Gemini-1.5-Flash-5.18810.3995.37710.779
Finetuned LLMs
Llama3-8b Finetuned8B7.68219.4527.62918.757
GraphRAG Implementations
Llama3-8b + GraphRAG8B7.09818.0926.53914.722
Llama3-70b + GraphRAG70B6.59014.8276.13514.163
GraphAgent-Task Expert8B3.80510.3164.06911.685
GraphAgent-General8B3.618*8.000*3.867*8.775*

📝 Citation

If you find this repository useful, please cite our paper:


@article{graphagent,
      title={GraphAgent: Agentic Graph Language Assistant}, 
      author={Yuhao Yang and Jiabin Tang and Lianghao Xia and Xingchen Zou and Yuxuan Liang and Chao Huang},
      year={2024},
      journal={arXiv preprint arXiv:2412.17029},
}