GPT2-NewsTitle icon indicating copy to clipboard operation
GPT2-NewsTitle copied to clipboard

新vocab和预训练模型不匹配问题

Open xdnjust opened this issue 2 years ago • 1 comments

楼主你好,感谢分享,代码中有个问题请教:如果加载的config和vocab对应的vocab_size=13317,但是模型预加载预训练模型,岂不是vocab_size冲突了,请问应该如何处理

model_config = GPT2Config.from_json_file(args.config_path) if args.pretrained_model_path: model = GPT2LMHeadModel.from_pretrained(args.pretrained_model_path) else: model = GPT2LMHeadModel(config=model_config) tokenizer = BertTokenizer.from_pretrained(args.vocab_path, do_lower_case=True)

xdnjust avatar Mar 11 '22 04:03 xdnjust

你加载你预训练模型的config和vocab就可以呀。我项目里的模型为了减少模型大小,删除了原始vocab中无用字符。

liucongg avatar Mar 11 '22 09:03 liucongg