cointegrated
commited on
Commit
•
e143da0
1
Parent(s):
b4eed35
Update README.md
Browse files
README.md
CHANGED
@@ -5,7 +5,25 @@ tags: []
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
|
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
+
This is a model for trainable transliteration from Latin (English but not only) to Russian Cyrillic
|
9 |
+
|
10 |
+
How to use:
|
11 |
+
|
12 |
+
```
|
13 |
+
import torch
|
14 |
+
from transformers import BertForMaskedLM, AutoTokenizer
|
15 |
+
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained("cointegrated/bert-char-ctc-en-ru-translit-v0", trust_remote_code=True)
|
17 |
+
model = BertForMaskedLM.from_pretrained("cointegrated/bert-char-ctc-en-ru-translit-v0")
|
18 |
+
|
19 |
+
text = 'Hello world! My name is David Dale, and yours is Schwarzenegger?'
|
20 |
+
|
21 |
+
with torch.inference_mode():
|
22 |
+
batch = tokenizer(text, return_tensors='pt', spaces=1, padding=True).to(model.device)
|
23 |
+
logits = torch.log_softmax(model(**batch).logits, axis=-1)
|
24 |
+
print(tokenizer.decode(logits[0].argmax(-1), skip_special_tokens=True))
|
25 |
+
# хэло Уорлд май нэйм из дэвид дэйл энд ёрз из скУорзэнэгжэр
|
26 |
+
```
|
27 |
|
28 |
|
29 |
|