birgermoell
commited on
Commit
·
1c47fec
1
Parent(s):
de02b26
Added eval script
Browse files- evaluate.py +5 -9
evaluate.py
CHANGED
@@ -1,14 +1,10 @@
|
|
1 |
-
from transformers import GPT2Tokenizer, GPT2Model, pipeline, set_seed
|
2 |
|
3 |
tokenizer = GPT2Tokenizer.from_pretrained("flax-community/swe-gpt-wiki")
|
4 |
-
model =
|
5 |
|
6 |
-
>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="jax")
|
7 |
-
>>> outputs = model(**inputs, labels=inputs["input_ids"])
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
generator = pipeline('text-generation', model=model)
|
13 |
set_seed(42)
|
14 |
-
generator("
|
|
|
|
1 |
+
from transformers import GPT2Tokenizer, GPT2Model, FlaxGPT2LMHeadModel, GPT2LMHeadModel, pipeline, set_seed
|
2 |
|
3 |
tokenizer = GPT2Tokenizer.from_pretrained("flax-community/swe-gpt-wiki")
|
4 |
+
model = GPT2LMHeadModel.from_pretrained("flax-community/swe-gpt-wiki")
|
5 |
|
|
|
|
|
6 |
|
7 |
+
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
|
|
|
|
|
|
8 |
set_seed(42)
|
9 |
+
result = generator("Sveriges huvudstad är", max_length=30, num_return_sequences=5)
|
10 |
+
print(result)
|