ashwani-tanwar commited on
Commit
7ccc8fe
1 Parent(s): 45bdc33

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -0
README.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: gu
3
+ ---
4
+
5
+ # Gujarati-in-Devanagari-XLM-R-Base
6
+
7
+
8
+ This model is finetuned over [XLM-RoBERTa](https://huggingface.co/xlm-roberta-base) (XLM-R) using its base variant with the Gujarati language using the [OSCAR](https://oscar-corpus.com/) monolingual dataset. We converted the Gujarati script to the Devanagari using [Indic-NLP](https://github.com/anoopkunchukuttan/indic_nlp_library) library. For example, the sentence 'અમદાવાદ એ ગુજરાતનું એક શહેર છે.' was converted to 'अमदावाद ए गुजरातनुं एक शहेर छे.'. This helped to get better contextualised representations for some words as the XLM-R was pre-trained with several languages written in Devanagari script such as Hindi, Marathi, Sanskrit, and so on.
9
+
10
+ We used the same masked language modelling (MLM) objective which was used for pretraining the XLM-R. As it is built over the pretrained XLM-R, we leveraged *Transfer Learning* by exploiting the knowledge from its parent model.
11
+
12
+ ## Dataset
13
+ OSCAR corpus contains several diverse datasets for different languages. We followed the work of [CamemBERT](https://www.aclweb.org/anthology/2020.acl-main.645/) who reported better performance with this diverse dataset as compared to the other large homogenous datasets.
14
+
15
+ ## Preprocessing and Training Procedure
16
+ Please visit [this link](https://github.com/ashwanitanwar/nmt-transfer-learning-xlm-r#6-finetuning-xlm-r) for the detailed procedure.
17
+
18
+ ## Usage
19
+ - This model can be used for further finetuning for different NLP tasks using the Gujarati language.
20
+ - It can be used to generate contextualised word representations for the Gujarati words.
21
+ - It can be used for domain adaptation.
22
+ - It can be used to predict the missing words from the Gujarati sentences.
23
+
24
+ ## Demo
25
+ ### Using the model to predict missing words
26
+ ```
27
+ from transformers import pipeline
28
+ unmasker = pipeline('fill-mask', model='ashwani-tanwar/Gujarati-in-Devanagari-XLM-R-Base')
29
+ pred_word = unmasker("अमदावाद ए गुजरातनुं एक <mask> छे.")
30
+ print(pred_word)
31
+ ```
32
+ ```
33
+ [{'sequence': '<s> अमदावाद ए गुजरातनुं एक नगर छे.</s>', 'score': 0.24843722581863403, 'token': 18576, 'token_str': '▁नगर'},
34
+ {'sequence': '<s> अमदावाद ए गुजरातनुं एक महानगर छे.</s>', 'score': 0.21455222368240356, 'token': 122519, 'token_str': '▁महानगर'},
35
+ {'sequence': '<s> अमदावाद ए गुजरातनुं एक राज्य छे.</s>', 'score': 0.16832049190998077, 'token': 10665, 'token_str': '▁राज्य'},
36
+ {'sequence': '<s> अमदावाद ए गुजरातनुं एक जिल्ला छे.</s>', 'score': 0.06764694303274155, 'token': 20396, 'token_str': '▁जिल्ला'},
37
+ {'sequence': '<s> अमदावाद ए गुजरातनुं एक शहर छे.</s>', 'score': 0.05364946648478508, 'token': 22770, 'token_str': '▁शहर'}]
38
+ ```
39
+ ### Using the model to generate contextualised word representations
40
+ ```
41
+ from transformers import AutoTokenizer, AutoModel
42
+ tokenizer = AutoTokenizer.from_pretrained("ashwani-tanwar/Gujarati-in-Devanagari-XLM-R-Base")
43
+ model = AutoModel.from_pretrained("ashwani-tanwar/Gujarati-in-Devanagari-XLM-R-Base")
44
+ sentence = "अमदावाद ए गुजरातनुं एक शहेर छे."
45
+ encoded_sentence = tokenizer(sentence, return_tensors='pt')
46
+ context_word_rep = model(**encoded_sentence)
47
+ ```