macedonizer
commited on
Commit
•
9b76d3f
1
Parent(s):
a48dbbe
Update README.md
Browse files
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
language:
|
3 |
- gr
|
4 |
-
thumbnail: https://huggingface.co/macedonizer/
|
5 |
license: apache-2.0
|
6 |
datasets:
|
7 |
- wiki-gr
|
@@ -15,14 +15,14 @@ and first released at [this page](https://openai.com/blog/better-language-models
|
|
15 |
|
16 |
## Model description
|
17 |
mk-gpt2 is a transformers model pretrained on a very large corpus of Macedonian data in a self-supervised fashion. This
|
18 |
-
means it was pretrained on the raw texts only, with no humans
|
19 |
of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely,
|
20 |
it was trained to guess the next word in sentences.
|
21 |
-
More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence,
|
22 |
-
shifted one token (word or piece of word) to the right. The model uses internally a mask-mechanism to make sure the
|
23 |
predictions for the token `i` only uses the inputs from `1` to `i` but not the future tokens.
|
24 |
This way, the model learns an inner representation of the Macedonian language that can then be used to extract features
|
25 |
-
useful for downstream tasks. The model is best at what it was pretrained for however, which is generating texts from a
|
26 |
prompt.
|
27 |
|
28 |
### How to use
|
@@ -31,8 +31,7 @@ Here is how to use this model to get the features of a given text in PyTorch:
|
|
31 |
import random
|
32 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
33 |
|
34 |
-
tokenizer = AutoTokenizer.from_pretrained('macedonizer/gr-gpt2')
|
35 |
-
nmodel = AutoModelWithLMHead.from_pretrained('macedonizer/gr-gpt2')
|
36 |
|
37 |
input_text = 'Η Αθήνα είναι'
|
38 |
|
@@ -49,16 +48,17 @@ if len(input_text) == 0: \
|
|
49 |
else: \
|
50 |
encoded_input = tokenizer(input_text, return_tensors="pt") \
|
51 |
output = model.generate( \
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
)
|
60 |
|
61 |
-
decoded_output = []
|
62 |
-
|
|
|
63 |
|
64 |
print(decoded_output)
|
|
|
1 |
---
|
2 |
language:
|
3 |
- gr
|
4 |
+
thumbnail: https://huggingface.co/macedonizer/gr-roberta-base/lets-talk-about-nlp-gr.jpg
|
5 |
license: apache-2.0
|
6 |
datasets:
|
7 |
- wiki-gr
|
|
|
15 |
|
16 |
## Model description
|
17 |
mk-gpt2 is a transformers model pretrained on a very large corpus of Macedonian data in a self-supervised fashion. This
|
18 |
+
means it was pretrained on the raw texts only, with no humans labeling them in any way (which is why it can use lots
|
19 |
of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely,
|
20 |
it was trained to guess the next word in sentences.
|
21 |
+
More precisely, inputs are sequences of the continuous text of a certain length and the targets are the same sequence,
|
22 |
+
shifted one token (word or piece of a word) to the right. The model uses internally a mask-mechanism to make sure the
|
23 |
predictions for the token `i` only uses the inputs from `1` to `i` but not the future tokens.
|
24 |
This way, the model learns an inner representation of the Macedonian language that can then be used to extract features
|
25 |
+
useful for downstream tasks. The model is best at what it was pretrained for, however, which is generating texts from a
|
26 |
prompt.
|
27 |
|
28 |
### How to use
|
|
|
31 |
import random
|
32 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
33 |
|
34 |
+
tokenizer = AutoTokenizer.from_pretrained('macedonizer/gr-gpt2') \\nnmodel = AutoModelWithLMHead.from_pretrained('macedonizer/gr-gpt2')
|
|
|
35 |
|
36 |
input_text = 'Η Αθήνα είναι'
|
37 |
|
|
|
48 |
else: \
|
49 |
encoded_input = tokenizer(input_text, return_tensors="pt") \
|
50 |
output = model.generate( \
|
51 |
+
**encoded_input, \
|
52 |
+
bos_token_id=random.randint(1, 50000), \
|
53 |
+
do_sample=True, \
|
54 |
+
top_k=50, \
|
55 |
+
max_length=1024, \
|
56 |
+
top_p=0.95, \
|
57 |
+
num_return_sequences=1, \
|
58 |
+
)
|
59 |
|
60 |
+
decoded_output = [] \
|
61 |
+
for sample in output: \
|
62 |
+
decoded_output.append(tokenizer.decode(sample, skip_special_tokens=True))
|
63 |
|
64 |
print(decoded_output)
|