Skip to content

Instantly share code, notes, and snippets.

@faisalhmohd
Created June 8, 2021 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faisalhmohd/d2629aef9e172c5f1028762c6b78cf28 to your computer and use it in GitHub Desktop.
Save faisalhmohd/d2629aef9e172c5f1028762c6b78cf28 to your computer and use it in GitHub Desktop.
Simple GPT-NEO Text Generation Example
# 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