Open licx11 opened 7 months ago
因为网络原因,我本地下载了gpt2模型,并修改了原代码中GPT4TS.py 36行处: self.gpt2 = GPT2Model.from_pretrained('gpt2', output_attentions=True, output_hidden_states=True) 为 self.gpt2 = AutoModelForCausalLM.from_pretrained("/***/models--openai-community--gpt2/snapshots/607a30d783dfa663caf39e06633721c8d4cfcd7e", output_attentions=True, output_hidden_states=True) 然后在运行脚本时遇到问题: self.gpt2.h = self.gpt2.h[:configs.gpt_layers]处报错 AttributeError: 'GPT2LMHeadModel' object has no attribute 'h'
self.gpt2 = GPT2Model.from_pretrained('gpt2', output_attentions=True, output_hidden_states=True)
self.gpt2 = AutoModelForCausalLM.from_pretrained("/***/models--openai-community--gpt2/snapshots/607a30d783dfa663caf39e06633721c8d4cfcd7e", output_attentions=True, output_hidden_states=True)
self.gpt2.h = self.gpt2.h[:configs.gpt_layers]
可以看一下源码https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py 与使用方式,GPT2LMHeadModel的一个变量transformer是GPT2Model
因为网络原因,我本地下载了gpt2模型,并修改了原代码中GPT4TS.py 36行处:
self.gpt2 = GPT2Model.from_pretrained('gpt2', output_attentions=True, output_hidden_states=True)
为self.gpt2 = AutoModelForCausalLM.from_pretrained("/***/models--openai-community--gpt2/snapshots/607a30d783dfa663caf39e06633721c8d4cfcd7e", output_attentions=True, output_hidden_states=True)
然后在运行脚本时遇到问题:self.gpt2.h = self.gpt2.h[:configs.gpt_layers]
处报错 AttributeError: 'GPT2LMHeadModel' object has no attribute 'h'