Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
inference: false
|
3 |
+
language:
|
4 |
+
- bg
|
5 |
+
license: mit
|
6 |
+
datasets:
|
7 |
+
- oscar
|
8 |
+
- chitanka
|
9 |
+
- wikipedia
|
10 |
+
tags:
|
11 |
+
- torch
|
12 |
+
---
|
13 |
+
|
14 |
+
# ROBERTA-TO-ROBERTA EncoderDecoder with Shared Weights
|
15 |
+
|
16 |
+
This model was intorduced in [this paper](https://arxiv.org/pdf/1907.12461.pdf).
|
17 |
+
|
18 |
+
## Model description
|
19 |
+
|
20 |
+
The training data is private English-Bulgarian parallel data.
|
21 |
+
|
22 |
+
## Intended uses & limitations
|
23 |
+
|
24 |
+
You can use the raw model for translation from English to Bulgarian.
|
25 |
+
|
26 |
+
### How to use
|
27 |
+
|
28 |
+
Here is how to use this model in PyTorch:
|
29 |
+
|
30 |
+
```python
|
31 |
+
>>> from transformers import EncoderDecoderModel, XLMRobertaTokenizer
|
32 |
+
>>>
|
33 |
+
>>> model_id = "rmihaylov/roberta2roberta-shared-nmt-bg"
|
34 |
+
>>> model = EncoderDecoderModel.from_pretrained(model_id)
|
35 |
+
>>> model.encoder.pooler = None
|
36 |
+
>>> tokenizer = XLMRobertaTokenizer.from_pretrained(model_id)
|
37 |
+
>>>
|
38 |
+
>>> text = """
|
39 |
+
Others were photographed ransacking the building, smiling while posing with congressional items such as House Speaker Nancy Pelosi's lectern or at her staffer's desk, or publicly bragged about the crowd's violent and destructive joyride.
|
40 |
+
"""
|
41 |
+
>>>
|
42 |
+
>>> inputs = tokenizer.encode_plus(text, max_length=100, return_tensors='pt', truncation=True)
|
43 |
+
>>>
|
44 |
+
>>> translation = model.generate(**inputs,
|
45 |
+
>>> max_length=100,
|
46 |
+
>>> num_beams=4,
|
47 |
+
>>> do_sample=True,
|
48 |
+
>>> num_return_sequences=1,
|
49 |
+
>>> top_p=0.95,
|
50 |
+
>>> decoder_start_token_id=tokenizer.bos_token_id)
|
51 |
+
|
52 |
+
>>> print([tokenizer.decode(g.tolist(), skip_special_tokens=True) for g in translation])
|
53 |
+
|
54 |
+
['Други бяха заснети да бягат из сградата, усмихвайки се, докато се представят с конгресни предмети, като например лекцията на председателя на парламента Нанси Пелози или на бюрото на нейния служител, или публично се хвалят за насилието и разрушителната радост на тълпата.']
|
55 |
+
```
|