Views
No views yet
pip install transformers. First download model:1from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
2import torch
3
4def translate(input_text, lang):
5 input_ids = tokenizer(input_text, return_tensors="pt")
6 generated_tokens = model.generate(**input_ids, forced_bos_token_id=tokenizer.get_lang_id(lang))
7 return tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
8
9model_name = "cartesinus/iva_mt_wslot-m2m100_418M-0.1.0-en-de"
10tokenizer = M2M100Tokenizer.from_pretrained(model_name, src_lang="en", tgt_lang="de")
11model = M2M100ForConditionalGeneration.from_pretrained(model_name)print(translate("set the temperature on my thermostat", "de"))print(translate("wake me up at <a>nine am<a> on <b>friday<b>", "de"))| Training Loss | Epoch | Step | Validation Loss | Bleu | Gen Len |
|---|---|---|---|---|---|
| 0.0183 | 1.0 | 1884 | 0.0144 | 63.5045 | 20.2994 |
| 0.0119 | 2.0 | 3768 | 0.0127 | 66.0473 | 20.5423 |
| 0.0083 | 3.0 | 5652 | 0.0123 | 65.5139 | 20.5409 |
| 0.0065 | 4.0 | 7536 | 0.0124 | 66.0731 | 20.6114 |
| 0.0048 | 5.0 | 9420 | 0.0122 | 66.2454 | 20.5906 |
| 0.0038 | 6.0 | 11304 | 0.0124 | 66.7412 | 20.6263 |
| 0.0031 | 7.0 | 13188 | 0.0126 | 66.5548 | 20.6835 |
@article{Sowanski2023SlotLI,
title={Slot Lost in Translation? Not Anymore: A Machine Translation Model for Virtual Assistants with Type-Independent Slot Transfer},
author={Marcin Sowanski and Artur Janicki},
journal={2023 30th International Conference on Systems, Signals and Image Processing (IWSSIP)},
year={2023},
pages={1-5}
}