kimmchii commited on
Commit
687acdb
1 Parent(s): ed022d0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -0
README.md CHANGED
@@ -1,3 +1,44 @@
1
  ---
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
  ---
4
+ # SMALL-100 Model
5
+
6
+ SMaLL-100 is a compact and fast massively multilingual machine translation model covering more than 10K language pairs, that achieves competitive results with M2M-100 while being much smaller and faster. It is introduced in [this paper](https://arxiv.org/abs/2210.11621)(accepted to EMNLP2022), and initially released in [this repository](https://github.com/alirezamshi/small100).
7
+
8
+ The model architecture and config are the same as [M2M-100](https://huggingface.co/facebook/m2m100_418M/tree/main) implementation, but the tokenizer is modified to adjust language codes. So, you should load the tokenizer locally from [tokenization_small100.py](https://huggingface.co/alirezamsh/small100/blob/main/tokenization_small100.py) file for the moment.
9
+
10
+ **Demo**: https://huggingface.co/spaces/alirezamsh/small100
11
+
12
+ **Note**: SMALL100Tokenizer requires sentencepiece, so make sure to install it by:
13
+
14
+ ```pip install sentencepiece```
15
+
16
+ - **Supervised Training**
17
+
18
+ SMaLL-100 is a seq-to-seq model for the translation task. The input to the model is ```source:[tgt_lang_code] + src_tokens + [EOS]``` and ```target: tgt_tokens + [EOS]```.
19
+
20
+
21
+ # `small-100-th` is the fine tuned model from SMALL-100
22
+
23
+
24
+ # small-100-th inference
25
+ ```
26
+ from transformers import M2M100ForConditionalGeneration
27
+ from tokenization_small100 import SMALL100Tokenizer
28
+ from huggingface_hub import notebook_login
29
+
30
+ notebook_login()
31
+
32
+ checkpoint = "kimmchii/small-100-th"
33
+ model = M2M100ForConditionalGeneration.from_pretrained(checkpoint)
34
+ tokenizer = SMALL100Tokenizer.from_pretrained(checkpoint)
35
+
36
+ thai_text = "สวัสดี"
37
+
38
+ # translate Thai to English
39
+ tokenizer.tgt_lang = "en"
40
+ encoded_th = tokenizer(thai_text, return_tensors="pt")
41
+ generated_tokens = model.generate(**encoded_th)
42
+ tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
43
+ # => "Hello"
44
+ ```