File size: 439 Bytes
1d2d61e
 
d1850c7
 
1d2d61e
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
from transformers import GPT2Tokenizer, GPT2Model, FlaxGPT2LMHeadModel, GPT2LMHeadModel, pipeline, set_seed
 
tokenizer = GPT2Tokenizer.from_pretrained("flax-community/dansk-gpt-wiki")
model = GPT2LMHeadModel.from_pretrained("flax-community/dansk-gpt-wiki")


generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
set_seed(42)
result = generator("Jeg elsker livet", max_length=150, num_return_sequences=5)
print(result)