ArturKotAllegro commited on
Commit
629e822
·
verified ·
1 Parent(s): b922be2

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +243 -152
  2. allegro-title.svg +359 -0
  3. p5-eng.svg +4 -0
  4. pivot-data-many2eng.svg +4 -0
README.md CHANGED
@@ -1,199 +1,290 @@
1
  ---
 
 
 
 
 
 
 
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
 
10
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
 
 
 
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
 
 
 
 
 
 
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
 
 
 
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
 
 
 
39
 
40
- ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
 
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
 
55
 
56
- [More Information Needed]
 
57
 
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
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
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
 
 
 
 
 
 
 
 
 
 
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
 
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
 
 
198
 
199
- [More Information Needed]
 
 
 
1
  ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - cs
5
+ - en
6
+ - pl
7
+ - sk
8
+ - sl
9
  library_name: transformers
10
+ tags:
11
+ - translation
12
+ - mt
13
+ - marian
14
+ - pytorch
15
+ - sentence-piece
16
+ - many2one
17
+ - multilingual
18
+ - pivot
19
+ - allegro
20
+ - laniqo
21
  ---
22
 
 
23
 
24
+ # MultiSlav P5-many2eng
25
 
26
+ <p align="center">
27
+ <a href="https://ml.allegro.tech/"><img src="allegro-title.svg" alt="MLR @ Allegro.com"></a>
28
+ </p>
29
 
30
 
31
+ ## Multilingual Many-to-English MT Model
32
 
