elmadany commited on
Commit
aa9e369
·
verified ·
1 Parent(s): bd1724d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +170 -0
README.md ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - aa
4
+ - af
5
+ - am
6
+ - ak
7
+ - bm
8
+ - ff
9
+ - fon
10
+ - ha
11
+ - ig
12
+ - ki
13
+ - lg
14
+ - ln
15
+ - mg
16
+ - nr
17
+ - om
18
+ - rn
19
+ - run
20
+ - sw
21
+ - sn
22
+ - tn
23
+ - ti
24
+ - ve
25
+ - wo
26
+ - xh
27
+ - yo
28
+ - zu
29
+ pipeline_tag: text-generation
30
+ tags:
31
+ - UBC
32
+ - African
33
+ - pytorch
34
+ - Chaeetah
35
+ - DLNLP
36
+ extra_gated_fields:
37
+ First Name: text
38
+ Last Name: text
39
+ Country: country
40
+ Affiliation: text
41
+ Job title:
42
+ type: select
43
+ options:
44
+ - Student
45
+ - Research Graduate
46
+ - AI researcher
47
+ - AI developer/engineer
48
+ - Reporter
49
+ - Other
50
+ I agree to use this model for non-commercial use ONLY: checkbox
51
+ I agree to cite the Cheetah paper: checkbox
52
+ geo: ip_location
53
+ By clicking Submit below I accept the terms of the license: checkbox
54
+ extra_gated_button_content: Submit
55
+ ---
56
+
57
+ <div style='text-align: justify;'>
58
+
59
+ This is the repository accompanying our ACL 2024 paper [Toucan: Many-to-Many Translation for 150 African Language Pairs](https://arxiv.org/abs/2407.04796).
60
+ We address a notable gap in Natural Language Processing (NLP) by introducing a collection of resources designed to improve Machine Translation (MT) for low-resource languages, with a specific focus on African languages. First, We introduce two language models (LMs), Cheetah-1.2B and Cheetah-3.7B, with 1.2 billion and 3.7 billion parameters respectively. Next, we finetune the aforementioned models to create Toucan, an Afrocentric machine translation model designed to support 156 African language pairs. To evaluate Toucan, we carefully develop an extensive machine translation benchmark, dubbed AfroLingu-MT, tailored for evaluating machine translation. Toucan significantly outperforms other models, showcasing its remarkable performance on MT for African languages. Finally, we train a new model, spBLEU_1K, to enhance translation evaluation metrics, covering 1K languages, including 614 African languages. This work aims to advance the field of NLP, fostering cross-cultural understanding and knowledge exchange, particularly in regions with limited language resources such as Africa.
61
+
62
+ </div>
63
+
64
+ ## Models
65
+
66
+ <div style='text-align: justify;'>
67
+
68
+ To effectively train a MT language model for African languages, it is crucial to start with a powerful, Afrocentric pretrained language model. For this purpose, we select Cheetah (Adebara et al.,
69
+ 2024), a recently introduced SoTA model with extensive coverage encompassing 517 African languages. One limitation of Cheetah, however, is that it is available only in a base architecture, featuring
70
+ 580M parameters. Given our objective to develop a large-scale language model for machine translation capabale of serving 156 directions, this base model does not fully meet our requirements. To address this limitation, we embark on training larger and more expansive Afrocentric sequence-to-sequence models. We focus on two sizes: one model with 1.2B parameters and another with 3.7B parameters. We refer to the new models “Cheetah-1.2B” and “Cheetah-3.7B”, respectively, to reflect their enhanced capabilities and parameter scale. These models represent a significant advancement in our efforts to improve machine
71
+ translation for African languages, offering greater capacities in handling the rich linguistic nuances of African languages. Cheetah Pertaining. To train the new Cheetah models, we utilize the same pre-training dataset employed in training the original Cheetah-base model (Adebara et al., 2024). This strategic choice ensures consistency in the foundational data across models, enabling the advanced Cheetah-1.2B and Cheetah-3.7B versions to build upon the rich linguistic diversity captured in the original dataset. We refer to (Adebara et al., 2024) for more information about the pretraining data of Cheetah models. We employ a learning rate of 0.01, a batch size of 1, 024 sequences, and a maximum sequence length of 1, 024. Each model undergoes pretraining for 1 million steps. The training process is conducted on Google Cloud TPU with 128 cores (v3 − 128) provided by the TensorFlow Research Cloud (TFRC). We provide additional details on pretraining in Section B in the Appendix.
72
+
73
+ </div>
74
+
75
+ - Please refer to [**supported-languages**]("https://github.com/UBC-NLP/Cheetah/blob/main/supported-languages.txt")
76
+ - More details about Cheetah's pretraning data, visit Cheetah's GitHub [**Cheetah paper GitHub**]("https://github.com/UBC-NLP/Cheetah")
77
+ - More details about Toucan's pretraning data, visit Toucan's GitHub [**Toucan paper GitHub**]("https://github.com/UBC-NLP/Toucan")
78
+
79
+
80
+ | **Cheetah Models** | **Link** |
81
+ |---------|:------------------:|
82
+ | 🔥**Cheetah-base**🔥| [https://huggingface.co/UBC-NLP/cheetah-base](https://huggingface.co/UBC-NLP/cheetah-base)
83
+ | 🔥**Cheetah-1.2B**🔥| [https://huggingface.co/UBC-NLP/cheetah-1.2B](https://huggingface.co/UBC-NLP/cheetah-1.2B)
84
+ | 🔥**Cheetah-3.7B**🔥| TBA
85
+
86
+
87
+ | **Tocan Models** | **Link** |
88
+ |---------|:------------------:|
89
+ | 🔥**Toucan-base**🔥| [https://huggingface.co/UBC-NLP/toucan-base](https://huggingface.co/UBC-NLP/toucan-base)
90
+ | 🔥**Toucan-1.2B**🔥| [https://huggingface.co/UBC-NLP/toucan-1.2B](https://huggingface.co/UBC-NLP/toucan-1.2B)
91
+ | 🔥**Toucan-3.7B**🔥| TBA
92
+
93
+ # 3. How to use Cheetah-1.2B model
94
+
95
+ Below is an example for using **Cheetah-1.2B** predict masked tokens.
96
+ ``` bash
97
+ from transformers import T5Tokenizer, AutoModelForSeq2SeqLM
98
+
99
+ tokenizer = T5Tokenizer.from_pretrained("UBC-NLP/cheetah-1.2B")
100
+ model = AutoModelForSeq2SeqLM.from_pretrained("UBC-NLP/cheetah-1.2B")
101
+
102
+ yor_prompt="ìròyìn kan nípa owó ìjọba <extra_id_0> kan"
103
+
104
+ input_ids = tokenizer(yor_prompt, return_tensors="pt").input_ids
105
+ outputs = model.generate(input_ids)
106
+ print("Cheetah-1.2B - Tokenized input:", tokenizer.tokenize(yor_prompt))
107
+ print("Cheetah-1.2B - Decoded output:", tokenizer.decode(outputs[0], skip_special_tokens=True))
108
+
109
+ ```
110
+ Output:
111
+ ```bash
112
+ Cheetah-1.2B - Tokenized input: ['▁ìròyìn', '▁kan', '▁nípa', '▁owó', '▁ìjọba', '<extra_id_0>', '▁kan']
113
+ Cheetah-1.2B - Decoded output: Nàìjíríà
114
+ ```
115
+
116
+ # 3. How to use Toucan model
117
+
118
+ Below is an example for translating using **Toucan-base**.
119
+ ``` bash
120
+ from transformers import AutoTokenizer, MT5ForConditionalGeneration
121
+ import torch
122
+ tokenizer = AutoTokenizer.from_pretrained("UBC-NLP/toucan-base")
123
+ model = MT5ForConditionalGeneration.from_pretrained("UBC-NLP/toucan-base", torch_dtype=torch.float16, device_map="auto")
124
+ model.eval()
125
+
126
+ #Translate from Enlglish to Zulu
127
+ text="zul: Clear all items from the recent documents list"
128
+ input_ids = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True).to("cuda:0")
129
+ with torch.no_grad():
130
+ generated_ids = model.generate(**input_ids, num_beams=5, max_new_tokens=len(text), do_sample=True, temperature=0.6, top_p=0.9)
131
+ print(tokenizer.batch_decode(generated_ids, skip_special_tokens=True, skip_prompt=True)[0])
132
+
133
+ ```
134
+ Output:
135
+ ```bash
136
+ Vala zonke izinto kusuka kwihlu lamadokhumende elidlule
137
+ ```
138
+
139
+
140
+
141
+ ## Citation
142
+ If you use the pre-trained model (Cheetah-1.2B) for your scientific publication, or if you find the resources in this repository useful, please cite our papers as follows (to be updated):
143
+
144
+ **Toucan's Paper**
145
+ ```
146
+ @misc{elmadany2024toucan,
147
+ title={Toucan: Many-to-Many Translation for 150 African Language Pairs},
148
+ author={AbdelRahim Elmadany and Ife Adebara and Muhammad Abdul-Mageed},
149
+ year={2024},
150
+ eprint={2407.04796},
151
+ archivePrefix={arXiv},
152
+ primaryClass={cs.CL},
153
+ url={https://arxiv.org/abs/2407.04796},
154
+ }
155
+ ```
156
+
157
+ **Cheetah's Paper**
158
+ ```
159
+ @misc{adebara2024cheetah,
160
+ title={Cheetah: Natural Language Generation for 517 African Languages},
161
+ author={Ife Adebara and AbdelRahim Elmadany and Muhammad Abdul-Mageed},
162
+ year={2024},
163
+ eprint={2401.01053},
164
+ archivePrefix={arXiv},
165
+ primaryClass={cs.CL}
166
+ }
167
+ ```
168
+
169
+ ## Acknowledgments
170
+ We gratefully acknowledges support from Canada Research Chairs (CRC), the Natural Sciences and Engineering Research Council of Canada (NSERC; RGPIN-2018-04267), the Social Sciences and Humanities Research Council of Canada (SSHRC; 435-2018-0576; 895-2020-1004; 895-2021-1008), Canadian Foundation for Innovation (CFI; 37771), [Digital Research Alliance of Canada](https://alliancecan.ca), [UBC ARC-Sockeye](https://arc.ubc.ca/ubc-arc-sockeye), Advanced Micro Devices, Inc. (AMD), and Google. Any opinions, conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of CRC, NSERC, SSHRC, CFI, the Alliance, AMD, Google, or UBC ARC-Sockeye.