himani commited on
Commit
30c55cb
·
1 Parent(s): 99a3d30

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +103 -1
README.md CHANGED
@@ -1,3 +1,105 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ tags:
3
+ - sentence-summarization
4
+ - multilingual
5
+ - nlp
6
+ - indicnlp
7
+ datasets:
8
+ - ai4bharat/IndicSentenceSummarization
9
+ language:
10
+ - as
11
+ - bn
12
+ - gu
13
+ - hi
14
+ - kn
15
+ - ml
16
+ - mr
17
+ - or
18
+ - pa
19
+ - ta
20
+ - te
21
+ license:
22
+ - mit
23
+ widget:
24
+ - जम्मू एवं कश्मीर के अनंतनाग जिले में शनिवार को सुरक्षाबलों के साथ मुठभेड़ में दो आतंकवादियों को मार गिराया गया। </s> <2hi>
25
+
26
+
27
+
28
  ---
29
+
30
+ # MultiIndicSentenceSummarization
31
+
32
+ This repository contains the [IndicBART](https://huggingface.co/ai4bharat/IndicBART) checkpoint finetuned on the 11 languages of [IndicSentenceSummarization](https://huggingface.co/datasets/ai4bharat/IndicSentenceSummarization) dataset. For finetuning details,
33
+ see the [paper](https://arxiv.org/abs/2203.05437).
34
+ <ul>
35
+ <li >Supported languages: Assamese, Bengali, Gujarati, Hindi, Marathi, Odiya, Punjabi, Kannada, Malayalam, Tamil, and Telugu. Not all of these languages are supported by mBART50 and mT5. </li>
36
+ <li >The model is much smaller than the mBART and mT5(-base) models, so less computationally expensive for decoding. </li>
37
+ <li> Trained on large Indic language corpora (431K sentences). </li>
38
+ <li> All languages, have been represented in Devanagari script to encourage transfer learning among the related languages. </li>
39
+ </ul>
40
+
41
+
42
+
43
+ ## Using this model in `transformers`
44
+
45
+ ```
46
+ from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
47
+ from transformers import AlbertTokenizer, AutoTokenizer
48
+ tokenizer = AutoTokenizer.from_pretrained("ai4bharat/MultiIndicSentenceSummarization", do_lower_case=False, use_fast=False, keep_accents=True)
49
+ # Or use tokenizer = AlbertTokenizer.from_pretrained("ai4bharat/MultiIndicSentenceSummarization", do_lower_case=False, use_fast=False, keep_accents=True)
50
+ model = AutoModelForSeq2SeqLM.from_pretrained("ai4bharat/MultiIndicSentenceSummarization")
51
+ # Or use model = MBartForConditionalGeneration.from_pretrained("ai4bharat/MultiIndicSentenceSummarization")
52
+
53
+ # Some initial mapping
54
+ bos_id = tokenizer._convert_token_to_id_with_added_voc("<s>")
55
+ eos_id = tokenizer._convert_token_to_id_with_added_voc("</s>")
56
+ pad_id = tokenizer._convert_token_to_id_with_added_voc("<pad>")
57
+
58
+ # To get lang_id use any of ['<2as>', '<2bn>', '<2en>', '<2gu>', '<2hi>', '<2kn>', '<2ml>', '<2mr>', '<2or>', '<2pa>', '<2ta>', '<2te>']
59
+ # First tokenize the input. The format below is how IndicBART was trained so the input should be "Sentence </s> <2xx>" where xx is the language code. Similarly, the output should be "<2yy> Sentence </s>".
60
+ inp = tokenizer("जम्मू एवं कश्मीर के अनंतनाग जिले में शनिवार को सुरक्षाबलों के साथ मुठभेड़ में दो आतंकवादियों को मार गिराया गया। </s> <2hi>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
61
+
62
+ # For generation. Pardon the messiness. Note the decoder_start_token_id.
63
+
64
+ model_output=model.generate(inp, use_cache=True,no_repeat_ngram_size=3, num_beams=5, length_penalty=0.8, 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("<2hi>"))
65
+
66
+ # Decode to get output strings
67
+ decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
68
+ print(decoded_output) # जम्मू एवं कश्मीरः अनंतनाग में सुरक्षाबलों के साथ मुठभेड़ में दो आतंकवादी ढेर
69
+
70
+ # Note that if your output language is not Hindi or Marathi, you should convert its script from Devanagari to the desired language using the Indic NLP Library.
71
+
72
+ ```
73
+ # Note:
74
+ If you wish to use any language written in a non-Devanagari script, then you should first convert it to Devanagari using the <a href="https://github.com/anoopkunchukuttan/indic_nlp_library">Indic NLP Library</a>. After you get the output, you should convert it back into the original script.
75
+
76
+ ## Benchmarks
77
+
78
+ Scores on the `IndicSentenceSummarization` test sets are as follows:
79
+
80
+ Language | Rouge-1 / Rouge-2 / Rouge-L
81
+ ---------|----------------------------
82
+ as | 46.77 / 59.29 / 71.17
83
+ bn | 34.91 / 49.29 / 53.97
84
+ gu | 29.97 / 45.92 / 47.46
85
+ hi | 28.11 / 45.34 / 49.29
86
+ kn | 70.03 / 77.32 / 83.37
87
+ ml | 54.42 / 66.42 / 66.45
88
+ mr | 26.98 / 46.50 / 45.75
89
+ or | 23.66 / 43.65 / 45.93
90
+ pa | 37.20 / 52.22 / 54.12
91
+ ta | 38.97 / 56.83 / 57.85
92
+ te | 35.28 / 53.44 / 55.33
93
+
94
+
95
+ ## Citation
96
+
97
+ If you use this model, please cite the following paper:
98
+ ```
99
+ @inproceedings{Kumar2022IndicNLGSM,
100
+ title={IndicNLG Suite: Multilingual Datasets for Diverse NLG Tasks in Indic Languages},
101
+ author={Aman Kumar and Himani Shrotriya and Prachi Sahu and Raj Dabre and Ratish Puduppully and Anoop Kunchukuttan and Amogh Mishra and Mitesh M. Khapra and Pratyush Kumar},
102
+ year={2022},
103
+ url = "https://arxiv.org/abs/2203.05437"
104
+ }
105
+ ```