swe-gpt-wiki / evaluate.py
birgermoell's picture
Updated generation script2
ea54aa8
raw
history blame contribute delete
457 Bytes
from transformers import GPT2Tokenizer, GPT2Model, FlaxGPT2LMHeadModel, GPT2LMHeadModel, pipeline, set_seed
tokenizer = GPT2Tokenizer.from_pretrained("flax-community/swe-gpt-wiki")
model = GPT2LMHeadModel.from_pretrained("flax-community/swe-gpt-wiki")
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
set_seed(42)
result = generator("En dag för länge sedan så fanns det", max_length=150, num_return_sequences=5)
print(result)