Upload 4 files
Browse files- README.md +238 -157
- allegro-title.svg +359 -0
- p4-pol.svg +4 -0
- pivot-data-many2pol.svg +4 -0
README.md
CHANGED
@@ -1,199 +1,280 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
#
|
7 |
|
8 |
-
|
|
|
|
|
9 |
|
|
|
10 |
|
|
|
|
|
|
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
|
|
|
|
|
15 |
|
16 |
-
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
###
|
29 |
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
35 |
|
36 |
-
## Uses
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
|
42 |
-
|
|
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
|
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
## Evaluation
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
|
169 |
-
|
170 |
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
-
|
174 |
|
175 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
|
177 |
-
[More Information Needed]
|
178 |
|
179 |
-
|
180 |
|
181 |
-
|
182 |
|
183 |
-
##
|
184 |
|
185 |
-
|
186 |
|
187 |
-
|
188 |
|
189 |
-
|
190 |
|
191 |
-
|
|
|
192 |
|
193 |
-
## Model Card Authors [optional]
|
194 |
|
195 |
-
|
196 |
|
197 |
-
|
|
|
|
|
198 |
|
199 |
-
|
|
|
|
|
|
1 |
---
|
2 |
+
license: cc-by-4.0
|
3 |
+
language:
|
4 |
+
- cs
|
5 |
+
- pl
|
6 |
+
- sk
|
7 |
+
- sl
|
8 |
library_name: transformers
|
9 |
+
tags:
|
10 |
+
- translation
|
11 |
+
- mt
|
12 |
+
- marian
|
13 |
+
- pytorch
|
14 |
+
- sentence-piece
|
15 |
+
- many2one
|
16 |
+
- multilingual
|
17 |
+
- pivot
|
18 |
+
- allegro
|
19 |
+
- laniqo
|
20 |
---
|
21 |
|
22 |
+
# MultiSlav P4-many2pol
|
23 |
|
24 |
+
<p align="center">
|
25 |
+
<a href="https://ml.allegro.tech/"><img src="allegro-title.svg" alt="MLR @ Allegro.com"></a>
|
26 |
+
</p>
|
27 |
|
28 |
+
## Multilingual Many-to-Polish MT Model
|
29 |
|
30 |
+
___P4-many2pol___ is an Encoder-Decoder vanilla transformer model trained on sentence-level Machine Translation task.
|
31 |
+
Model is supporting translation from 3 languages: Czech, Slovak, and Slovene to Polish.
|
32 |
+
This model is part of the [___MultiSlav___ collection](https://huggingface.co/collections/allegro/multislav-6793d6b6419e5963e759a683). More information will be available soon in our upcoming MultiSlav paper.
|
33 |
|
34 |
+
Experiments were conducted under research project by [Machine Learning Research](https://ml.allegro.tech/) lab for [Allegro.com](https://ml.allegro.tech/).
|
35 |
+
Big thanks to [laniqo.com](laniqo.com) for cooperation in the research.
|
36 |
|
37 |
+
<p align="center">
|
38 |
+
<img src="p4-pol.svg">
|
39 |
+
</p>
|
40 |
|
41 |
+
___P4-many2pol___ - Many-to-Polish model translating from Slavic languages to Polish.
|
42 |
+
This model and [_P4-pol2many_](https://huggingface.co/allegro/P4-pol2many) combine into ___P4-pol___ pivot system translating between _4_ Slavic languages.
|
43 |
+
_P4-pol_ translates all supported slavic languages using Many2One model to Polish bridge sentence
|
44 |
+
and next using the One2Many model from Polish bridge sentence to target Slavic language.
|
45 |
|
46 |
+
### Model description
|
47 |
|
48 |
+
* **Model name:** P4-many2pol
|
49 |
+
* **Source Languages:** Czech, Slovak, Slovene
|
50 |
+
* **Target Language:** Polish
|
51 |
+
* **Model Collection:** [MultiSlav](https://huggingface.co/collections/allegro/multislav-6793d6b6419e5963e759a683)
|
52 |
+
* **Model type:** MarianMTModel Encoder-Decoder
|
53 |
+
* **License:** CC BY 4.0 (commercial use allowed)
|
54 |
+
* **Developed by:** [MLR @ Allegro](https://ml.allegro.tech/) & [Laniqo.com](https://laniqo.com/)
|
55 |
|
56 |
+
### Supported languages
|
57 |
|
58 |
+
To use the model, you must provide the target language for translation.
|
59 |
+
Target language tokens are represented as 3-letter ISO 639-3 language codes embedded in a format >>xxx<<.
|
60 |
+
All accepted directions and their respective tokens are listed below.
|
61 |
+
Each of them was added as a special token to Sentence-Piece tokenizer.
|
62 |
|
63 |
+
| **Source Language** | **First token** |
|
64 |
+
|---------------------|-----------------|
|
65 |
+
| Czech | `>>ces<<` |
|
66 |
+
| Slovak | `>>slk<<` |
|
67 |
+
| Slovene | `>>slv<<` |
|
68 |
|
|
|
69 |
|
70 |
+
## Use case quickstart
|
71 |
|
72 |
+
Example code-snippet to use model. Due to bug the `MarianMTModel` must be used explicitly.
|
73 |
|
74 |
+
```python
|
75 |
+
from transformers import AutoTokenizer, MarianMTModel
|
76 |
|
77 |
+
m2o_model_name = "Allegro/P4-many2pol"
|
78 |
|
79 |
+
m2o_tokenizer = AutoTokenizer.from_pretrained(m2o_model_name)
|
80 |
+
m2o_model = MarianMTModel.from_pretrained(m2o_model_name)
|
81 |
|
82 |
+
text = ">>ces<<" + " " + "Allegro je on-line e-commerce platforma, na které své produkty prodávají střední a malé firmy, stejně jako velké značky."
|
83 |
|
84 |
+
translations = m2o_model.generate(**m2o_tokenizer.batch_encode_plus([text], return_tensors="pt"))
|
85 |
+
bridge_translation = m2o_tokenizer.batch_decode(translations, skip_special_tokens=True, clean_up_tokenization_spaces=True)
|
86 |
+
print(bridge_translation[0])
|
87 |
+
```
|
88 |
+
|
89 |
+
Generated _bridge_ Polish output:
|
90 |
+
> Allegro to internetowa platforma e-commerce, na której swoje produkty sprzedają średnie i małe firmy, a także duże marki.
|
91 |
+
|
92 |
+
To pivot-translate to other languages via _bridge_ Polish sentence, we need One2Many model.
|
93 |
+
One2Many model requires explicit target language token as well:
|
94 |
+
|
95 |
+
```python
|
96 |
+
|
97 |
+
o2m_model_name = "Allegro/P4-pol2many"
|
98 |
+
|
99 |
+
o2m_tokenizer = AutoTokenizer.from_pretrained(o2m_model_name)
|
100 |
+
o2m_model = MarianMTModel.from_pretrained(o2m_model_name)
|
101 |
+
|
102 |
+
texts_to_translate = [
|
103 |
+
">>slk<<" + bridge_translation[0],
|
104 |
+
">>slv<<" + bridge_translation[0]
|
105 |
+
]
|
106 |
+
translation = o2m_model.generate(**o2m_tokenizer.batch_encode_plus(texts_to_translate, return_tensors="pt"))
|
107 |
+
decoded_translations = o2m_tokenizer.batch_decode(translation, skip_special_tokens=True, clean_up_tokenization_spaces=True)
|
108 |
+
|
109 |
+
for trans in decoded_translations:
|
110 |
+
print(trans)
|
111 |
+
```
|
112 |
+
|
113 |
+
|
114 |
+
Generated Czech to Slovak pivot translation via Polish:
|
115 |
+
> Allegro je online platforma elektronického obchodu, na ktorej svoje produkty predávajú stredné a malé podniky, ako aj veľké značky.
|
116 |
+
|
117 |
+
Generated Czech to Slovene pivot translation via Polish:
|
118 |
+
> Allegro je spletna platforma za e-poslovanje, kjer svoje izdelke prodajajo srednje velika in mala podjetja ter velike blagovne znamke.
|
119 |
+
|
120 |
+
## Training
|
121 |
+
|
122 |
+
[SentencePiece](https://github.com/google/sentencepiece) tokenizer has a vocab size 64k in total (16k per language). Tokenizer was trained on randomly sampled part of the training corpus.
|
123 |
+
During the training we used the [MarianNMT](https://marian-nmt.github.io/) framework.
|
124 |
+
Base marian configuration used: [transfromer-big](https://github.com/marian-nmt/marian-dev/blob/master/src/common/aliases.cpp#L113).
|
125 |
+
All training parameters are listed in table below.
|
126 |
+
|
127 |
+
### Training hyperparameters:
|
128 |
+
|
129 |
+
| **Hyperparameter** | **Value** |
|
130 |
+
|----------------------------|------------------------------------------------------------------------------------------------------------|
|
131 |
+
| Total Parameter Size | 242M |
|
132 |
+
| Training Examples | 112M |
|
133 |
+
| Vocab Size | 64k |
|
134 |
+
| Base Parameters | [Marian transfromer-big](https://github.com/marian-nmt/marian-dev/blob/master/src/common/aliases.cpp#L113) |
|
135 |
+
| Number of Encoding Layers | 6 |
|
136 |
+
| Number of Decoding Layers | 6 |
|
137 |
+
| Model Dimension | 1024 |
|
138 |
+
| FF Dimension | 4096 |
|
139 |
+
| Heads | 16 |
|
140 |
+
| Dropout | 0.1 |
|
141 |
+
| Batch Size | mini batch fit to VRAM |
|
142 |
+
| Training Accelerators | 4x A100 40GB |
|
143 |
+
| Max Length | 100 tokens |
|
144 |
+
| Optimizer | Adam |
|
145 |
+
| Warmup steps | 8000 |
|
146 |
+
| Context | Sentence-level MT |
|
147 |
+
| Source Languages Supported | Czech, Slovak, Slovene |
|
148 |
+
| Target Languages Supported | Polish |
|
149 |
+
| Precision | float16 |
|
150 |
+
| Validation Freq | 3000 steps |
|
151 |
+
| Stop Metric | ChrF |
|
152 |
+
| Stop Criterion | 20 Validation steps |
|
153 |
+
|
154 |
+
|
155 |
+
## Training corpora
|
156 |
+
|
157 |
+
<p align="center">
|
158 |
+
<img src="pivot-data-many2pol.svg">
|
159 |
+
</p>
|
160 |
+
|
161 |
+
The main research question was: "How does adding additional, related languages impact the quality of the model?" - we explored it in the Slavic language family.
|
162 |
+
In this model we experimented with expanding data-regime by using data from multiple source languages. We found that additional fluency data clearly improved compared to the bi-directional baseline models.
|
163 |
+
For example in translation from Czech to Polish, this allowed us to expand training data-size from 63M to 112M examples, and from 23M to 112M for Slovene to Polish translation.
|
164 |
+
|
165 |
+
We only used explicitly open-source data to ensure open-source license of our model.
|
166 |
+
Datasets were downloaded via [MT-Data](https://pypi.org/project/mtdata/0.2.10/) library. Number of total examples post filtering and deduplication: __112M__.
|
167 |
+
|
168 |
+
The datasets used:
|
169 |
+
|
170 |
+
| **Corpus** |
|
171 |
+
|----------------------|
|
172 |
+
| paracrawl |
|
173 |
+
| opensubtitles |
|
174 |
+
| multiparacrawl |
|
175 |
+
| dgt |
|
176 |
+
| elrc |
|
177 |
+
| xlent |
|
178 |
+
| wikititles |
|
179 |
+
| wmt |
|
180 |
+
| wikimatrix |
|
181 |
+
| dcep |
|
182 |
+
| ELRC |
|
183 |
+
| tildemodel |
|
184 |
+
| europarl |
|
185 |
+
| eesc |
|
186 |
+
| eubookshop |
|
187 |
+
| emea |
|
188 |
+
| jrc_acquis |
|
189 |
+
| ema |
|
190 |
+
| qed |
|
191 |
+
| elitr_eca |
|
192 |
+
| EU-dcep |
|
193 |
+
| rapid |
|
194 |
+
| ecb |
|
195 |
+
| kde4 |
|
196 |
+
| news_commentary |
|
197 |
+
| kde |
|
198 |
+
| bible_uedin |
|
199 |
+
| europat |
|
200 |
+
| elra |
|
201 |
+
| wikipedia |
|
202 |
+
| wikimedia |
|
203 |
+
| tatoeba |
|
204 |
+
| globalvoices |
|
205 |
+
| euconst |
|
206 |
+
| ubuntu |
|
207 |
+
| php |
|
208 |
+
| ecdc |
|
209 |
+
| eac |
|
210 |
+
| eac_reference |
|
211 |
+
| gnome |
|
212 |
+
| EU-eac |
|
213 |
+
| books |
|
214 |
+
| EU-ecdc |
|
215 |
+
| newsdev |
|
216 |
+
| khresmoi_summary |
|
217 |
+
| czechtourism |
|
218 |
+
| khresmoi_summary_dev |
|
219 |
+
| worldbank |
|
220 |
|
221 |
## Evaluation
|
222 |
|
223 |
+
Evaluation of the models was performed on [Flores200](https://huggingface.co/datasets/facebook/flores) dataset.
|
224 |
+
The table below compares performance of the open-source models and all applicable models from our collection.
|
225 |
+
Metrics BLEU, ChrF2, and Unbabel/wmt22-comet-da.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
|
227 |
+
Translation results on translation from Czech to Polish (Slavic direction to Polish with the __highest__ data-regime):
|
228 |
|
229 |
+
| **Model** | **Comet22** | **BLEU** | **ChrF** | **Model Size** |
|
230 |
+
|-------------------------------------------------------|:------------:|:---------:|:--------:|---------------:|
|
231 |
+
| M2M−100 | 89.0 | 18.3 | 48.0 | 1.2B |
|
232 |
+
| NLLB−200 | 88.9 | 27.5 | 47.3 | 1.3B |
|
233 |
+
| Opus Sla-Sla | 82.8 | 13.6 | 43.5 | 64M |
|
234 |
+
| BiDi-ces-pol (baseline) | 89.4 | 19.2 | 49.2 | 209M |
|
235 |
+
| ___P4-many2pol___ <span style="color:green;">*</span> | 89.6 | __19.3__ | __49.5__ | 242M |
|
236 |
+
| P5-eng <span style="color:red;">◊</span> | 89.0 | 18.5 | 48.7 | 2x 258M |
|
237 |
+
| P5-ces <span style="color:red;">◊</span> | 89.6 | 19.0 | 49.0 | 2x 258M |
|
238 |
+
| MultiSlav-4slav | 89.7 | 18.9 | 49.2 | 242M |
|
239 |
+
| MultiSlav-5lang | __89.8__ | 19.0 | 49.3 | 258M |
|
240 |
|
241 |
+
Translation results on translation from Slovene to Polish (direction to Polish with the __lowest__ data-regime):
|
242 |
|
243 |
+
| **Model** | **Comet22** | **BLEU** | **ChrF** | **Model Size** |
|
244 |
+
|-------------------------------------------------------|:-------------:|:--------:|:----------:|---------------:|
|
245 |
+
| M2M−100 | 88.7 | 17.8 | 47.3 | 1.2B |
|
246 |
+
| NLLB−200 | 88.6 | 17.0 | 46.3 | 1.3B |
|
247 |
+
| Opus Sla-Sla | 80.8 | 12.3 | 41.8 | 64M |
|
248 |
+
| BiDi-pol-slv (baseline) | 88.1 | 17.0 | 47.3 | 209M |
|
249 |
+
| ___P4-many2pol___ <span style="color:green;">*</span> | 88.7 | 17.7 | __48.0__ | 242M |
|
250 |
+
| P5-eng <span style="color:red;">◊</span> | 88.4 | 17.6 | 47.8 | 2x 258M |
|
251 |
+
| P5-ces <span style="color:red;">◊</span> | 87.9 | 16.7 | 46.7 | 2x 258M |
|
252 |
+
| MultiSlav-4slav | 88.9 | 17.8 | __48.0__ | 242M |
|
253 |
+
| MultiSlav-5lang | __89.2__ | __18.0__ | 47.9 | 258M |
|
254 |
|
|
|
255 |
|
256 |
+
<span style="color:green;">*</span> this model; it is Many2One a part of the P4-pol pivot system.
|
257 |
|
258 |
+
<span style="color:red;">◊</span> system of 2 models *Many2XXX* and *XXX2Many*.
|
259 |
|
260 |
+
## Limitations and Biases
|
261 |
|
262 |
+
We did not evaluate inherent bias contained in training datasets. It is advised to validate bias of our models in perspective domain. This might be especially problematic in translation from English to Slavic languages, which require explicitly indicated gender and might hallucinate based on bias present in training data.
|
263 |
|
264 |
+
## License
|
265 |
|
266 |
+
The model is licensed under CC BY 4.0, which allows for commercial use.
|
267 |
|
268 |
+
## Citation
|
269 |
+
TO BE UPDATED SOON 🤗
|
270 |
|
|
|
271 |
|
272 |
+
## Contact Options
|
273 |
|
274 |
+
Authors:
|
275 |
+
- MLR @ Allegro: [Artur Kot](https://linkedin.com/in/arturkot), [Mikołaj Koszowski](https://linkedin.com/in/mkoszowski), [Wojciech Chojnowski](https://linkedin.com/in/wojciech-chojnowski-744702348), [Mieszko Rutkowski](https://linkedin.com/in/mieszko-rutkowski)
|
276 |
+
- Laniqo.com: [Artur Nowakowski](https://linkedin.com/in/artur-nowakowski-mt), [Kamil Guttmann](https://linkedin.com/in/kamil-guttmann), [Mikołaj Pokrywka](https://linkedin.com/in/mikolaj-pokrywka)
|
277 |
|
278 |
+
Please don't hesitate to contact authors if you have any questions or suggestions:
|
279 |
+
- e-mail: artur.kot@allegro.com or mikolaj.koszowski@allegro.com
|
280 |
+
- LinkedIn: [Artur Kot](https://linkedin.com/in/arturkot) or [Mikołaj Koszowski](https://linkedin.com/in/mkoszowski)
|
allegro-title.svg
ADDED
|
p4-pol.svg
ADDED
|
pivot-data-many2pol.svg
ADDED
|