cartesinus commited on
Commit
d26a119
1 Parent(s): f364a26

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -25
README.md CHANGED
@@ -1,50 +1,113 @@
1
  ---
2
  license: mit
3
  tags:
4
- - generated_from_trainer
 
 
 
 
5
  metrics:
6
  - bleu
7
  model-index:
8
- - name: iva_mt_wslot-m2m100_1.2B-0.1.0
9
  results: []
 
 
 
 
 
 
 
10
  ---
11
 
12
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
13
  should probably proofread and complete it, then remove this comment. -->
14
 
15
- # iva_mt_wslot-m2m100_1.2B-0.1.0
16
 
17
- This model is a fine-tuned version of [facebook/m2m100_1.2B](https://huggingface.co/facebook/m2m100_1.2B) on the None dataset.
18
- It achieves the following results on the evaluation set:
19
- - Loss: 0.3082
20
- - Bleu: 62.4604
21
- - Gen Len: 21.2847
22
 
23
- ## Model description
 
 
 
24
 
25
- More information needed
 
26
 
27
- ## Intended uses & limitations
 
 
28
 
29
- More information needed
 
 
30
 
31
- ## Training and evaluation data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- More information needed
34
 
35
- ## Training procedure
36
 
37
- ### Training hyperparameters
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- The following hyperparameters were used during training:
40
- - learning_rate: 2e-05
41
- - train_batch_size: 4
42
- - eval_batch_size: 4
43
- - seed: 42
44
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
45
- - lr_scheduler_type: linear
46
- - num_epochs: 10
47
- - mixed_precision_training: Native AMP
 
 
48
 
49
  ### Training results
50
 
 
1
  ---
2
  license: mit
3
  tags:
4
+ - machine translation
5
+ - iva
6
+ - virtual assistants
7
+ - natural-language-understanding
8
+ - nlu
9
  metrics:
10
  - bleu
11
  model-index:
12
+ - name: iva_mt_wslot-m2m100_1.2B-en-pl
13
  results: []
14
+ datasets:
15
+ - cartesinus/iva_mt_wslot
16
+ language:
17
+ - pl
18
+ - en
19
+ co2_eq_emissions:
20
+ emissions: 0.68
21
  ---
22
 
23
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
24
  should probably proofread and complete it, then remove this comment. -->
25
 
26
+ # iva_mt_wslot-m2m100_1.2B-en-pl (v0.1.0)
27
 
28
+ This model is a fine-tuned version of [facebook/m2m100_1.2B](https://huggingface.co/facebook/m2m100_1.2B) on the
29
+ [iva_mt_wslot](https://huggingface.co/datasets/cartesinus/iva_mt_wslot) dataset. There is also smaller version of this model here:
30
+ [cartesinus/iva_mt_wslot-m2m100_418M-en-pl](https://huggingface.co/cartesinus/iva_mt_wslot-m2m100_418M-0.1.0). This model (1.2B) achieves the following results:
 
 
31
 
32
+ 1) On the test set (iva_mt):
33
+ - BLEU (plain text): **(result in preparation)**
34
+ - BLEU (with slots): **(result in preparation)**
35
+ - F1 score: (in preparation)
36
 
37
+ For reference BLEU for baseline m2m100-418M (plain text) was 21.9468 and for m2m100-1.2B was **(result in preparation)**. Second result (BLEU with slots) is when tags
38
+ are treated as "normal" words in sentence. Therefore that result might be a bit misleading. Please refer to plain text results if you are not sure how to interpret them.
39
 
40
+ 2) WMT20 (en2pl):
41
+ - BLEU (lowercased, tags removed): **(result in preparation)**
42
+ - BLEU for baseline m2m100-1.2B (plain text): **(result in preparation)**
43
 
44
+ For reference WMT20 submission systems in en-pl direction had between 25 and 30 BLEU
45
+
46
+ 3) BLEU on the evaluation set (same as in below table 'Training results'): **62.4604**
47
 
48
+ 4) On the training set (to see how it adjusted to train):
49
+ - BLEU (plain text): **(result in preparation)**
50
+ - BLEU (with slots): **(result in preparation)**
51
+
52
+ BLEU was measured with [sacreBLEU](https://github.com/mjpost/sacrebleu) library.
53
+
54
+ ## Model description, intended uses & limitations
55
+
56
+ Model is biased towards virtual assistant (IVA) sentences in prediction/translation. These sentences are short, imperatives with a lot of name entities (slots) and
57
+ particular vocabulary (for example settings name). It can be observed in above results where WMT results are very low while in-domain test is very high.
58
+
59
+ This model will most probably force IVA translations on your text. As long as sentences that you are translating are more or less similar to massive and leyzer domains it
60
+ will be ok. If you will translate out-of-domain sentenences (such as for example News, Medical) that are not very similar then results will drop significantly.
61
+
62
+ One last thing that needs to be mentioned is that BLEU is not particulary good metric to evaluate IVA sentences due to their length and it should be evalued with other
63
+ metrices (e.g. [GLEU](https://aclanthology.org/P15-2097.pdf)).
64
 
65
+ ## How to use
66
 
67
+ First please make sure to install `pip install transformers`. First download model:
68
 
69
+ ```python
70
+ from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
71
+ import torch
72
+
73
+ def translate(input_text, lang):
74
+ input_ids = tokenizer(input_text, return_tensors="pt")
75
+ generated_tokens = model.generate(**input_ids, forced_bos_token_id=tokenizer.get_lang_id(lang))
76
+ return tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
77
+
78
+ model_name = "cartesinus/iva_mt_wslot-m2m100_1.2B-en-pl"
79
+ tokenizer = M2M100Tokenizer.from_pretrained(model_name, src_lang="en", tgt_lang="pl")
80
+ model = M2M100ForConditionalGeneration.from_pretrained(model_name)
81
+ ```
82
+
83
+ Then you can translate either plan text like this:
84
+ ```python
85
+ print(translate("set the temperature on my thermostat", "pl"))
86
+ ```
87
+ or you can translate with slot annotations that will be restored in tgt language:
88
+ ```python
89
+ print(translate("wake me up at <a>nine am<a> on <b>friday<b>", "pl")) #translation: obudź mnie o <a>piątej rano<a> <b>w tym tygodniu<b>
90
+ ```
91
+ Limitations of translation with slot transfer:
92
+ 1) Annotated words must be placed between semi-xml tags like this "this is \<a\>example\<a\>"
93
+ 2) There is no closing tag for example "\<\a\>" in above example - this is done on purpose to ommit problems with backslash escape
94
+ 3) If sentence consists of more than one slot then simply use next alphabet letter. For example "this is \<a\>example\<a\> with more than \<b\>one\<b\> slot"
95
+ 4) Please do not add space before first or last annotated word because this particular model was trained this way and it most probably will lower it's results
96
+
97
+
98
+ ## Training and evaluation data
99
 
100
+ ## Dataset Composition (en-pl)
101
+ | Corpus | Train | Dev | Test |
102
+ |----------------------------------------------------------------------|--------|-------|-------|
103
+ | [Massive 1.1](https://huggingface.co/datasets/AmazonScience/massive) | 11514 | 2033 | 2974 |
104
+ | [Leyzer 0.2.0](https://github.com/cartesinus/leyzer/tree/0.2.0) | 3974 | 701 | 1380 |
105
+ | [OpenSubtitles from OPUS](https://opus.nlpl.eu/OpenSubtitles-v1.php) | 2329 | 411 | 500 |
106
+ | [KDE from OPUS](https://opus.nlpl.eu/KDE4.php) | 1154 | 241 | 241 |
107
+ | [CCMatrix from Opus](https://opus.nlpl.eu/CCMatrix.php) | 1096 | 232 | 237 |
108
+ | [Ubuntu from OPUS](https://opus.nlpl.eu/Ubuntu.php) | 281 | 60 | 59 |
109
+ | [Gnome from OPUS](https://opus.nlpl.eu/GNOME.php) | 14 | 3 | 3 |
110
+ | *total* | 20362 | 3681 | 5394 |
111
 
112
  ### Training results
113