ClipCap-Chinese
ClipCap-Chinese copied to clipboard
GPT2模型加载以及MappingNetwork
感谢您的工作!在实验过程中,我发现了以下问题:
- model.py中gpt2的加载报错
try: self.gpt2 = GPT2LMHeadModel.from_pretrained(gpt2_path) logger.info('succeed to load pretrain gpt2 model') except: config = GPT2Config.from_pretrained(gpt2_path) self.gpt2 = GPT2LMHeadModel.from_config(config) logger.info('random initialize gpt2 model')
line178: AttributeError: type object 'GPT2LMHeadModel' has no attribute 'from_config' 可直接修改为加载GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-cluecorpussmall") - model.py中Mapping Ntework的加载出错
if mapping_type == MappingType.MLP: self.clip_project = MLP((clip_size, (self.prefix_size * prefix_len) // 2, self.prefix_size * prefix_len)) else: self.clip_project = BertMapper(bert_config, clip_size, self.prefix_size, prefix_len, constant_len)
MappingType.MLP应该修改为MappingType.MLP.value,不然传入的str=mlp没有意义,会一直去加载Bert的Transformer结构 - train_finetune_gpt2.sh脚本中并未指定finetune_gpt2参数,而train.py中该参数默认为False,即直接运行该脚本gpt2不会进行微调
关于问题3的话,代码是用了一个action = ‘store_true’,在bash里申明了就自动变为true了,可能是作者的习惯吧