Views
No views yet
Pocket Polyglot Mzansi is a small 50M parameter machine translation model for South African languages. The model is part of an ongoing research project that aims to develop a small (<50M parameters) machine translation model that matches or exceeds the accuracy of NLLB-200-600M on South African languages. The current version of the model is > 90% smaller than NLLB-200-600M, but sacrifices only 6.3% in accuracy in terms of chrF++.Pocket Polyglot Mzansi is a research model. The intended use is deployment on edge devices for offline machine translation. It allows for single sentence translation among six languages.1>>> from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3>>> tokenizer = AutoTokenizer.from_pretrained("stefan7/pocket_polyglot_mzansi_50M_6langs")
4>>> model = AutoModelForSeq2SeqLM.from_pretrained("stefan7/pocket_polyglot_mzansi_50M_6langs")
5
6>>> tokenizer.src_lang = "eng_Latn"
7>>> text = "How was your day?"
8>>> inputs = tokenizer(text, return_tensors="pt")
9
10>>> translated_tokens = model.generate(
11... **inputs, forced_bos_token_id=tokenizer.convert_tokens_to_ids("xho_Latn")
12... )
13>>> tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]
14Wawunjani umhla wakho?| Our 50M model | NLLB-200-600M | % difference | |
|---|---|---|---|
| Number of parameters | 49,260,544 | 615,073,792 | -92.0% |
| Memory footprint in 16-bit (GB) | 0.09 | 1.15 | -91.9% |
| chrF++v | 48.8 | 52.1 | -6.3% |
| spBLEU | 25.1 | 29.5 | -14.7% |
| Source language | Target language | Our 50M model | NLLB-200 600M | Difference |
|---|---|---|---|---|
| isiXhosa | isiZulu | 44.3 | 45.5 | -1.3 |
| isiXhosa | Afrikaans | 43.0 | 46.1 | -3.0 |
| isiXhosa | English | 48.3 | 55.7 | -7.5 |
| isiZulu | isiXhosa | 42.9 | 42.6 | 0.3 |
| isiZulu | Afrikaans | 44.5 | 47.1 | -2.5 |
| isiZulu | English | 49.3 | 57.3 | -8.0 |
| Afrikaans | isiXhosa | 41.6 | 44.3 | -2.8 |
| Afrikaans | isiZulu | 44.9 | 47.6 | -2.7 |
| Afrikaans | English | 65.9 | 73.5 | -7.7 |
| English | isiXhosa | 46.2 | 47.3 | -1.2 |
| English | isiZulu | 49.5 | 51.6 | -2.1 |
| English | Afrikaans | 62.1 | 63.3 | -1.2 |
| English | Sepedi | 48.9 | 49.4 | -0.5 |
| English | Setswana | 45.3 | 47.3 | -2.0 |
| isiZulu | Sepedi | 44.9 | 45.2 | -0.3 |
| isiZulu | Setswana | 43.7 | 44.4 | -0.7 |
| Sepedi | English | 48.1 | 57.1 | -9.0 |
| Sepedi | isiZulu | 43.1 | 45.3 | -2.2 |
| Sepedi | Setswana | 42.2 | 43.6 | -1.4 |
| Setswana | English | 41.4 | 48.5 | -7.2 |
| Setswana | isiZulu | 39.3 | 41.3 | -2.1 |
| Setswana | Sepedi | 40.4 | 41.8 | -1.4 |