33
+ ___P5-many2eng___ is an Encoder-Decoder vanilla transformer model trained on sentence-level Machine Translation task.
34
+ Model is supporting translation from 4 languages: Czech, Polish, Slovak, and Slovene to English.
35
+ This model is part of the [___MultiSlav___ collection](https://huggingface.co/collections/allegro/multislav-6793d6b6419e5963e759a683).
36
+ More information will be available soon in our upcoming MultiSlav paper.
37
 
38
+ Experiments were conducted under research project by [Machine Learning Research](https://ml.allegro.tech/) lab for [Allegro.com](https://ml.allegro.tech/).
39
+ Big thanks to [laniqo.com](laniqo.com) for cooperation in the research.
40
 
41
+ <p align="center">
42
+ <img src="p5-eng.svg">
43
+ </p>
44
 
45
+ ___P5-many2eng___ - _5_-language _Many-to-English_ model translating from all applicable languages to English.
46
+ This model and [_P5-eng2many_](https://huggingface.co/allegro/P5-eng2many) combine into ___P5-eng___ pivot system translating between _5_ languages.
47
+ _P5-eng_ translates all supported languages using Many2One model to English bridge sentence
48
+ and next using the One2Many model from English bridge sentence to target language.
 
 
 
49
 
50
+ ### Model description
51
 
52
+ * **Model name:** P5-many2ces
53
+ * **Source Languages:** Czech, Polish, Slovak, Slovene
54
+ * **Target Language:** English
55
+ * **Model Collection:** [MultiSlav](https://huggingface.co/collections/allegro/multislav-6793d6b6419e5963e759a683)
56
+ * **Model type:** MarianMTModel Encoder-Decoder
57
+ * **License:** CC BY 4.0 (commercial use allowed)
58
+ * **Developed by:** [MLR @ Allegro](https://ml.allegro.tech/) & [Laniqo.com](https://laniqo.com/)
59
 
60
+ ### Supported languages
 
 
61
 
62
+ Using model you must specify source language for translation.
63
+ Source language tokens are represented as 3-letter ISO 639-3 language codes embedded in a format >>xxx<<.
64
+ All accepted directions and their respective tokens are listed below.
65
+ Each of them was added as a special token to Sentence-Piece tokenizer.
66
 
67
+ | **Source Language** | **First token** |
68
+ |---------------------|-----------------|
69
+ | Czech | `>>ces<<` |
70
+ | Polish | `>>pol<<` |
71
+ | Slovak | `>>slk<<` |
72
+ | Slovene | `>>slv<<` |
73
 
 
74
 
75
+ ## Use case quickstart
76
 
77
+ Example code-snippet to use model. Due to bug the `MarianMTModel` must be used explicitly.
78
 
79
+ ```python
80
+ from transformers import AutoTokenizer, MarianMTModel
81
 
82
+ m2o_model_name = "Allegro/P5-many2eng"
83
 
84
+ m2o_tokenizer = AutoTokenizer.from_pretrained(m2o_model_name)
85
+ m2o_model = MarianMTModel.from_pretrained(m2o_model_name)
86
 
87
+ text = ">>pol<<" + " " + "Allegro to internetowa platforma e-commerce, na której swoje produkty sprzedają średnie i małe firmy, jak również duże marki."
88
 
89
+ translations = m2o_model.generate(**m2o_tokenizer.batch_encode_plus([text], return_tensors="pt"))
90
+ bridge_translation = m2o_tokenizer.batch_decode(translations, skip_special_tokens=True, clean_up_tokenization_spaces=True)
91
+ print(bridge_translation[0])
92
+ ```
93
 
94
+ Generated _bridge_ English output:
95
+ > Allegro is an online e-commerce platform where medium and small companies as well as large brands sell their products.
96
 
97
+ To pivot-translate to other languages via _bridge_ English sentence, we need One2Many model.
98
+ One2Many model requires explicit target language token as well:
99
+
100
+ ```python
101
+
102
+ o2m_model_name = "Allegro/P5-eng2many"
103
+
104
+ o2m_tokenizer = AutoTokenizer.from_pretrained(o2m_model_name)
105
+ o2m_model = MarianMTModel.from_pretrained(o2m_model_name)
106
+
107
+ texts_to_translate = [
108
+ ">>ces<<" + " " + bridge_translation[0],
109
+ ">>slk<<" + " " + bridge_translation[0],
110
+ ">>slv<<" + " " + bridge_translation[0]
111
+ ]
112
+ translation = o2m_model.generate(**o2m_tokenizer.batch_encode_plus(texts_to_translate, return_tensors="pt"))
113
+ decoded_translations = o2m_tokenizer.batch_decode(translation, skip_special_tokens=True, clean_up_tokenization_spaces=True)
114
+
115
+ for trans in decoded_translations:
116
+ print(trans)
117
+ ```
118
+
119
+ Generated Polish to Czech pivot translation via English:
120
+ > Allegro je on-line e-commerce platforma, kde střední a malé firmy, stejně jako velké značky prodávají své produkty.
121
+
122
+ Generated Polish to Slovak pivot translation via English:
123
+ > Allegro je online e-commerce platforma, kde stredné a malé firmy, ako aj veľké značky predávajú svoje produkty.
124
+
125
+ Generated Polish to Slovene pivot translation via English:
126
+ > Allegro je spletna e-poslovanje platforma, kjer srednje in mala podjetja, kot tudi velike blagovne znamke prodajajo svoje izdelke.
127
+
128
+ ## Training
129
+
130
+ [SentencePiece](https://github.com/google/sentencepiece) tokenizer has a vocab size 80k in total (16k per language). Tokenizer was trained on randomly sampled part of the training corpus.
131
+ During the training we used the [MarianNMT](https://marian-nmt.github.io/) framework.
132
+ Base marian configuration used: [transfromer-big](https://github.com/marian-nmt/marian-dev/blob/master/src/common/aliases.cpp#L113).
133
+ All training parameters are listed in table below.
134
+
135
+ ### Training hyperparameters:
136
+
137
+ | **Hyperparameter** | **Value** |
138
+ |-----------------------------|------------------------------------------------------------------------------------------------------------|
139
+ | Total Parameter Size | 258M |
140
+ | Training Examples | 393M |
141
+ | Vocab Size | 80k |
142
+ | Base Parameters | [Marian transfromer-big](https://github.com/marian-nmt/marian-dev/blob/master/src/common/aliases.cpp#L113) |
143
+ | Number of Encoding Layers | 6 |
144
+ | Number of Decoding Layers | 6 |
145
+ | Model Dimension | 1024 |
146
+ | FF Dimension | 4096 |
147
+ | Heads | 16 |
148
+ | Dropout | 0.1 |
149
+ | Batch Size | mini batch fit to VRAM |
150
+ | Training Accelerators | 4x A100 40GB |
151
+ | Max Length | 100 tokens |
152
+ | Optimizer | Adam |
153
+ | Warmup steps | 8000 |
154
+ | Context | Sentence-level MT |
155
+ | Source Languages Supported | Czech, Polish, Slovak, Slovene |
156
+ | Target Language Supported | English |
157
+ | Precision | float16 |
158
+ | Validation Freq | 3000 steps |
159
+ | Stop Metric | ChrF |
160
+ | Stop Criterion | 20 Validation steps |
161
+
162
+
163
+ ## Training corpora
164
+
165
+ <p align="center">
166
+ <img src="pivot-data-many2eng.svg">
167
+ </p>
168
+
169
+ 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.
170
+ Choosing English model as Bridge Language provides more training examples to model, as English is high-resource data-regime increasing to 393M compared to 269M for [P5-many2ces]().
171
+ However, English has a limited morphology compared to Slavic languages, which may lead to loss of information (like gender for the subject in the sentence).
172
+ Performance results are mixed compared to [P5-many2ces]().
173
+ We only used explicitly open-source data to ensure open-source license of our model.
174
+
175
+ Datasets were downloaded via [MT-Data](https://pypi.org/project/mtdata/0.2.10/) library. Number of total examples post filtering and deduplication: __393M__.
176
+
177
+ The datasets used:
178
+
179
+ | **Corpus** |
180
+ |----------------------|
181
+ | paracrawl |
182
+ | opensubtitles |
183
+ | multiparacrawl |
184
+ | dgt |
185
+ | elrc |
186
+ | xlent |
187
+ | wikititles |
188
+ | wmt |
189
+ | wikimatrix |
190
+ | dcep |
191
+ | ELRC |
192
+ | tildemodel |
193
+ | europarl |
194
+ | eesc |
195
+ | eubookshop |
196
+ | emea |
197
+ | jrc_acquis |
198
+ | ema |
199
+ | qed |
200
+ | elitr_eca |
201
+ | EU-dcep |
202
+ | rapid |
203
+ | ecb |
204
+ | kde4 |
205
+ | news_commentary |
206
+ | kde |
207
+ | bible_uedin |
208
+ | europat |
209
+ | elra |
210
+ | wikipedia |
211
+ | wikimedia |
212
+ | tatoeba |
213
+ | globalvoices |
214
+ | euconst |
215
+ | ubuntu |
216
+ | php |
217
+ | ecdc |
218
+ | eac |
219
+ | eac_reference |
220
+ | gnome |
221
+ | EU-eac |
222
+ | books |
223
+ | EU-ecdc |
224
+ | newsdev |
225
+ | khresmoi_summary |
226
+ | czechtourism |
227
+ | khresmoi_summary_dev |
228
+ | worldbank |
229
 
230
  ## Evaluation
231
 
232
+ Evaluation of the models was performed on [Flores200](https://huggingface.co/datasets/facebook/flores) dataset.
233
+ The table below compares performance of the open-source models and all applicable models from our collection.
234
+ Metrics BLEU, ChrF2, and Unbabel/wmt22-comet-da.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
+ Translation results on translation from Polish to Czech (Slavic direction with the __highest__ data-regime):
237
 
238
+ | **Model** | **Comet22** | **BLEU** | **ChrF** | **Model Size** |
239
+ |------------------------------------------------------------------------------------|:-----------:|:--------:|:--------:|---------------:|
240
+ | M2M−100 | 89.6 | 19.8 | 47.7 | 1.2B |
241
+ | NLLB−200 | 89.4 | 19.2 | 46.7 | 1.3B |
242
+ | Opus Sla-Sla | 82.9 | 14.6 | 42.6 | 64M |
243
+ | BiDi-ces-pol (baseline) | 90.0 | 20.3 | 48.5 | 209M |
244
+ | P4-pol <span style="color:red;">◊</span> | 90.2 | 20.2 | 48.5 | 2x 242M |
245
+ | ___P5-eng___ <span style="color:red;">◊</span> <span style="color:green;">*</span> | 89.0 | 19.9 | 48.3 | 2x 258M |
246
+ | P5-many2ces | 90.3 | 20.2 | 48.6 | 258M |
247
+ | MultiSlav-4slav | 90.2 | 20.6 | 48.7 | 242M |
248
+ | MultiSlav-5lang | __90.4__ | __20.7__ | __48.9__ | 258M |
249
 
250
+ Translation results on translation from Slovene to Czech (direction to Czech with the __lowest__ data-regime):
251
 
252
+ | **Model** | **Comet22** | **BLEU** | **ChrF** | **Model Size** |
253
+ |------------------------------------------------------------------------------------|:-----------:|:--------:|:--------:|---------------:|
254
+ | M2M−100 | 90.3 | 24.3 | 51.6 | 1.2B |
255
+ | NLLB−200 | 90.0 | 22.5 | 49.9 | 1.3B |
256
+ | Opus Sla-Sla | 83.5 | 17.4 | 46.0 | 1.3B |
257
+ | BiDi-ces-slv (baseline) | 90.0 | 24.4 | 52.0 | 209M |
258
+ | P4-pol <span style="color:red;">◊</span> | 89.3 | 22.7 | 50.4 | 2x 242M |
259
+ | ___P5-eng___ <span style="color:red;">◊</span> <span style="color:green;">*</span> | 89.6 | 24.7 | 52.4 | 2x 258M |
260
+ | P5-many2ces | 90.3 | 24.9 | 52.4 | 258M |
261
+ | MultiSlav-4slav | __90.6__ | __25.3__ | __52.7__ | 242M |
262
+ | MultiSlav-5lang | __90.6__ | 25.2 | 52.5 | 258M |
263
 
 
264
 
265
+ <span style="color:green;">*</span> used entire _P5-eng_ pivot system, including One2Many [P5-eng2many]() model.
266
 
267
+ <span style="color:red;">◊</span> system of 2 models *Many2XXX* and *XXX2Many*.
268
 
269
+ ## Limitations and Biases
270
 
271
+ 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.
272
 
273
+ ## License
274
 
275
+ The model is licensed under CC BY 4.0, which allows for commercial use.
276
 
277
+ ## Citation
278
+ TO BE UPDATED SOON 🤗
279
 
 
280
 
 
281
 
282
+ ## Contact Options
283
 
284
+ Authors:
285
+ - 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)
286
+ - 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)
287
 
288
+ Please don't hesitate to contact authors if you have any questions or suggestions:
289
290
+ - LinkedIn: [Artur Kot](https://linkedin.com/in/arturkot) or [Mikołaj Koszowski](https://linkedin.com/in/mkoszowski)
allegro-title.svg ADDED
p5-eng.svg ADDED
pivot-data-many2eng.svg ADDED