Morizeyao / GPT2-Chinese

Chinese version of GPT2 training code, using BERT tokenizer.
MIT License
7.45k stars 1.7k forks source link

mac运行错误 #198

Closed linkangren closed 3 years ago

linkangren commented 3 years ago

模型还得另外下载吗?放哪个文件夹

2021-03-04 01:18:14.945849: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f838ff8f2e0 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2021-03-04 01:18:14.945907: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version args: Namespace(batch_size=1, device='0,1,2,3', fast_pattern=True, length=50, model_config='config/model_config_small.json', model_path='model/final_model', no_wordpiece=False, nsamples=4, prefix='[CLS]最美的不是下雨天,是曾与你躲过雨的屋檐', repetition_penalty=1.0, save_samples=True, save_samples_path='.', segment=False, temperature=1, tokenizer_path='cache/vocab_small.txt', topk=8, topp=0) Traceback (most recent call last): File "/Users/linkangren/opt/anaconda3/envs/paddle_env/lib/python3.7/site-packages/transformers/configuration_utils.py", line 133, in from_pretrained resolved_config_file = cached_path(config_file, cache_dir=cache_dir, force_download=force_download, proxies=proxies) File "/Users/linkangren/opt/anaconda3/envs/paddle_env/lib/python3.7/site-packages/transformers/file_utils.py", line 182, in cached_path raise EnvironmentError("file {} not found".format(url_or_filename)) OSError: file model/final_model not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./generate.py", line 222, in main() File "./generate.py", line 165, in main model = GPT2LMHeadModel.from_pretrained(args.model_path) File "/Users/linkangren/opt/anaconda3/envs/paddle_env/lib/python3.7/site-packages/transformers/modeling_utils.py", line 287, in from_pretrained **kwargs File "/Users/linkangren/opt/anaconda3/envs/paddle_env/lib/python3.7/site-packages/transformers/configuration_utils.py", line 145, in from_pretrained raise EnvironmentError(msg) OSError: Model name 'model/final_model' was not found in model name list (gpt2, gpt2-medium, gpt2-large, distilgpt2). We assumed 'model/final_model' was a path or url to a configuration file named config.json or a directory containing such a file but couldn't find any such file at this path or url.

libralibra commented 3 years ago

Model name 'model/final_model' was not found

你看生成的代码,如果没有指定模型路径,默认路径是'model/final_model',把你下载的其他网友训练好的模型放在这个路径下就可以,如果没有文件夹需要新建.

如果你是自己训练,训练好的模型会自动在这个路径下.