abhik1505040 commited on
Commit
5e8e929
1 Parent(s): f77f9fb

Initial commit

Browse files
README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - bn
4
+ licenses:
5
+ - cc-by-nc-sa-4.0
6
+ ---
7
+
8
+ # BanglaBERT
9
+
10
+ This repository contains the pretrained discriminator checkpoint of the model **BanglaBERT**. This is an [ELECTRA](https://openreview.net/pdf?id=r1xMH1BtvB) discriminator model pretrained with the Replaced Token Detection (RTD) objective. Finetuned models using this checkpoint achieve state-of-the-art results on many of the NLP tasks in bengali.
11
+
12
+ For finetuning on different downstream tasks such as `Sentiment classification`, `Named Entity Recognition`, `Natural Language Inference` etc., refer to the scripts in the official [repository](https://https://github.com/csebuetnlp/banglabert).
13
+
14
+ ## Using this model as a discriminator in `transformers` (tested on 4.11.0.dev0)
15
+
16
+ ```python
17
+ from transformers import ElectraForPreTraining, ElectraTokenizerFast
18
+ from normalizer import normalize # pip install git+https://github.com/abhik1505040/normalizer
19
+ import torch
20
+
21
+ model = ElectraForPreTraining.from_pretrained("banglabert")
22
+ tokenizer = ElectraTokenizerFast.from_pretrained("banglabert")
23
+
24
+ original_sentence = "আমি কৃতজ্ঞ কারণ আপনি আমার জন্য অনেক কিছু করেছেন।"
25
+ fake_sentence = "আমি হতাশ কারণ আপনি আমার জন্য অনেক কিছু করেছেন।"
26
+ fake_sentence = normalize(fake_sentence) # this normalization step is required before tokenizing the text
27
+
28
+ fake_tokens = tokenizer.tokenize(fake_sentence)
29
+ fake_inputs = tokenizer.encode(fake_sentence, return_tensors="pt")
30
+ discriminator_outputs = model(fake_inputs).logits
31
+ predictions = torch.round((torch.sign(discriminator_outputs) + 1) / 2)
32
+
33
+ [print("%7s" % token, end="") for token in fake_tokens]
34
+ print("\n" + "-" * 50)
35
+ [print("%7s" % int(prediction), end="") for prediction in predictions.squeeze().tolist()[1:-1]]
36
+ print("\n" + "-" * 50)
37
+ ```
38
+
39
+ ## Citation
40
+
41
+ If you use this model, please cite the following paper:
42
+ ```
43
+ @misc{bhattacharjee2021banglabert,
44
+ title={BanglaBERT: Combating Embedding Barrier in Multilingual Models for Low-Resource Language Understanding},
45
+ author={Abhik Bhattacharjee and Tahmid Hasan and Kazi Samin and Md Saiful Islam and M. Sohel Rahman and Anindya Iqbal and Rifat Shahriyar},
46
+ year={2021},
47
+ eprint={2101.00204},
48
+ archivePrefix={arXiv},
49
+ primaryClass={cs.CL}
50
+ }
51
+ ```
52
+
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ElectraForPreTraining"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "embedding_size": 768,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 3072,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "electra",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 12,
17
+ "pad_token_id": 0,
18
+ "summary_activation": "gelu",
19
+ "summary_last_dropout": 0.1,
20
+ "summary_type": "first",
21
+ "summary_use_proj": true,
22
+ "type_vocab_size": 2,
23
+ "vocab_size": 32000
24
+ }
25
+
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d33f519f42705d54e65fc1601644a6f4562c3462f96943b32b4184536130f98
3
+ size 442560329
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": false, "tokenize_chinese_chars": false, "special_tokens_map_file": null, "full_tokenizer_file": null}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff