Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import torch
- from transformers import GPT2LMHeadModel, GPT2Tokenizer
- model = _pretrained('gpt2')
- tokenizer = _pretrained('gpt2')
- input_text = 'Once upon a time'
- input_ids = tokenizer(input_text, return_tensors='pt')['input_ids']
- output = (input_ids, max_length=100, num_return_sequences=1)
- output_text = (output[0], skip_special_tokens=True)
- print(output_text)
Advertisement
Advertisement