Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 24 |
+
|
| 25 |
---
|
| 26 |
+
|
| 27 |
+
# MultiIndicSentenceSummarizationSS
|
| 28 |
+
|
| 29 |
+
This repository contains the [IndicBARTSS](https://huggingface.co/ai4bharat/IndicBARTSS) checkpoint finetuned on the 11 languages of [IndicSentenceSummarization](https://huggingface.co/datasets/ai4bharat/IndicSentenceSummarization) dataset. For finetuning details,
|
| 30 |
+
see the [paper](https://arxiv.org/abs/2203.05437).
|
| 31 |
+
<ul>
|
| 32 |
+
<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>
|
| 33 |
+
<li >The model is much smaller than the mBART and mT5(-base) models, so less computationally expensive for decoding. </li>
|
| 34 |
+
<li> Trained on large Indic language corpora (5.53 million sentences). </li>
|
| 35 |
+
<li> Unlike <a href="https://huggingface.co/ai4bharat/MultiIndicSentenceSummarization">MultiIndicSentenceSummarization</a> each language is written in its own script, so you do not need to perform any script mapping to/from Devanagari. </li>
|
| 36 |
+
</ul>
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
## Using this model in `transformers`
|
| 41 |
+
|
| 42 |
+
```
|
| 43 |
+
from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
|
| 44 |
+
from transformers import AlbertTokenizer, AutoTokenizer
|
| 45 |
+
tokenizer = AutoTokenizer.from_pretrained("ai4bharat/MultiIndicSentenceSummarizationSS", do_lower_case=False, use_fast=False, keep_accents=True)
|
| 46 |
+
# Or use tokenizer = AlbertTokenizer.from_pretrained("ai4bharat/MultiIndicSentenceSummarizationSS", do_lower_case=False, use_fast=False, keep_accents=True)
|
| 47 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("ai4bharat/MultiIndicSentenceSummarizationSS")
|
| 48 |
+
# Or use model = MBartForConditionalGeneration.from_pretrained("ai4bharat/MultiIndicSentenceSummarizationSS")
|
| 49 |
+
|
| 50 |
+
# Some initial mapping
|
| 51 |
+
bos_id = tokenizer._convert_token_to_id_with_added_voc("<s>")
|
| 52 |
+
eos_id = tokenizer._convert_token_to_id_with_added_voc("</s>")
|
| 53 |
+
pad_id = tokenizer._convert_token_to_id_with_added_voc("<pad>")
|
| 54 |
+
|
| 55 |
+
# To get lang_id use any of ['<2as>', '<2bn>', '<2en>', '<2gu>', '<2hi>', '<2kn>', '<2ml>', '<2mr>', '<2or>', '<2pa>', '<2ta>', '<2te>']
|
| 56 |
+
# 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>".
|
| 57 |
+
inp = tokenizer("जम्मू एवं कश्मीर के अनंतनाग जिले में शनिवार को सुरक्षाबलों के साथ मुठभेड़ में दो आतंकवादियों को मार गिराया गया। </s> <2hi>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
|
| 58 |
+
|
| 59 |
+
# For generation. Pardon the messiness. Note the decoder_start_token_id.
|
| 60 |
+
|
| 61 |
+
model_output=model.generate(inp, use_cache=True,no_repeat_ngram_size=3, num_beams=5, length_penalty=0.8, max_length=20, 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("<2hi>"))
|
| 62 |
+
|
| 63 |
+
# Decode to get output strings
|
| 64 |
+
decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
|
| 65 |
+
print(decoded_output) # अनंतनाग में सुरक्षाबलों के साथ मुठभेड़ में दो आतंकवादी ढेर
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Benchmarks
|
| 69 |
+
|
| 70 |
+
Scores on the `IndicSentenceSummarization` test sets are as follows:
|
| 71 |
+
|
| 72 |
+
Language | Rouge-1 / Rouge-2 / Rouge-L
|
| 73 |
+
---------|----------------------------
|
| 74 |
+
as | 63.56 / 49.90 / 62.57
|
| 75 |
+
bn | 52.52 / 36.15 / 50.60
|
| 76 |
+
gu | 47.69 / 29.77 / 45.61
|
| 77 |
+
hi | 50.43 / 28.13 / 45.15
|
| 78 |
+
kn | 77.06 / 69.36 / 76.33
|
| 79 |
+
ml | 65.00 / 51.99 / 63.76
|
| 80 |
+
mr | 47.05 / 25.97 / 45.52
|
| 81 |
+
or | 50.96 / 30.32 / 49.23
|
| 82 |
+
pa | 54.95 / 36.26 / 51.26
|
| 83 |
+
ta | 58.52 / 38.36 / 56.49
|
| 84 |
+
te | 53.75 / 35.17 / 52.66
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
## Citation
|
| 89 |
+
|
| 90 |
+
If you use this model, please cite the following paper:
|
| 91 |
+
```
|
| 92 |
+
@inproceedings{Kumar2022IndicNLGSM,
|
| 93 |
+
title={IndicNLG Suite: Multilingual Datasets for Diverse NLG Tasks in Indic Languages},
|
| 94 |
+
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},
|
| 95 |
+
year={2022},
|
| 96 |
+
url = "https://arxiv.org/abs/2203.05437"
|
| 97 |
+
}
|
| 98 |
+
```
|