macedonizer
commited on
Commit
•
d54eeb7
1
Parent(s):
53faf04
Create README.md
Browse files
README.md
CHANGED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MK-RoBERTa base model
|
2 |
+
Pretrained model on Macedonia language using a masked language modeling (MLM) objective. It was introduced in this paper and first released in this repository. This model is case-sensitive: it makes a difference between скопје and Скопје.
|
3 |
+
|
4 |
+
Model description
|
5 |
+
RoBERTa is a transformers model pretrained on a large corpus of мацед data in a self-supervised fashion. This means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic process to generate inputs and labels from those texts.
|
6 |
+
|
7 |
+
More precisely, it was pretrained with the Masked language modeling (MLM) objective. Taking a sentence, the model randomly masks 15% of the words in the input then run the entire masked sentence through the model and has to predict the masked words. This is different from traditional recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the sentence.
|
8 |
+
|
9 |
+
This way, the model learns an inner representation of the English language that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard classifier using the features produced by the BERT model as inputs.
|
10 |
+
|
11 |
+
Intended uses & limitations
|
12 |
+
You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task. See the model hub to look for fine-tuned versions on a task that interests you.
|
13 |
+
|
14 |
+
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked) to make decisions, such as sequence classification, token classification or question answering. For tasks such as text generation you should look at model like GPT2.
|
15 |
+
|
16 |
+
How to use
|
17 |
+
You can use this model directly with a pipeline for masked language modeling:
|
18 |
+
|
19 |
+
>>> from transformers import pipeline
|
20 |
+
>>> unmasker = pipeline('fill-mask', model='macedonizer/mk-roberta-base')
|
21 |
+
>>> unmasker("Скопје е <mask> град на Македонија.")
|
22 |
+
|
23 |
+
[{'sequence': 'Скопје е главен град на Македонија.',
|
24 |
+
'score': 0.5900368094444275,
|
25 |
+
'token': 2782,
|
26 |
+
'token_str': ' главен'},
|
27 |
+
{'sequence': 'Скопје е главниот град на Македонија.',
|
28 |
+
'score': 0.1789761781692505,
|
29 |
+
'token': 3177,
|
30 |
+
'token_str': ' главниот'},
|
31 |
+
{'sequence': 'Скопје е административен град на Македонија.',
|
32 |
+
'score': 0.01679774932563305,
|
33 |
+
'token': 9563,
|
34 |
+
'token_str': ' административен'},
|
35 |
+
{'sequence': 'Скопје е мал град на Македонија.',
|
36 |
+
'score': 0.016263898462057114,
|
37 |
+
'token': 2473,
|
38 |
+
'token_str': ' мал'},
|
39 |
+
{'sequence': 'Скопје е најголемиот град на Македонија.',
|
40 |
+
'score': 0.01312252413481474,
|
41 |
+
'token': 4271,
|
42 |
+
'token_str': ' најголемиот'}]
|
43 |
+
|
44 |
+
Here is how to use this model to get the features of a given text in PyTorch:
|
45 |
+
|
46 |
+
from transformers import RobertaTokenizer, RobertaModel
|
47 |
+
tokenizer = RobertaTokenizer.from_pretrained('macedonizer/mk-roberta-base')
|
48 |
+
model = RobertaModel.from_pretrained('macedonizer/mk-roberta-base')
|
49 |
+
text = "Replace me by any text you'd like."
|
50 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
51 |
+
output = model(**encoded_input)
|