Created
June 8, 2021 17:10
-
-
Save faisalhmohd/d2629aef9e172c5f1028762c6b78cf28 to your computer and use it in GitHub Desktop.
Simple GPT-NEO Text Generation Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pre-install Dependencies | |
# pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html | |
# pip install transformers | |
from transformers import pipeline | |
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B') | |
article_title = "batman is too strong for superman" | |
res = generator(prompt, max_length=50, do_sample=True, temperature=0.9) # Play around with the parameters here to vary your output | |
print(res[0]['generated_text']) | |
# Output: | |
# batman is too strong for superman (even for superman), and batman and romano are too strong for batman. | |
# In my opinion, this is the best example. In the end, the whole thing is a very |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment