Created placeholder readme with examples
Browse files
README.md
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Model page TODO. Model name in my thesis was FinnGPT but I chose not to pollute the namespace and leave that kind of name for a more serious attempt at Finnish GPT models.
|
2 |
+
|
3 |
+
### How to use
|
4 |
+
|
5 |
+
Example with text generation pipeline:
|
6 |
+
|
7 |
+
|
8 |
+
```python
|
9 |
+
>>> from transformers import pipeline
|
10 |
+
>>> generator = pipeline('text-generation', model='hatanp/gpt-fi')
|
11 |
+
>>> generator("Testilauseella voidaan testata tokenisointia. Tämän jatkaminen on luultavasti vaikeaa, mutta", max_length=3,do_sample=True, top_p=0.9, top_k=12, temperature=0.9, num_return_sequences=2)
|
12 |
+
|
13 |
+
[{'generated_text': 'Testilauseella voidaan testata tokenisointia. Tämän jatkaminen on luultavasti vaikeaa, mutta ei mahdotonta. \n Jos et ole kiinnostunut tokenis'},
|
14 |
+
{'generated_text': 'Testilauseella voidaan testata tokenisointia. Tämän jatkaminen on luultavasti vaikeaa, mutta sen toteuttaminen onnistuu, jos testilaboratorio osaa analysoida'},
|
15 |
+
{'generated_text': 'Testilauseella voidaan testata tokenisointia. Tämän jatkaminen on luultavasti vaikeaa, mutta sen testaaminen on silti hyödyllistä. Jos testisuorit'}]
|
16 |
+
```
|
17 |
+
|
18 |
+
Example to generate text manually:
|
19 |
+
|
20 |
+
```python
|
21 |
+
>>> from transformers import AutoModelForCausalLM,AutoTokenizer
|
22 |
+
>>> model = AutoModelForCausalLM.from_pretrained("hatanp/gpt-fi")
|
23 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("hatanp/gpt-fi")
|
24 |
+
>>> prompt = "Testilauseella voidaan testata tokenisointia. Tämän jatkaminen on luultavasti vaikeaa, mutta"
|
25 |
+
>>> inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
|
26 |
+
>>> prompt_len = len(tokenizer.decode(inputs[0],skip_special_tokens=True, clean_up_tokenization_spaces=True))
|
27 |
+
>>> outputs = model.generate(inputs, max_length=len(inputs[0])+20, do_sample=True, top_p=0.9, top_k=12, temperature=0.9)
|
28 |
+
>>> text_out = tokenizer.decode(outputs[0])[prompt_len:]
|
29 |
+
>>> print(text_out)
|
30 |
+
|
31 |
+
" on olemassa joitain keinoja, joilla voit testata tokenisointia. Tässä artikkelissa käydään läpi testilauseiden"
|
32 |
+
```
|