Update README.md
Browse files
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
license: cc-by-sa-4.0
|
3 |
datasets:
|
4 |
-
-
|
5 |
- jerteh/SrpWiki
|
6 |
- jerteh/SrpELTeC
|
7 |
-
-
|
8 |
language:
|
9 |
- sr
|
10 |
tags:
|
@@ -14,9 +14,155 @@ tags:
|
|
14 |
- BERT
|
15 |
- MaskedLM
|
16 |
---
|
17 |
-
Najveći enkoderski model za srpski jezik.
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
kao i korpus [PDRS 1.0](https://www.clarin.si/repository/xmlui/handle/11356/1752) razvijen od strane Instituta za Srpski jezik SANU.
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-sa-4.0
|
3 |
datasets:
|
4 |
+
- jerteh/cc100-sr-jerteh
|
5 |
- jerteh/SrpWiki
|
6 |
- jerteh/SrpELTeC
|
7 |
+
- srwac
|
8 |
language:
|
9 |
- sr
|
10 |
tags:
|
|
|
14 |
- BERT
|
15 |
- MaskedLM
|
16 |
---
|
|
|
17 |
|
18 |
+
<h4><i class="highlight-container"><b class="highlight">jerteh-355</b></i> —
|
19 |
+
Najveći BERT model specijalno obučen za srpski jezik.</h4>
|
20 |
+
|
21 |
+
<img src="cover.png" style="width:100%">
|
22 |
+
|
23 |
+
<div id="zastava">
|
24 |
+
<div class="grb">
|
25 |
+
<img src="https://www.ai.gov.rs/img/logo_60x120-2.png" style="position:relative; left:30px; z-index:10; height:85px">
|
26 |
+
</div>
|
27 |
+
<table width=100% style="border:0px">
|
28 |
+
<tr style=
|
29 |
+
"background-color:#C6363C;width:100%;border:0px;height:30px"><td></td></tr>
|
30 |
+
<tr style="background-color:#0C4076;width:100%;border:0px;height:30px"><td></td></tr>
|
31 |
+
<tr style="background-color:#ffffff;width:100%;border:0px;height:30px"><td></td></tr>
|
32 |
+
</table>
|
33 |
+
</div>
|
34 |
+
|
35 |
+
Vektorizuje reči, ili dopunjava nedostajuće reči u tekstu.\
|
36 |
+
Jednaka podrška unosa i na ćirilici i na latinici!
|
37 |
+
|
38 |
+
Pored navedenih, model je obučavan i na ostalim korpusima [Društva za jezičke resurse i tehnologije](https://jerteh.rs),
|
39 |
+
uključujući korpuse savremenog srpskog jezika: SrpKor2013 i SrpKor2021,
|
40 |
kao i korpus [PDRS 1.0](https://www.clarin.si/repository/xmlui/handle/11356/1752) razvijen od strane Instituta za Srpski jezik SANU.
|
41 |
|
42 |
+
|
43 |
+
## Upotreba
|
44 |
+
|
45 |
+
```python
|
46 |
+
>>> from transformers import pipeline
|
47 |
+
>>> generator = pipeline('fill-mask', model='jerteh/jerteh-355')
|
48 |
+
>>> unmasker("Kada bi čovek znao gde će pasti on bi<mask>.")
|
49 |
+
```
|
50 |
+
|
51 |
+
```
|
52 |
+
[{'score': 0.16073498129844666, 'token': 11379, 'token_str': ' pao', 'sequence': 'Kada bi čovek znao gde će pasti on bi pao.'},
|
53 |
+
{'score': 0.14656540751457214, 'token': 10799, 'token_str': ' umro', 'sequence': 'Kada bi čovek znao gde će pasti on bi umro.'},
|
54 |
+
{'score': 0.11459200084209442, 'token': 7797, 'token_str': ' otišao', 'sequence': 'Kada bi čovek znao gde će pasti on bi otišao.'},
|
55 |
+
{'score': 0.061787571758031845, 'token': 7103, 'token_str': ' znao', 'sequence': 'Kada bi čovek znao gde će pasti on bi znao.'},
|
56 |
+
{'score': 0.0532902330160141, 'token': 998, 'token_str': ' rekao', 'sequence': 'Kada bi čovek znao gde će pasti on bi rekao.'}]
|
57 |
+
```
|
58 |
+
|
59 |
+
```python
|
60 |
+
>>> from transformers import AutoTokenizer, AutoModelForMaskedLM
|
61 |
+
>>> from torch import LongTensor, no_grad
|
62 |
+
>>> from scipy import spatial
|
63 |
+
>>> tokenizer = AutoTokenizer.from_pretrained('jerteh/jerteh-355')
|
64 |
+
>>> model = AutoModelForMaskedLM.from_pretrained('jerteh/jerteh-355', output_hidden_states=True)
|
65 |
+
>>> x = " pas"
|
66 |
+
>>> y = " mačka"
|
67 |
+
>>> z = " svemir"
|
68 |
+
>>> tensor_x = LongTensor(tokenizer.encode(x, add_special_tokens=False)).unsqueeze(0)
|
69 |
+
>>> tensor_y = LongTensor(tokenizer.encode(y, add_special_tokens=False)).unsqueeze(0)
|
70 |
+
>>> tensor_z = LongTensor(tokenizer.encode(z, add_special_tokens=False)).unsqueeze(0)
|
71 |
+
>>> model.eval()
|
72 |
+
>>> with no_grad():
|
73 |
+
>>> vektor_x = model(input_ids=tensor_x).hidden_states[-1].squeeze()
|
74 |
+
>>> vektor_y = model(input_ids=tensor_y).hidden_states[-1].squeeze()
|
75 |
+
>>> vektor_z = model(input_ids=tensor_z).hidden_states[-1].squeeze()
|
76 |
+
>>> print(spatial.distance.cosine(vektor_x, vektor_y))
|
77 |
+
>>> print(spatial.distance.cosine(vektor_x, vektor_z))
|
78 |
+
```
|
79 |
+
|
80 |
+
```
|
81 |
+
0.09954947233200073
|
82 |
+
0.21845555305480957
|
83 |
+
```
|
84 |
+
|
85 |
+
<h4>U slučaju potrebe za bržim modelom, pogledajte <a href="https://huggingface.co/jerteh/jerteh-125" class="highlight-container">
|
86 |
+
<b class="highlight">jerteh-125</b></a> — mali BERT model za srpski jezik.</h4>
|
87 |
+
|
88 |
+
<h4>U slučaju potrebe za generativnim modelom, pogledajte <a href="https://huggingface.co/jerteh/gpt2-orao" class="highlight-container">
|
89 |
+
<b class="highlight">gpt2-orao</b></a> i <a href="https://huggingface.co/jerteh/gpt2-vrabac" class="highlight-container">
|
90 |
+
<b class="highlight">gpt2-vrabac</b></a></h4>
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
<div class="inline-flex flex-col" style="line-height: 1.5;">
|
95 |
+
<div style="text-align: center; margin-top: 3px; font-size: 16px; font-weight: 800">Autor</div>
|
96 |
+
<a href="https://huggingface.co/procesaur">
|
97 |
+
<div class="flex">
|
98 |
+
<div
|
99 |
+
style="display:DISPLAY_1; margin-left: auto; margin-right: auto; width: 92px; height:92px; border-radius: 50%;
|
100 |
+
background-size: cover; background-image: url('https://cdn-uploads.huggingface.co/production/uploads/1673534533167-63bc254fb8c61b8aa496a39b.jpeg?w=200&h=200&f=face')">
|
101 |
+
</div>
|
102 |
+
</div>
|
103 |
+
</a>
|
104 |
+
<div style="text-align: center; font-size: 16px; font-weight: 800">Mihailo Škorić</div>
|
105 |
+
<div>
|
106 |
+
<a href="https://huggingface.co/procesaur">
|
107 |
+
<div style="text-align: center; font-size: 14px;">@procesaur</div>
|
108 |
+
</a>
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
|
112 |
+
|
113 |
+
<style>
|
114 |
+
|
115 |
+
.highlight-container, .highlight {
|
116 |
+
position: relative;
|
117 |
+
text-decoration:none
|
118 |
+
}
|
119 |
+
|
120 |
+
.highlight-container {
|
121 |
+
display: inline-block;
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
.highlight{
|
126 |
+
color:white;
|
127 |
+
text-transform:uppercase;
|
128 |
+
font-size: 16pt;
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
.highlight-container{
|
133 |
+
padding:5px 10px
|
134 |
+
}
|
135 |
+
|
136 |
+
.highlight-container:before {
|
137 |
+
content: " ";
|
138 |
+
display: block;
|
139 |
+
height: 100%;
|
140 |
+
width: 100%;
|
141 |
+
margin-left: 0px;
|
142 |
+
margin-right: 0px;
|
143 |
+
position: absolute;
|
144 |
+
background: #e80909;
|
145 |
+
transform: rotate(2deg);
|
146 |
+
top: -1px;
|
147 |
+
left: -1px;
|
148 |
+
border-radius: 20% 25% 20% 24%;
|
149 |
+
padding: 10px 18px 18px 10px;
|
150 |
+
}
|
151 |
+
|
152 |
+
div.grb, #zastava>table {
|
153 |
+
position:absolute;
|
154 |
+
top:0px;
|
155 |
+
left: 0px;
|
156 |
+
margin:0px
|
157 |
+
}
|
158 |
+
|
159 |
+
div.grb>img, #zastava>table{
|
160 |
+
margin:0px
|
161 |
+
}
|
162 |
+
|
163 |
+
#zastava {
|
164 |
+
position: relative;
|
165 |
+
margin-bottom:120px
|
166 |
+
}
|
167 |
+
|
168 |
+
</style>
|