Update README.md
Browse files
README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
This is the
|
2 |
|
3 |
Usage:
|
4 |
|
@@ -6,13 +6,13 @@ Usage:
|
|
6 |
from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
|
7 |
from transformers import AlbertTokenizer, AutoTokenizer
|
8 |
|
9 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
10 |
|
11 |
-
# Or use tokenizer = AlbertTokenizer.from_pretrained("
|
12 |
|
13 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("
|
14 |
|
15 |
-
# Or use model = MBartForConditionalGeneration.from_pretrained("
|
16 |
|
17 |
# Some initial mapping
|
18 |
bos_id = tokenizer._convert_token_to_id_with_added_voc("<s>")
|
@@ -20,7 +20,7 @@ eos_id = tokenizer._convert_token_to_id_with_added_voc("</s>")
|
|
20 |
pad_id = tokenizer._convert_token_to_id_with_added_voc("<pad>")
|
21 |
# To get lang_id use any of ['<2as>', '<2bn>', '<2en>', '<2gu>', '<2hi>', '<2kn>', '<2ml>', '<2mr>', '<2or>', '<2pa>', '<2ta>', '<2te>']
|
22 |
|
23 |
-
# First tokenize the input and outputs. The format below is how
|
24 |
inp = tokenizer("I am a boy </s> <2en>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids # tensor([[ 466, 1981, 80, 25573, 64001, 64004]])
|
25 |
|
26 |
out = tokenizer("<2hi> मैं एक लड़का हूँ </s>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids # tensor([[64006, 942, 43, 32720, 8384, 64001]])
|
|
|
1 |
+
This is the IndicBARTSS model. For detailed documentation look here: https://indicnlp.ai4bharat.org/indic-bart/ and https://github.com/AI4Bharat/indic-bart/
|
2 |
|
3 |
Usage:
|
4 |
|
|
|
6 |
from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
|
7 |
from transformers import AlbertTokenizer, AutoTokenizer
|
8 |
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained("ai4bharat/IndicBARTSS", do_lower_case=False, use_fast=False, keep_accents=True)
|
10 |
|
11 |
+
# Or use tokenizer = AlbertTokenizer.from_pretrained("ai4bharat/IndicBARTSS", do_lower_case=False, use_fast=False, keep_accents=True)
|
12 |
|
13 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("ai4bharat/IndicBARTSS")
|
14 |
|
15 |
+
# Or use model = MBartForConditionalGeneration.from_pretrained("ai4bharat/IndicBARTSS")
|
16 |
|
17 |
# Some initial mapping
|
18 |
bos_id = tokenizer._convert_token_to_id_with_added_voc("<s>")
|
|
|
20 |
pad_id = tokenizer._convert_token_to_id_with_added_voc("<pad>")
|
21 |
# To get lang_id use any of ['<2as>', '<2bn>', '<2en>', '<2gu>', '<2hi>', '<2kn>', '<2ml>', '<2mr>', '<2or>', '<2pa>', '<2ta>', '<2te>']
|
22 |
|
23 |
+
# First tokenize the input and outputs. The format below is how IndicBARTSS was trained so the input should be "Sentence </s> <2xx>" where xx is the language code. Similarly, the output should be "<2yy> Sentence </s>".
|
24 |
inp = tokenizer("I am a boy </s> <2en>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids # tensor([[ 466, 1981, 80, 25573, 64001, 64004]])
|
25 |
|
26 |
out = tokenizer("<2hi> मैं एक लड़का हूँ </s>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids # tensor([[64006, 942, 43, 32720, 8384, 64001]])
|