[SIGIR'2024] "GraphGPT: Graph Instruction Tuning for Large Language Models"
832
stars
22
commits
Python
primary language
Jun 25, 2024
updated
GraphGPT: Graph Instruction Tuning for Large Language ModelsData Intelligence Lab@University of Hong Kong, Baidu Inc.
This repository hosts the code, data and model weight of GraphGPT (SIGIR'24 full paper track).
The lightweight training requires PyTorch 2.1+, so we need to update corresponding libraries:
# if you have set up the env for GraphGPT earlier
pip uninstall torch
pip uninstall torchvision
pip uninstall torchaudio
# CUDA 11.8
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
# update pyg for the PyTorch 2.1+
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
# install lightning
pip install lightning
Due to compatibility issues, if you are using the previously released graph data, we recommend downloading and updating it according to the provided link: updated graph data.
You can run the scripts as follow:
Stage-1:
cd path/to/GraphGPT
sh ./scripts/tune_script/graphgpt_stage1.sh
Stage-2:
cd path/to/GraphGPT
sh ./scripts/tune_script/graphgpt_stage2.sh
replace_llama_attn_with_flash_attn() in line 8 in https://github.com/HKUDS/GraphGPT/blob/main/graphgpt/train/train_mem.py. For more details, please refer to #17No module named 'graphgpt' error, you could refer to issue #56🎯🎯📢📢 We have made significant updates to the models and data used in our GraphGPT on 🤗 Huggingface. We highly recommend referring to the table below for further details:
| 🤗 Huggingface Address | 🎯 Description |
|---|---|
| huggingface.co/Jiabin99/GraphGPT-7B-mix-all | It's the checkpoint of our GraphGPT based on Vicuna-7B-v1.5 tuned on instruction data Arxiv-PubMed-mix-NC-LP |
| huggingface.co/Jiabin99/Arxiv-PubMed-GraphCLIP-GT | It's the checkpoint of the pre-trained graph transformer (GT) trained on Arxiv and PubMed using Text-Graph grounding. |
| huggingface.co/datasets/Jiabin99/Arxiv-PubMed-mix-NC-LP | This's the mixing instruction dataset with node classification (NC) and link prediction (LP) on Arxiv and PubMed. |
| huggingface.co/datasets/Jiabin99/GraphGPT-eval-instruction | We release all instruction dataset for our evaluation. |
| huggingface.co/datasets/Jiabin99/All_pyg_graph_data | We merge all utilized graph data. |
| huggingface.co/datasets/Jiabin99/graph-matching | This is the instruction data used in graph-matching stage. |
[2023.10.28]📢📢For the Chinese version of the explanation, please refer to this article.
[2023.10.26]🔥🔥Release our utilized Instruction data.
[2023.10.26]🔥🔥Release checkpoints of our GraphGPT and pre-trained graph encoder.
[2023.10.23] 🚀🚀 The full paper of our GraphGPT is available at https://arxiv.org/abs/2310.13023. Please check out it and give us more feedbacks!
[2023.10.15] 🚀🚀 Release the code of GraphGPT.
we present the GraphGPT framework that aligns LLMs with graph structural knowledge with a graph instruction tuning paradigm.
For more technical details, kindly refer to the paper and the project website of our Graph.
.
├── README.md
├── assets
│ ├── demo_narrow.gif
│ ├── screenshot_cli.png
│ ├── screenshot_gui.png
│ ├── server_arch.png
│ └── vicuna_logo.jpeg
├── format.sh
├── graphgpt
│ ├── __init__.py
│ ├── constants.py
│ ├── conversation.py
│ ├── eval
│ │ ├── README.md
│ │ ├── requirements.txt
│ │ ├── run_graphgpt.py
│ │ ├── run_graphgpt_LP.py
│ │ ├── run_vicuna.py
│ │ └── script
│ │ └── run_model_qa.yaml
│ ├── model
│ │ ├── GraphLlama.py
│ │ ├── __init__.py
│ │ ├── apply_delta.py
│ │ ├── apply_lora.py
│ │ ├── builder.py
│ │ ├── compression.py
│ │ ├── convert_fp16.py
│ │ ├── graph_layers
│ │ │ ├── __init__.py
│ │ │ ├── bpe_simple_vocab_16e6.txt.gz
│ │ │ ├── clip_graph.py
│ │ │ ├── graph_transformer.py
│ │ │ ├── mpnn.py
│ │ │ └── simple_tokenizer.py
│ │ ├── make_delta.py
│ │ ├── model_adapter.py
│ │ ├── model_registry.py
│ │ ├── monkey_patch_non_inplace.py
│ │ └── utils.py
│ ├── protocol
│ │ └── openai_api_protocol.py
│ ├── serve
│ │ ├── __init__.py
│ │ ├── api_provider.py
│ │ ├── bard_worker.py
│ │ ├── cacheflow_worker.py
│ │ ├── cli.py
│ │ ├── controller.py
│ │ ├── gateway
│ │ │ ├── README.md
│ │ │ └── nginx.conf
│ │ ├── gradio_block_arena_anony.py
│ │ ├── gradio_block_arena_named.py
│ │ ├── gradio_css.py
│ │ ├── gradio_patch.py
│ │ ├── gradio_web_server.py
│ │ ├── gradio_web_server_multi.py
│ │ ├── huggingface_api.py
│ │ ├── inference.py
│ │ ├── model_worker.py
│ │ ├── monitor
│ │ │ ├── basic_stats.py
│ │ │ ├── clean_battle_data.py
│ │ │ ├── elo_analysis.py
│ │ │ ├── hf_space_leaderboard_app.py
│ │ │ └── monitor.py
│ │ ├── openai_api_server.py
│ │ ├── register_worker.py
│ │ ├── test_message.py
│ │ └── test_throughput.py
│ ├── train
│ │ ├── graphchat_trainer.py
│ │ ├── llama_flash_attn_monkey_patch.py
│ │ ├── train_graph.py
│ │ ├── train_lora.py
│ │ └── train_mem.py
│ └── utils.py
├── playground
│ ├── inspect_conv.py
│ ├── test_embedding
│ │ ├── README.md
│ │ ├── test_classification.py
│ │ ├── test_semantic_search.py
│ │ └── test_sentence_similarity.py
│ └── test_openai_api
│ ├── anthropic_api.py
│ └── openai_api.py
├── pyproject.toml
├── scripts
│ ├── eval_script
│ │ └── graphgpt_eval.sh
│ ├── extract_graph_projector.py
│ ├── serving
│ │ ├── controller.yaml
│ │ └── model_worker.yaml
│ └── tune_script
│ ├── extract_projector.sh
│ ├── graphgpt_stage1.sh
│ └── graphgpt_stage2.sh
└── tests
├── test_openai_curl.sh
├── test_openai_langchain.py
└── test_openai_sdk.py
Please first clone the repo and install the required environment, which can be done by running the following commands:
conda create -n graphgpt python=3.8
conda activate graphgpt
# Torch with CUDA 11.7
pip install torch==1.13.0+cu117 torchvision==0.14.0+cu117 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu117
# To support vicuna base model
pip3 install "fschat[model_worker,webui]"
# To install pyg and pyg-relevant packages
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-1.13.0+cu117.html
# Clone our GraphGPT
git clone https://github.com/HKUDS/GraphGPT.git
cd GraphGPT
# Install required libraries
pip install -r requirements.txt
GraphGPT tuning paradigm consists of two stages: (1) self-supervised instruction tuning; (2) task-specific instruction tuning.
GraphGPT is trained based on following excellent existing models. Please follow the instructions to prepare the checkpoints.
Vicuna:
Prepare our base model Vicuna, which is an instruction-tuned chatbot and base model in our implementation. Please download its weights here. We generally utilize v1.1 and v1.5 model with 7B parameters.
Graph Encoder:
is used to encode graph structures. We employ text-graph grounding approach to obtain the pre-trained graph transformer model, which you could download by graph transformer and put it at [./GraphGPT]. We also provide source codes and example Cora data for text-graph grounding at [./text-graph-grounding] for your reference.
Graph Data:
is a combination of all utilized pyg graph data that contain node features, edge_index and so on. You can download by all_graph_data.pt and put it at [./GraphGPT/graph_data]
Prepare data: Please download our instruction tuning data graph_matching.json for the graph matching task.
Start tuning: After the aforementioned steps, you could start the first stage tuning by filling blanks at graphgpt_stage1.sh. There is an example as below:
# to fill in the following path to run the first stage of our GraphGPT!
model_path=../vicuna-7b-v1.5-16k
instruct_ds=./data/stage_1/graph_matching.json
graph_data_path=./graph_data/all_graph_data.pt
pretra_gnn=clip_gt_arxiv
output_model=./checkpoints/stage_1
wandb offline
python -m torch.distributed.run --nnodes=1 --nproc_per_node=4 --master_port=20001 \
graphgpt/train/train_mem.py \
--model_name_or_path ${model_path} \
--version v1 \
--data_path ${instruct_ds} \
--graph_content ./arxiv_ti_ab.json \
--graph_data_path ${graph_data_path} \
--graph_tower ${pretra_gnn} \
--tune_graph_mlp_adapter True \
--graph_select_layer -2 \
--use_graph_start_end \
--bf16 True \
--output_dir ${output_model} \
--num_train_epochs 3 \
--per_device_train_batch_size 2 \
--per_device_eval_batch_size 2 \
--gradient_accumulation_steps 1 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 2400 \
--save_total_limit 1 \
--learning_rate 2e-3 \
--weight_decay 0. \
--warmup_ratio 0.03 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--tf32 True \
--model_max_length 2048 \
--gradient_checkpointing True \
--lazy_preprocess True \
--report_to wandb
We could extract the trained projector in the stage 1 by filling blanks at extract_projector.sh. There is an example as below:
# to fill in the following path to extract projector for the first tuning stage!
src_model=./checkpoints/stage_1
output_proj=./checkpoints/stage_1_projector/stage_1_projector.bin
python3.8 ./scripts/extract_graph_projector.py \
--model_name_or_path ${src_model} \
--output ${output_proj}
Prepare data: The choices of our task-specific instruction data could be diverse, e.g., standard or COT (Chain-of-Thought) node classification, link prediction or mixing data for multitasking. Please refer to the task_specific.
Start tuning: After the aforementioned steps, you could start the second stage tuning by filling blanks at graphgpt_stage2.sh. There is an example as below:
# to fill in the following path to run the second stage of our GraphGPT!
model_path=../vicuna-7b-v1.5-16k
instruct_ds=./data/stage_2/data_all_mix.json
graph_data_path=./graph_data/all_graph_data.pt
pretra_gnn=clip_gt_arxiv
tuned_proj=./checkpoints/stage_1_projector/stage_1_projector.bin
output_model=./checkpoints/stage_2
wandb offline
python -m torch.distributed.run --nnodes=1 --nproc_per_node=4 --master_port=20001 \
graphgpt/train/train_mem.py \
--model_name_or_path ${model_path} \
--version v1 \
--data_path ${instruct_ds} \
--graph_content ./arxiv_ti_ab.json \
--graph_data_path ${graph_data_path} \
--graph_tower ${pretra_gnn} \
--pretrain_graph_mlp_adapter ${tuned_proj} \
--tune_graph_mlp_adapter True \
--graph_select_layer -2 \
--use_graph_start_end True\
--bf16 True \
--output_dir ${output_model} \
--num_train_epochs 2 \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--gradient_accumulation_steps 1 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 50000 \
--save_total_limit 1 \
--learning_rate 2e-5 \
--weight_decay 0. \
--warmup_ratio 0.03 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--tf32 True \
--model_max_length 2048 \
--gradient_checkpointing True \
--dataloader_num_workers 4 \
--lazy_preprocess True \
--report_to wandb
You could start the second stage tuning by filling blanks at graphgpt_eval.sh. There is an example as below:
# to fill in the following path to extract projector for the second tuning stage!
output_model=./checkpoints/stage_2
datapath=./data/eval/arxiv_nc.json
graph_data_path=./graph_data/all_graph_data.pt
res_path=./output_stage_2_arxiv_nc
start_id=0
end_id=20000
num_gpus=2
python3.8 ./graphgpt/eval/run_graphgpt.py --model-name ${output_model} --prompting_file ${datapath} --graph_data_path ${graph_data_path} --output_res_path ${res_path} --start_id ${start_id} --end_id ${end_id} --num_gpus ${num_gpus}
For any questions or feedback, feel free to contact Jiabin Tang.
If you find GraphGPT useful in your research or applications, please kindly cite:
@articles{tang2023graphgpt,
title={GraphGPT: Graph Instruction Tuning for Large Language Models},
author={Jiabin Tang and Yuhao Yang and Wei Wei and Lei Shi and Lixin Su and Suqi Cheng and Dawei Yin and Chao Huang},
year={2023},
eprint={2310.13023},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
You may refer to related work that serves as foundations for our framework and code repository, Vicuna, LLaVa, We also partially draw inspirations from MiniGPT-4. For the text-graph grounding design, we leverages implementation from G2P2. The design of our website and README.md was inspired by NExT-GPT. Thanks for their wonderful works.
Python
98.9%
Shell
1.1%
[SIGIR'2024] "GraphGPT: Graph Instruction Tuning for Large Language Models"
832
stars
22
commits
Python
primary language
Jun 25, 2024
updated
GraphGPT: Graph Instruction Tuning for Large Language ModelsData Intelligence Lab@University of Hong Kong, Baidu Inc.
This repository hosts the code, data and model weight of GraphGPT (SIGIR'24 full paper track).
The lightweight training requires PyTorch 2.1+, so we need to update corresponding libraries:
# if you have set up the env for GraphGPT earlier
pip uninstall torch
pip uninstall torchvision
pip uninstall torchaudio
# CUDA 11.8
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
# update pyg for the PyTorch 2.1+
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
# install lightning
pip install lightning
Due to compatibility issues, if you are using the previously released graph data, we recommend downloading and updating it according to the provided link: updated graph data.
You can run the scripts as follow:
Stage-1:
cd path/to/GraphGPT
sh ./scripts/tune_script/graphgpt_stage1.sh
Stage-2:
cd path/to/GraphGPT
sh ./scripts/tune_script/graphgpt_stage2.sh
replace_llama_attn_with_flash_attn() in line 8 in https://github.com/HKUDS/GraphGPT/blob/main/graphgpt/train/train_mem.py. For more details, please refer to #17No module named 'graphgpt' error, you could refer to issue #56🎯🎯📢📢 We have made significant updates to the models and data used in our GraphGPT on 🤗 Huggingface. We highly recommend referring to the table below for further details:
| 🤗 Huggingface Address | 🎯 Description |
|---|---|
| huggingface.co/Jiabin99/GraphGPT-7B-mix-all | It's the checkpoint of our GraphGPT based on Vicuna-7B-v1.5 tuned on instruction data Arxiv-PubMed-mix-NC-LP |
| huggingface.co/Jiabin99/Arxiv-PubMed-GraphCLIP-GT | It's the checkpoint of the pre-trained graph transformer (GT) trained on Arxiv and PubMed using Text-Graph grounding. |
| huggingface.co/datasets/Jiabin99/Arxiv-PubMed-mix-NC-LP | This's the mixing instruction dataset with node classification (NC) and link prediction (LP) on Arxiv and PubMed. |
| huggingface.co/datasets/Jiabin99/GraphGPT-eval-instruction | We release all instruction dataset for our evaluation. |
| huggingface.co/datasets/Jiabin99/All_pyg_graph_data | We merge all utilized graph data. |
| huggingface.co/datasets/Jiabin99/graph-matching | This is the instruction data used in graph-matching stage. |
[2023.10.28]📢📢For the Chinese version of the explanation, please refer to this article.
[2023.10.26]🔥🔥Release our utilized Instruction data.
[2023.10.26]🔥🔥Release checkpoints of our GraphGPT and pre-trained graph encoder.
[2023.10.23] 🚀🚀 The full paper of our GraphGPT is available at https://arxiv.org/abs/2310.13023. Please check out it and give us more feedbacks!
[2023.10.15] 🚀🚀 Release the code of GraphGPT.
we present the GraphGPT framework that aligns LLMs with graph structural knowledge with a graph instruction tuning paradigm.
For more technical details, kindly refer to the paper and the project website of our Graph.
.
├── README.md
├── assets
│ ├── demo_narrow.gif
│ ├── screenshot_cli.png
│ ├── screenshot_gui.png
│ ├── server_arch.png
│ └── vicuna_logo.jpeg
├── format.sh
├── graphgpt
│ ├── __init__.py
│ ├── constants.py
│ ├── conversation.py
│ ├── eval
│ │ ├── README.md
│ │ ├── requirements.txt
│ │ ├── run_graphgpt.py
│ │ ├── run_graphgpt_LP.py
│ │ ├── run_vicuna.py
│ │ └── script
│ │ └── run_model_qa.yaml
│ ├── model
│ │ ├── GraphLlama.py
│ │ ├── __init__.py
│ │ ├── apply_delta.py
│ │ ├── apply_lora.py
│ │ ├── builder.py
│ │ ├── compression.py
│ │ ├── convert_fp16.py
│ │ ├── graph_layers
│ │ │ ├── __init__.py
│ │ │ ├── bpe_simple_vocab_16e6.txt.gz
│ │ │ ├── clip_graph.py
│ │ │ ├── graph_transformer.py
│ │ │ ├── mpnn.py
│ │ │ └── simple_tokenizer.py
│ │ ├── make_delta.py
│ │ ├── model_adapter.py
│ │ ├── model_registry.py
│ │ ├── monkey_patch_non_inplace.py
│ │ └── utils.py
│ ├── protocol
│ │ └── openai_api_protocol.py
│ ├── serve
│ │ ├── __init__.py
│ │ ├── api_provider.py
│ │ ├── bard_worker.py
│ │ ├── cacheflow_worker.py
│ │ ├── cli.py
│ │ ├── controller.py
│ │ ├── gateway
│ │ │ ├── README.md
│ │ │ └── nginx.conf
│ │ ├── gradio_block_arena_anony.py
│ │ ├── gradio_block_arena_named.py
│ │ ├── gradio_css.py
│ │ ├── gradio_patch.py
│ │ ├── gradio_web_server.py
│ │ ├── gradio_web_server_multi.py
│ │ ├── huggingface_api.py
│ │ ├── inference.py
│ │ ├── model_worker.py
│ │ ├── monitor
│ │ │ ├── basic_stats.py
│ │ │ ├── clean_battle_data.py
│ │ │ ├── elo_analysis.py
│ │ │ ├── hf_space_leaderboard_app.py
│ │ │ └── monitor.py
│ │ ├── openai_api_server.py
│ │ ├── register_worker.py
│ │ ├── test_message.py
│ │ └── test_throughput.py
│ ├── train
│ │ ├── graphchat_trainer.py
│ │ ├── llama_flash_attn_monkey_patch.py
│ │ ├── train_graph.py
│ │ ├── train_lora.py
│ │ └── train_mem.py
│ └── utils.py
├── playground
│ ├── inspect_conv.py
│ ├── test_embedding
│ │ ├── README.md
│ │ ├── test_classification.py
│ │ ├── test_semantic_search.py
│ │ └── test_sentence_similarity.py
│ └── test_openai_api
│ ├── anthropic_api.py
│ └── openai_api.py
├── pyproject.toml
├── scripts
│ ├── eval_script
│ │ └── graphgpt_eval.sh
│ ├── extract_graph_projector.py
│ ├── serving
│ │ ├── controller.yaml
│ │ └── model_worker.yaml
│ └── tune_script
│ ├── extract_projector.sh
│ ├── graphgpt_stage1.sh
│ └── graphgpt_stage2.sh
└── tests
├── test_openai_curl.sh
├── test_openai_langchain.py
└── test_openai_sdk.py
Please first clone the repo and install the required environment, which can be done by running the following commands:
conda create -n graphgpt python=3.8
conda activate graphgpt
# Torch with CUDA 11.7
pip install torch==1.13.0+cu117 torchvision==0.14.0+cu117 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu117
# To support vicuna base model
pip3 install "fschat[model_worker,webui]"
# To install pyg and pyg-relevant packages
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-1.13.0+cu117.html
# Clone our GraphGPT
git clone https://github.com/HKUDS/GraphGPT.git
cd GraphGPT
# Install required libraries
pip install -r requirements.txt
GraphGPT tuning paradigm consists of two stages: (1) self-supervised instruction tuning; (2) task-specific instruction tuning.
GraphGPT is trained based on following excellent existing models. Please follow the instructions to prepare the checkpoints.
Vicuna:
Prepare our base model Vicuna, which is an instruction-tuned chatbot and base model in our implementation. Please download its weights here. We generally utilize v1.1 and v1.5 model with 7B parameters.
Graph Encoder:
is used to encode graph structures. We employ text-graph grounding approach to obtain the pre-trained graph transformer model, which you could download by graph transformer and put it at [./GraphGPT]. We also provide source codes and example Cora data for text-graph grounding at [./text-graph-grounding] for your reference.
Graph Data:
is a combination of all utilized pyg graph data that contain node features, edge_index and so on. You can download by all_graph_data.pt and put it at [./GraphGPT/graph_data]
Prepare data: Please download our instruction tuning data graph_matching.json for the graph matching task.
Start tuning: After the aforementioned steps, you could start the first stage tuning by filling blanks at graphgpt_stage1.sh. There is an example as below:
# to fill in the following path to run the first stage of our GraphGPT!
model_path=../vicuna-7b-v1.5-16k
instruct_ds=./data/stage_1/graph_matching.json
graph_data_path=./graph_data/all_graph_data.pt
pretra_gnn=clip_gt_arxiv
output_model=./checkpoints/stage_1
wandb offline
python -m torch.distributed.run --nnodes=1 --nproc_per_node=4 --master_port=20001 \
graphgpt/train/train_mem.py \
--model_name_or_path ${model_path} \
--version v1 \
--data_path ${instruct_ds} \
--graph_content ./arxiv_ti_ab.json \
--graph_data_path ${graph_data_path} \
--graph_tower ${pretra_gnn} \
--tune_graph_mlp_adapter True \
--graph_select_layer -2 \
--use_graph_start_end \
--bf16 True \
--output_dir ${output_model} \
--num_train_epochs 3 \
--per_device_train_batch_size 2 \
--per_device_eval_batch_size 2 \
--gradient_accumulation_steps 1 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 2400 \
--save_total_limit 1 \
--learning_rate 2e-3 \
--weight_decay 0. \
--warmup_ratio 0.03 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--tf32 True \
--model_max_length 2048 \
--gradient_checkpointing True \
--lazy_preprocess True \
--report_to wandb
We could extract the trained projector in the stage 1 by filling blanks at extract_projector.sh. There is an example as below:
# to fill in the following path to extract projector for the first tuning stage!
src_model=./checkpoints/stage_1
output_proj=./checkpoints/stage_1_projector/stage_1_projector.bin
python3.8 ./scripts/extract_graph_projector.py \
--model_name_or_path ${src_model} \
--output ${output_proj}
Prepare data: The choices of our task-specific instruction data could be diverse, e.g., standard or COT (Chain-of-Thought) node classification, link prediction or mixing data for multitasking. Please refer to the task_specific.
Start tuning: After the aforementioned steps, you could start the second stage tuning by filling blanks at graphgpt_stage2.sh. There is an example as below:
# to fill in the following path to run the second stage of our GraphGPT!
model_path=../vicuna-7b-v1.5-16k
instruct_ds=./data/stage_2/data_all_mix.json
graph_data_path=./graph_data/all_graph_data.pt
pretra_gnn=clip_gt_arxiv
tuned_proj=./checkpoints/stage_1_projector/stage_1_projector.bin
output_model=./checkpoints/stage_2
wandb offline
python -m torch.distributed.run --nnodes=1 --nproc_per_node=4 --master_port=20001 \
graphgpt/train/train_mem.py \
--model_name_or_path ${model_path} \
--version v1 \
--data_path ${instruct_ds} \
--graph_content ./arxiv_ti_ab.json \
--graph_data_path ${graph_data_path} \
--graph_tower ${pretra_gnn} \
--pretrain_graph_mlp_adapter ${tuned_proj} \
--tune_graph_mlp_adapter True \
--graph_select_layer -2 \
--use_graph_start_end True\
--bf16 True \
--output_dir ${output_model} \
--num_train_epochs 2 \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--gradient_accumulation_steps 1 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 50000 \
--save_total_limit 1 \
--learning_rate 2e-5 \
--weight_decay 0. \
--warmup_ratio 0.03 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--tf32 True \
--model_max_length 2048 \
--gradient_checkpointing True \
--dataloader_num_workers 4 \
--lazy_preprocess True \
--report_to wandb
You could start the second stage tuning by filling blanks at graphgpt_eval.sh. There is an example as below:
# to fill in the following path to extract projector for the second tuning stage!
output_model=./checkpoints/stage_2
datapath=./data/eval/arxiv_nc.json
graph_data_path=./graph_data/all_graph_data.pt
res_path=./output_stage_2_arxiv_nc
start_id=0
end_id=20000
num_gpus=2
python3.8 ./graphgpt/eval/run_graphgpt.py --model-name ${output_model} --prompting_file ${datapath} --graph_data_path ${graph_data_path} --output_res_path ${res_path} --start_id ${start_id} --end_id ${end_id} --num_gpus ${num_gpus}
For any questions or feedback, feel free to contact Jiabin Tang.
If you find GraphGPT useful in your research or applications, please kindly cite:
@articles{tang2023graphgpt,
title={GraphGPT: Graph Instruction Tuning for Large Language Models},
author={Jiabin Tang and Yuhao Yang and Wei Wei and Lei Shi and Lixin Su and Suqi Cheng and Dawei Yin and Chao Huang},
year={2023},
eprint={2310.13023},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
You may refer to related work that serves as foundations for our framework and code repository, Vicuna, LLaVa, We also partially draw inspirations from MiniGPT-4. For the text-graph grounding design, we leverages implementation from G2P2. The design of our website and README.md was inspired by NExT-GPT. Thanks for their wonderful works.
Python
98.9%
Shell
1.1%