pbloem / former

Simple transformer implementation from scratch in pytorch.
http://peterbloem.nl/blog/transformers
MIT License
1.04k stars 171 forks source link

Using the trained model #14

Closed ShivanshuPurohit closed 4 years ago

ShivanshuPurohit commented 4 years ago

How do I use the trained model to generate text?

pbloem commented 4 years ago

The script currently doesn't allow saving and loading. See https://pytorch.org/tutorials/beginner/saving_loading_models.html for instructions on how to add this.

These lines are responsible for generating some text from the model. You can adapt those as necessary. Text generation happens in batches so you may need to stare at the code for a bit to see how it works.