cartesinus commited on
Commit
78c11b1
1 Parent(s): 44106bc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +64 -10
README.md CHANGED
@@ -15,22 +15,76 @@ should probably proofread and complete it, then remove this comment. -->
15
  # iva_mt_wslot-m2m100_418M-0.1.0 en-pl
16
 
17
  This model is a fine-tuned version of [facebook/m2m100_418M](https://huggingface.co/facebook/m2m100_418M) on the [iva_mt_wslot](https://huggingface.co/datasets/cartesinus/iva_mt_wslot) dataset.
18
- It achieves the following results on the evaluation set:
19
- - Loss: 0.0176
 
 
 
 
 
 
 
 
 
 
 
20
  - Bleu: 61.6249
21
- - Gen Len: 21.157
22
 
23
- On training set:
24
- - translated train witout slots in input: 93.8200 Bleu
25
- - translated train with slots in input: 70.5597 Bleu
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- ## Model description
 
 
 
28
 
29
- More information needed
 
 
 
30
 
31
- ## Intended uses & limitations
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- More information needed
34
 
35
  ## Training and evaluation data
36
 
 
15
  # iva_mt_wslot-m2m100_418M-0.1.0 en-pl
16
 
17
  This model is a fine-tuned version of [facebook/m2m100_418M](https://huggingface.co/facebook/m2m100_418M) on the [iva_mt_wslot](https://huggingface.co/datasets/cartesinus/iva_mt_wslot) dataset.
18
+
19
+
20
+ It achieves the following results:
21
+ 1) On the test set (iva_mt):
22
+ - Bleu (plain text): 39.1560
23
+ - Bleu (with slots): 63.8767
24
+ - Baseline m2m100-418M (plain text): TBD
25
+
26
+ 2) WMT20 (en2pl):
27
+ - Bleu (lowercased, tags removed): 15.0863 (for reference WMT20 submission systems in en-pl direction had between 25 and 30 bleu)
28
+ - Baseline m2m100-418M (plain text): TBD
29
+
30
+ 4) On the evaluation set:
31
  - Bleu: 61.6249
 
32
 
33
+ 3) On the training set (to see how it adjusted to train):
34
+ - Bleu (plain text): 70.5597
35
+ - Bleu (with slots): 93.8200
36
+
37
+ Bleu was measured with (sacrebleu)[https://github.com/mjpost/sacrebleu] library.
38
+
39
+ ## Model description, intended uses & limitations
40
+
41
+ Model is biased towards virtual assistant (IVA) sentences in prediction/translation. These sentences are short, most of them are short, imperatives. Both of this facts
42
+ can be observed in above results. WMT results are very low while in-domain test is very high. One thing that needs to be mentioned is that BLEU is not particulary good
43
+ metric to evaluate IVA sentences due to their length and it should be evalued with other metrices (e.g. [GLEU](https://aclanthology.org/P15-2097.pdf)).
44
+
45
+ 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
46
+ can work. If you will translate domains unseen in either of them results might drop significantly to the point where baseline m2m100-418M will be better than this model.
47
+
48
+ This model will generate tags in output even if there is not tag in input sentence. Frequency of this depends on input text. When testing IVA utterances this occurs
49
+ between 3 and 5% of all cases. When WMT20 was translated it happened in % cases (input text was from News domain).
50
+ This is not very severe and can be fixed easily in post-processing (something like `sed 's/<[a-z]>//g'` should be enough in most cases).
51
+
52
+ Translations with slots very often differ from same sentences when slots are removed. This is quite frequent and it happens between 30 and 50% of translated utterances.
53
+ For example there will be a difference between "is it raining in barcelona" and "is it raining in <a>barcelona<a>". In second case model will more likely localize name of
54
+ city to some Polish name (here Lublin, because such city was given in Massive train set). This might be useful if you want to generate more variants.
55
+
56
+ ## How to use
57
+
58
+ First please make sure to install `pip install transformers`. First download model:
59
+
60
+ ```python
61
+ from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
62
+ import torch
63
 
64
+ def translate(input_text, lang):
65
+ input_ids = tokenizer(input_text, return_tensors="pt")
66
+ generated_tokens = model.generate(**input_ids, forced_bos_token_id=tokenizer.get_lang_id(lang))
67
+ return tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
68
 
69
+ model_name = "cartesinus/iva_mt_wslot-m2m100_418M-0.1.0"
70
+ tokenizer = M2M100Tokenizer.from_pretrained(model_name, src_lang="en", tgt_lang="pl")
71
+ model = M2M100ForConditionalGeneration.from_pretrained(model_name)
72
+ ```
73
 
74
+ Then you can translate either plan text like this:
75
+ ```python
76
+ print(translate("set the temperature on my thermostat", "pl"))
77
+ ```
78
+ or you can translate with slot annotations that will be restored in tgt language:
79
+ ```python
80
+ 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>
81
+ ```
82
+ Limitations of translation with slot transfer:
83
+ 1) Annotated words must be placed between semi-xml tags like this "this is <a>example<a>"
84
+ 2) There is no closing tag for example "<\a>" in above example - this is done on purpose to ommit problems with backslash escape
85
+ 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"
86
+ 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
87
 
 
88
 
89
  ## Training and evaluation data
90