prajdabre commited on
Commit
9e07189
1 Parent(s): 069f104

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -3
README.md CHANGED
@@ -1,3 +1,38 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ This is a many-to-many model for Creole-English, English-Creole and Creole-Creole MT, fine-tuned on top of facebook/mbart-large-50-many-to-many-mmt, with all data.
6
+
7
+ Usage:
8
+
9
+ ```
10
+ from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
11
+ from transformers import MbartTokenizer, AutoTokenizer
12
+
13
+ tokenizer = AutoTokenizer.from_pretrained("n8rob/kreyol-mt-pubtrain", do_lower_case=False, use_fast=False, keep_accents=True)
14
+
15
+ # Or use tokenizer = MbartTokenizer.from_pretrained("n8rob/kreyol-mt-pubtrain", use_fast=False)
16
+
17
+ model = AutoModelForSeq2SeqLM.from_pretrained("n8rob/kreyol-mt-pubtrain")
18
+
19
+ # Or use model = MBartForConditionalGeneration.from_pretrained("n8rob/kreyol-mt-pubtrain")
20
+
21
+ # First tokenize the input and outputs. The format below is how the model was trained so the input should be "Sentence </s> SRCCODE". Similarly, the output should be "TGTCODE Sentence </s>".
22
+ # For Hawaiian Creole to English translation, we need to use language indicator tags: fr_XX and en_XX where fr_XX represents Hawaiian Creole (hwc) and en_XX represents English (eng).
23
+ # For a mapping of the original language and language code (3 character) to mBART-50 compatible language tokens consider the following dictionary:
24
+ # {} ## Add this
25
+ # Note: We mapped languages to their language tokens manually. For example, we used en_XX, fr_XX, es_XX for English, French and Spanish as in the original mBART-50 model. But then we repurposed other tokens for Creoles.
26
+
27
+ # As for what the language codes and their corresponding languages are, please refer to: https://github.com/JHU-CLSP/Kreyol-MT?tab=readme-ov-file#building-machine-translation-for-latin-american-caribbean-and-colonial-african-creole-languages
28
+
29
+ inp = tokenizer('Wen dey wen stretch him out fo whip him real hard , Paul wen tell da captain dat stay dea , "Dis okay in da rules fo da Rome peopo ? fo you fo whip one guy dat get da same rights jalike da Rome peopo ? even one guy dat neva do notting wrong ?" </s> fr_XX', add_special_tokens=False, return_tensors="pt", padding=True).input_ids
30
+
31
+ model.eval() # Set dropouts to zero
32
+
33
+ model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=60, min_length=1, early_stopping=True, pad_token_id=pad_id, bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("en_XX"))
34
+
35
+ decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
36
+
37
+ print(decoded_output)
38
+ ```