julien-c HF staff commited on
Commit
892ae30
1 Parent(s): 68edfb3

Migrate model card from transformers-repo

Browse files

Read announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/ashwani-tanwar/Gujarati-XLM-R-Base/README.md

Files changed (1) hide show
  1. README.md +45 -0
README.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: gu
3
+ ---
4
+
5
+ # Gujarati-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 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.
9
+
10
+ ## Dataset
11
+ 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.
12
+
13
+ ## Preprocessing and Training Procedure
14
+ Please visit [this link](https://github.com/ashwanitanwar/nmt-transfer-learning-xlm-r#6-finetuning-xlm-r) for the detailed procedure.
15
+
16
+ ## Usage
17
+ - This model can be used for further finetuning for different NLP tasks using the Gujarati language.
18
+ - It can be used to generate contextualised word representations for the Gujarati words.
19
+ - It can be used for domain adaptation.
20
+ - It can be used to predict the missing words from the Gujarati sentences.
21
+
22
+ ## Demo
23
+ ### Using the model to predict missing words
24
+ ```
25
+ from transformers import pipeline
26
+ unmasker = pipeline('fill-mask', model='ashwani-tanwar/Gujarati-XLM-R-Base')
27
+ pred_word = unmasker("અમદાવાદ એ ગુજરાતનું એક <mask> છે.")
28
+ print(pred_word)
29
+ ```
30
+ ```
31
+ [{'sequence': '<s> અમદાવાદ એ ગુજરાતનું એક શહેર છે.</s>', 'score': 0.9463568329811096, 'token': 85227, 'token_str': '▁શહેર'},
32
+ {'sequence': '<s> અમદાવાદ એ ગુજરાતનું એક ગામ છે.</s>', 'score': 0.013311690650880337, 'token': 66346, 'token_str': '▁ગામ'},
33
+ {'sequence': '<s> અમદાવાદ એ ગુજરાતનું એકનગર છે.</s>', 'score': 0.012945962138473988, 'token': 69702, 'token_str': 'નગર'},
34
+ {'sequence': '<s> અમદાવાદ એ ગુજરાતનું એક સ્થળ છે.</s>', 'score': 0.0045941537246108055, 'token': 135436, 'token_str': '▁સ્થળ'},
35
+ {'sequence': '<s> અમદાવાદ એ ગુજરાતનું એક મહત્વ છે.</s>', 'score': 0.00402021361514926, 'token': 126763, 'token_str': '▁મહત્વ'}]
36
+ ```
37
+ ### Using the model to generate contextualised word representations
38
+ ```
39
+ from transformers import AutoTokenizer, AutoModel
40
+ tokenizer = AutoTokenizer.from_pretrained("ashwani-tanwar/Gujarati-XLM-R-Base")
41
+ model = AutoModel.from_pretrained("ashwani-tanwar/Gujarati-XLM-R-Base")
42
+ sentence = "અમદાવાદ એ ગુજરાતનું એક શહેર છે."
43
+ encoded_sentence = tokenizer(sentence, return_tensors='pt')
44
+ context_word_rep = model(**encoded_sentence)
45
+ ```