CoolFace
Modelpublic

cartesinus/iva_mt_wslot-m2m100_1.2B-en-pl

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes21downloads
Model Card

<!-- This model card has been generated automatically according to the information the Trainer had access to. You should probably proofread and complete it, then remove this comment. -->

ivamtwslot-m2m100_1.2B-en-pl (v0.1.0)

This model is a fine-tuned version of facebook/m2m100_1.2B on the iva_mt_wslot dataset. There is also smaller version of this model here: cartesinus/iva_mt_wslot-m2m100_418M-en-pl. This model (1.2B) achieves the following results:

1) On the test set (iva_mt):

  • —BLEU (plain text): (result in preparation)
  • —BLEU (with slots): (result in preparation)
  • —F1 score: (in preparation)

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 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.

2) WMT20 (en2pl):

  • —BLEU (lowercased, tags removed): (result in preparation)
  • —BLEU for baseline m2m100-1.2B (plain text): (result in preparation)

For reference WMT20 submission systems in en-pl direction had between 25 and 30 BLEU

3) BLEU on the evaluation set (same as in below table 'Training results'): 62.4604

4) On the training set (to see how it adjusted to train):

  • —BLEU (plain text): (result in preparation)
  • —BLEU (with slots): (result in preparation)

BLEU was measured with sacreBLEU library.

Model description, intended uses & limitations

Model is biased towards virtual assistant (IVA) sentences in prediction/translation. These sentences are short, imperatives with a lot of name entities (slots) and 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.

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 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.

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 metrices (e.g. GLEU).

How to use

First please make sure to install pip install transformers. First download model:

python
from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
import torch

def translate(input_text, lang):
    input_ids = tokenizer(input_text, return_tensors="pt")
    generated_tokens = model.generate(**input_ids, forced_bos_token_id=tokenizer.get_lang_id(lang))
    return tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)

model_name = "cartesinus/iva_mt_wslot-m2m100_1.2B-en-pl"
tokenizer = M2M100Tokenizer.from_pretrained(model_name, src_lang="en", tgt_lang="pl")
model = M2M100ForConditionalGeneration.from_pretrained(model_name)

Then you can translate either plan text like this:

python
print(translate("set the temperature on my thermostat", "pl"))

or you can translate with slot annotations that will be restored in tgt language:

python
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>

Limitations of translation with slot transfer: 1) Annotated words must be placed between semi-xml tags like this "this is \<a\>example\<a\>" 2) There is no closing tag for example "\<\a\>" in above example - this is done on purpose to ommit problems with backslash escape 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" 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

Training and evaluation data

Dataset Composition (en-pl)

CorpusTrainDevTest
Massive 1.11151420332974
Leyzer 0.2.039747011380
OpenSubtitles from OPUS2329411500
KDE from OPUS1154241241
CCMatrix from Opus1096232237
Ubuntu from OPUS2816059
Gnome from OPUS1433
total2036236815394

Training results

Training LossEpochStepValidation LossBleuGen Len
0.27441.050910.255558.511921.0728
0.18292.0101820.247559.736421.0769
0.11243.0152730.249961.355221.06
0.07834.0203640.259761.661821.2402
0.04965.0254550.269862.194221.2901
0.03186.0305460.279861.906821.3399
0.02047.0356370.289361.775321.3102
0.01388.0407280.297962.392521.3238
0.0099.0458190.303462.494221.2516
0.005810.0509100.308262.460421.2847

Framework versions

  • —Transformers 4.26.1
  • —Pytorch 1.13.1+cu116
  • —Datasets 2.10.1
  • —Tokenizers 0.13.2