HKUDS / GraphGPT

[SIGIR'2024] "GraphGPT: Graph Instruction Tuning for Large Language Models"
https://arxiv.org/abs/2310.13023
Apache License 2.0
635 stars 59 forks source link

关于运行graphgpt_eval.sh找不到模块的问题 #16

Closed nulinuli closed 11 months ago

nulinuli commented 1 year ago

import torch import os import sys sys.path.append(u'/home/fry/桌面/GraphGPT/graphgpt') from conversation import conv_templates, SeparatorStyle from transformers import CLIPVisionModel, CLIPImageProcessor, StoppingCriteria from model import * 为了找到上级目录下的模块,我用了sys.path,在修改完引用之后,运行之后又出现了其他一些找不到模块的问题,因为文件较多有点复杂不知道该怎么搞,之前把graphgpt_eval.sh以及run_graphgpt.py放在根目录里是可以运行的,但是运行一段时间后还是会有找不到模块的问题,这些文件有点复杂位置都很分散,现在不知道该如何解决了,恳请您的指点!

tjb-tech commented 1 year ago

import torch import os import sys sys.path.append(u'/home/fry/桌面/GraphGPT/graphgpt') from conversation import conv_templates, SeparatorStyle from transformers import CLIPVisionModel, CLIPImageProcessor, StoppingCriteria from model import * 为了找到上级目录下的模块,我用了sys.path,在修改完引用之后,运行之后又出现了其他一些找不到模块的问题,因为文件较多有点复杂不知道该怎么搞,之前把graphgpt_eval.sh以及run_graphgpt.py放在根目录里是可以运行的,但是运行一段时间后还是会有找不到模块的问题,这些文件有点复杂位置都很分散,现在不知道该如何解决了,恳请您的指点!

感谢您的反馈。graphgpt_eval.sh应该在GraphGPT的目录下运行,但不需要改变文件的位置,可以参考以下命令:

cd path/to/GraphGPT
sh path/to/graphgpt_eval.sh
nulinuli commented 1 year ago

谢谢您的答复,运行run_graphgpt.py会出现下列问题

(graphgpt) fry@fry-MS-7D90:~/GraphGPT$ sh ./scripts/eval_script/graphgpt_eval.sh Traceback (most recent call last): File "./graphgpt/eval/run_graphgpt.py", line 5, in from graphgpt.conversation import conv_templates, SeparatorStyle ModuleNotFoundError: No module named 'graphgpt'

然后我试着将run_graphgpt.py文件放在根目录下运行之后出现下列问题

(graphgpt) fry@fry-MS-7D90:~/GraphGPT$ sh ./scripts/eval_script/graphgpt_eval.sh 2023-11-10 10:05:13,195 INFO worker.py:1673 -- Started a local Ray instance. (eval_model pid=4924) start loading (eval_model pid=4924) Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained. (eval_model pid=4924) finish loading (eval_model pid=4924) start loading (eval_model pid=4924) Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained. Traceback (most recent call last): File "./run_graphgpt.py", line 240, in run_eval(args, args.num_gpus) File "./run_graphgpt.py", line 94, in run_eval ans_jsons.extend(ray.get(ans_handle)) File "/home/fry/.conda/envs/graphgpt/lib/python3.8/site-packages/ray/_private/auto_init_hook.py", line 24, in auto_init_wrapper return fn(*args, kwargs) File "/home/fry/.conda/envs/graphgpt/lib/python3.8/site-packages/ray/_private/client_mode_hook.py", line 103, in wrapper return func(*args, *kwargs) File "/home/fry/.conda/envs/graphgpt/lib/python3.8/site-packages/ray/_private/worker.py", line 2563, in get raise value.as_instanceof_cause() ray.exceptions.RayTaskError(AssertionError): ray::eval_model() (pid=4924, ip=172.27.37.124) File "/home/fry/.conda/envs/graphgpt/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, kwargs) File "./run_graphgpt.py", line 116, in eval_model model = GraphLlamaForCausalLM.from_pretrained(args.model_name, torch_dtype=torch.float16, use_cache=True, low_cpu_mem_usage=True).cuda() File "/home/fry/.conda/envs/graphgpt/lib/python3.8/site-packages/transformers/modeling_utils.py", line 3085, in from_pretrained model = cls(config, *model_args, **model_kwargs) File "/home/fry/GraphGPT/graphgpt/model/GraphLlama.py", line 283, in init self.model = GraphLlamaModel(config) File "/home/fry/GraphGPT/graphgpt/model/GraphLlama.py", line 103, in init clip_graph, args= load_model_pretrained(CLIP, config.pretrain_graph_model_path) File "/home/fry/GraphGPT/graphgpt/model/GraphLlama.py", line 54, in load_model_pretrained assert osp.exists(osp.join(pretrain_model_path, 'config.json')), 'config.json missing' AssertionError: config.json missing

再次麻烦您指点一下!

import torch import os import sys sys.path.append(u'/home/fry/桌面/GraphGPT/graphgpt') from conversation import conv_templates, SeparatorStyle from transformers import CLIPVisionModel, CLIPImageProcessor, StoppingCriteria from model import * 为了找到上级目录下的模块,我用了sys.path,在修改完引用之后,运行之后又出现了其他一些找不到模块的问题,因为文件较多有点复杂不知道该怎么搞,之前把graphgpt_eval.sh以及run_graphgpt.py放在根目录里是可以运行的,但是运行一段时间后还是会有找不到模块的问题,这些文件有点复杂位置都很分散,现在不知道该如何解决了,恳请您的指点!

感谢您的反馈。graphgpt_eval.sh应该在GraphGPT的目录下运行,但不需要改变文件的位置,可以参考以下命令:

cd path/to/GraphGPT
sh path/to/graphgpt_eval.sh
tjb-tech commented 1 year ago

AssertionError: config.json missing

AssertionError: config.json missing的问题在于您没有将pre-trained GNN放入目录中,并使得pretrain_model_path指向pre-trained GNN

nulinuli commented 1 year ago

我的[pre-trained GNN]是在checkpoints/stage_里面,我发现他的pretrain_graph_model_path指向如下,我并未找到该config文件,我该如何修改呢

(eval_model pid=10444) config: GraphLlamaConfig { (eval_model pid=10444) "_name_or_path": "./checkpoints/stage_2", (eval_model pid=10444) "architectures": [ (eval_model pid=10444) "GraphLlamaForCausalLM" (eval_model pid=10444) ], (eval_model pid=10444) "attention_bias": false, (eval_model pid=10444) "bos_token_id": 1, (eval_model pid=10444) "eos_token_id": 2, (eval_model pid=10444) "freeze_graph_mlp_adapter": false, (eval_model pid=10444) "graph_hidden_size": 128, (eval_model pid=10444) "graph_select_layer": -2, (eval_model pid=10444) "graph_tower": "clip_gt_arxiv_pub", (eval_model pid=10444) "hidden_act": "silu", (eval_model pid=10444) "hidden_size": 4096, (eval_model pid=10444) "initializer_range": 0.02, (eval_model pid=10444) "intermediate_size": 11008, (eval_model pid=10444) "max_position_embeddings": 4096, (eval_model pid=10444) "max_sequence_length": 16384, (eval_model pid=10444) "model_type": "GraphLlama", (eval_model pid=10444) "num_attention_heads": 32, (eval_model pid=10444) "num_hidden_layers": 32, (eval_model pid=10444) "num_key_value_heads": 32, (eval_model pid=10444) "pad_token_id": 0, (eval_model pid=10444) "pretrain_graph_model_path": "./clip_gt_arxiv_pub", (eval_model pid=10444) "pretraining_tp": 1, (eval_model pid=10444) "rms_norm_eps": 1e-05, (eval_model pid=10444) "rope_scaling": { (eval_model pid=10444) "factor": 4.0, (eval_model pid=10444) "type": "linear" (eval_model pid=10444) }, (eval_model pid=10444) "rope_theta": 10000.0, (eval_model pid=10444) "sep_graph_conv_front": false, (eval_model pid=10444) "tie_word_embeddings": false, (eval_model pid=10444) "torch_dtype": "float32", (eval_model pid=10444) "transformers_version": "4.34.1", (eval_model pid=10444) "tune_graph_mlp_adapter": true, (eval_model pid=10444) "use_cache": true, (eval_model pid=10444) "use_graph_proj": true, (eval_model pid=10444) "use_graph_start_end": true, (eval_model pid=10444) "vocab_size": 32003 (eval_model pid=10444) } (eval_model pid=10444)

AssertionError: config.json missing

AssertionError: config.json missing的问题在于您没有将pre-trained GNN放入目录中,并使得pretrain_model_path指向pre-trained GNN

tjb-tech commented 1 year ago

可以直接修改直接修改载入checkpoint的config.json文件

我的[pre-trained GNN]是在checkpoints/stage_里面,我发现他的pretrain_graph_model_path指向如下,我并未找到该config文件,我该如何修改呢

(eval_model pid=10444) config: GraphLlamaConfig { (eval_model pid=10444) "_name_or_path": "./checkpoints/stage_2", (eval_model pid=10444) "architectures": [ (eval_model pid=10444) "GraphLlamaForCausalLM" (eval_model pid=10444) ], (eval_model pid=10444) "attention_bias": false, (eval_model pid=10444) "bos_token_id": 1, (eval_model pid=10444) "eos_token_id": 2, (eval_model pid=10444) "freeze_graph_mlp_adapter": false, (eval_model pid=10444) "graph_hidden_size": 128, (eval_model pid=10444) "graph_select_layer": -2, (eval_model pid=10444) "graph_tower": "clip_gt_arxiv_pub", (eval_model pid=10444) "hidden_act": "silu", (eval_model pid=10444) "hidden_size": 4096, (eval_model pid=10444) "initializer_range": 0.02, (eval_model pid=10444) "intermediate_size": 11008, (eval_model pid=10444) "max_position_embeddings": 4096, (eval_model pid=10444) "max_sequence_length": 16384, (eval_model pid=10444) "model_type": "GraphLlama", (eval_model pid=10444) "num_attention_heads": 32, (eval_model pid=10444) "num_hidden_layers": 32, (eval_model pid=10444) "num_key_value_heads": 32, (eval_model pid=10444) "pad_token_id": 0, (eval_model pid=10444) "pretrain_graph_model_path": "./clip_gt_arxiv_pub", (eval_model pid=10444) "pretraining_tp": 1, (eval_model pid=10444) "rms_norm_eps": 1e-05, (eval_model pid=10444) "rope_scaling": { (eval_model pid=10444) "factor": 4.0, (eval_model pid=10444) "type": "linear" (eval_model pid=10444) }, (eval_model pid=10444) "rope_theta": 10000.0, (eval_model pid=10444) "sep_graph_conv_front": false, (eval_model pid=10444) "tie_word_embeddings": false, (eval_model pid=10444) "torch_dtype": "float32", (eval_model pid=10444) "transformers_version": "4.34.1", (eval_model pid=10444) "tune_graph_mlp_adapter": true, (eval_model pid=10444) "use_cache": true, (eval_model pid=10444) "use_graph_proj": true, (eval_model pid=10444) "use_graph_start_end": true, (eval_model pid=10444) "vocab_size": 32003 (eval_model pid=10444) } (eval_model pid=10444)

AssertionError: config.json missing

AssertionError: config.json missing的问题在于您没有将pre-trained GNN放入目录中,并使得pretrain_model_path指向pre-trained GNN

nulinuli commented 11 months ago

我已收到你的信啦!

CigarOVO commented 1 month ago

我的[pre-trained GNN]是在checkpoints/stage_里面,我发现他的pretrain_graph_model_path指向如下,我并未找到该config文件,我该如何修改呢

(eval_model pid=10444) config: GraphLlamaConfig { (eval_model pid=10444) "_name_or_path": "./checkpoints/stage_2", (eval_model pid=10444) "architectures": [ (eval_model pid=10444) "GraphLlamaForCausalLM" (eval_model pid=10444) ], (eval_model pid=10444) "attention_bias": false, (eval_model pid=10444) "bos_token_id": 1, (eval_model pid=10444) "eos_token_id": 2, (eval_model pid=10444) "freeze_graph_mlp_adapter": false, (eval_model pid=10444) "graph_hidden_size": 128, (eval_model pid=10444) "graph_select_layer": -2, (eval_model pid=10444) "graph_tower": "clip_gt_arxiv_pub", (eval_model pid=10444) "hidden_act": "silu", (eval_model pid=10444) "hidden_size": 4096, (eval_model pid=10444) "initializer_range": 0.02, (eval_model pid=10444) "intermediate_size": 11008, (eval_model pid=10444) "max_position_embeddings": 4096, (eval_model pid=10444) "max_sequence_length": 16384, (eval_model pid=10444) "model_type": "GraphLlama", (eval_model pid=10444) "num_attention_heads": 32, (eval_model pid=10444) "num_hidden_layers": 32, (eval_model pid=10444) "num_key_value_heads": 32, (eval_model pid=10444) "pad_token_id": 0, (eval_model pid=10444) "pretrain_graph_model_path": "./clip_gt_arxiv_pub", (eval_model pid=10444) "pretraining_tp": 1, (eval_model pid=10444) "rms_norm_eps": 1e-05, (eval_model pid=10444) "rope_scaling": { (eval_model pid=10444) "factor": 4.0, (eval_model pid=10444) "type": "linear" (eval_model pid=10444) }, (eval_model pid=10444) "rope_theta": 10000.0, (eval_model pid=10444) "sep_graph_conv_front": false, (eval_model pid=10444) "tie_word_embeddings": false, (eval_model pid=10444) "torch_dtype": "float32", (eval_model pid=10444) "transformers_version": "4.34.1", (eval_model pid=10444) "tune_graph_mlp_adapter": true, (eval_model pid=10444) "use_cache": true, (eval_model pid=10444) "use_graph_proj": true, (eval_model pid=10444) "use_graph_start_end": true, (eval_model pid=10444) "vocab_size": 32003 (eval_model pid=10444) } (eval_model pid=10444)

AssertionError: config.json missing

AssertionError: config.json missing的问题在于您没有将pre-trained GNN放入目录中,并使得pretrain_model_path指向pre-trained GNN

请问是如何修改的呢?我修改二阶段checkpoint中的config.json还是报这个错误