valhalla commited on
Commit
6d8496e
1 Parent(s): 2c055e1

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -0
README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: multilingual
3
+ license: mit
4
+ tags:
5
+ - translation
6
+ - wmt21
7
+ ---
8
+
9
+ # WMT 21 En-X
10
+ WMT 21 En-X is a 4.7B multilingual encoder-decoder (seq-to-seq) model trained for one-to-many multilingual translation.
11
+ It was introduced in this [paper](https://arxiv.org/abs/2108.03265) and first released in [this](https://github.com/pytorch/fairseq/tree/main/examples/wmt21) repository.
12
+
13
+ The model can directly translate English text into 7 other languages: Hausa (ha), Icelandic (is), Japanese (ja), Czech (cs), Russian (ru), Chinese (zh), German (de).
14
+
15
+ To translate into a target language, the target language id is forced as the first generated token.
16
+ To force the target language id as the first generated token, pass the `forced_bos_token_id` parameter to the `generate` method.
17
+
18
+ *Note: `M2M100Tokenizer` depends on `sentencepiece`, so make sure to install it before running the example.*
19
+
20
+ To install `sentencepiece` run `pip install sentencepiece`
21
+
22
+ ```python
23
+ from transformers import AutoModelForConditionalGeneration, AutoTokenizer
24
+
25
+ model = AutoModelForConditionalGeneration.from_pretrained("facebook/wmt21-dense-24-wide-en-x")
26
+ tokenizer = AutoTokenizer.from_pretrained("facebook/wmt21-dense-24-wide-en-x")
27
+
28
+ inputs = tokenizer("One model for many languages.", return_tensors="pt")
29
+
30
+ # translate English to German
31
+ generated_tokens = model.generate(**inputs, forced_bos_token_id=tokenizer.get_lang_id("de"))
32
+ tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
33
+ # => "Ein Modell für viele Sprachen."
34
+
35
+ # translate English to Icelandic
36
+ generated_tokens = model.generate(**inputs, forced_bos_token_id=tokenizer.get_lang_id("is"))
37
+ tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
38
+ # => "Ein fyrirmynd fyrir mörg tungumál."
39
+ ```
40
+
41
+ See the [model hub](https://huggingface.co/models?filter=wmt21) to look for more fine-tuned versions.
42
+
43
+
44
+ ## Languages covered
45
+ English (en), Hausa (ha), Icelandic (is), Japanese (ja), Czech (cs), Russian (ru), Chinese (zh), German (de)
46
+
47
+
48
+ ## BibTeX entry and citation info
49
+ ```
50
+ @inproceedings{tran2021facebook
51
+ title={Facebook AI’s WMT21 News Translation Task Submission},
52
+ author={Chau Tran and Shruti Bhosale and James Cross and Philipp Koehn and Sergey Edunov and Angela Fan},
53
+ booktitle={Proc. of WMT},
54
+ year={2021},
55
+ }
56
+ ```