prakhar21 / TextAugmentation-GPT2

Fine-tuned pre-trained GPT2 for custom topic specific text generation. Such system can be used for Text Augmentation.
MIT License
187 stars 43 forks source link

generate.py cur_ids = torch.cat([cur_ids, torch.ones((1,1)).long().to(device) * next_token_id], dim = 1) name 'device' is not defined #12

Open xsyzka opened 2 years ago

xsyzka commented 2 years ago

NameError: name 'device' is not defined ?How can I solve it, thank you

BucketHeadP65 commented 2 years ago

@xsyzka Welp it might be too late: The root cause of the error is that the variable device is not defined :P . But even if you define it you might encounter the following issues:

1) To use the pre-trained model that @prakhar21 provides you need an older version of transformers (2.8.0) which i managed to run only with cpu. 2) You can use newer version of transformers and train your own model. Then you can make the following changes:

fix

xsyzka commented 2 years ago

Thank you very much for your advice!

xsyzka commented 2 years ago

@xsyzka好吧,可能为时已晚:错误的根本原因是设备未:P定义。但是,即使您定义了它,也可能会遇到以下问题:

  1. 要使用@prakhar21使用的预训练模型,您需要一个旧版本的转换器,我设法仅使用cpu运行
  2. 您可以使用较新版本的转换器并训练自己的模型。然后,您可以进行以下更改:

修复

Thank you very much for your advice!

BucketHeadP65 commented 2 years ago

Thank you very much for your advice!

You are welcome!