Duplicate from asafaya/bert-mini-arabic
Browse filesCo-authored-by: Ali Safaya <asafaya@users.noreply.huggingface.co>
- .gitattributes +10 -0
- README.md +68 -0
- config.json +22 -0
- flax_model.msgpack +3 -0
- model.safetensors +3 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tf_model.h5 +3 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: ar
|
| 3 |
+
datasets:
|
| 4 |
+
- oscar
|
| 5 |
+
- wikipedia
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# Arabic BERT Mini Model
|
| 9 |
+
|
| 10 |
+
Pretrained BERT Mini language model for Arabic
|
| 11 |
+
|
| 12 |
+
_If you use this model in your work, please cite this paper:_
|
| 13 |
+
|
| 14 |
+
```
|
| 15 |
+
@inproceedings{safaya-etal-2020-kuisail,
|
| 16 |
+
title = "{KUISAIL} at {S}em{E}val-2020 Task 12: {BERT}-{CNN} for Offensive Speech Identification in Social Media",
|
| 17 |
+
author = "Safaya, Ali and
|
| 18 |
+
Abdullatif, Moutasem and
|
| 19 |
+
Yuret, Deniz",
|
| 20 |
+
booktitle = "Proceedings of the Fourteenth Workshop on Semantic Evaluation",
|
| 21 |
+
month = dec,
|
| 22 |
+
year = "2020",
|
| 23 |
+
address = "Barcelona (online)",
|
| 24 |
+
publisher = "International Committee for Computational Linguistics",
|
| 25 |
+
url = "https://www.aclweb.org/anthology/2020.semeval-1.271",
|
| 26 |
+
pages = "2054--2059",
|
| 27 |
+
}
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
## Pretraining Corpus
|
| 31 |
+
|
| 32 |
+
`arabic-bert-mini` model was pretrained on ~8.2 Billion words:
|
| 33 |
+
|
| 34 |
+
- Arabic version of [OSCAR](https://traces1.inria.fr/oscar/) - filtered from [Common Crawl](http://commoncrawl.org/)
|
| 35 |
+
- Recent dump of Arabic [Wikipedia](https://dumps.wikimedia.org/backup-index.html)
|
| 36 |
+
|
| 37 |
+
and other Arabic resources which sum up to ~95GB of text.
|
| 38 |
+
|
| 39 |
+
__Notes on training data:__
|
| 40 |
+
|
| 41 |
+
- Our final version of corpus contains some non-Arabic words inlines, which we did not remove from sentences since that would affect some tasks like NER.
|
| 42 |
+
- Although non-Arabic characters were lowered as a preprocessing step, since Arabic characters does not have upper or lower case, there is no cased and uncased version of the model.
|
| 43 |
+
- The corpus and vocabulary set are not restricted to Modern Standard Arabic, they contain some dialectical Arabic too.
|
| 44 |
+
|
| 45 |
+
## Pretraining details
|
| 46 |
+
|
| 47 |
+
- This model was trained using Google BERT's github [repository](https://github.com/google-research/bert) on a single TPU v3-8 provided for free from [TFRC](https://www.tensorflow.org/tfrc).
|
| 48 |
+
- Our pretraining procedure follows training settings of bert with some changes: trained for 3M training steps with batchsize of 128, instead of 1M with batchsize of 256.
|
| 49 |
+
|
| 50 |
+
## Load Pretrained Model
|
| 51 |
+
|
| 52 |
+
You can use this model by installing `torch` or `tensorflow` and Huggingface library `transformers`. And you can use it directly by initializing it like this:
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from transformers import AutoTokenizer, AutoModel
|
| 56 |
+
|
| 57 |
+
tokenizer = AutoTokenizer.from_pretrained("asafaya/bert-mini-arabic")
|
| 58 |
+
model = AutoModelForMaskedLM.from_pretrained("asafaya/bert-mini-arabic")
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Results
|
| 62 |
+
|
| 63 |
+
For further details on the models performance or any other queries, please refer to [Arabic-BERT](https://github.com/alisafaya/Arabic-BERT)
|
| 64 |
+
|
| 65 |
+
## Acknowledgement
|
| 66 |
+
|
| 67 |
+
Thanks to Google for providing free TPU for the training process and for Huggingface for hosting this model on their servers 😊
|
| 68 |
+
|
config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_num_labels": 2,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForMaskedLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"gradient_checkpointing": false,
|
| 8 |
+
"hidden_act": "gelu",
|
| 9 |
+
"hidden_dropout_prob": 0.1,
|
| 10 |
+
"hidden_size": 256,
|
| 11 |
+
"initializer_range": 0.02,
|
| 12 |
+
"intermediate_size": 1024,
|
| 13 |
+
"layer_norm_eps": 1e-12,
|
| 14 |
+
"max_position_embeddings": 512,
|
| 15 |
+
"model_type": "bert",
|
| 16 |
+
"num_attention_heads": 4,
|
| 17 |
+
"num_hidden_layers": 4,
|
| 18 |
+
"output_past": true,
|
| 19 |
+
"pad_token_id": 0,
|
| 20 |
+
"type_vocab_size": 2,
|
| 21 |
+
"vocab_size": 32000
|
| 22 |
+
}
|
flax_model.msgpack
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c7a16e14f0439d52b7af3b7e78f2b26e520d2d51156a627ab76f3a9e84c6d94e
|
| 3 |
+
size 46328481
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cf1f64fdea5dbc06f9ec67af829075e5ce59fa08f1c935f90eb14fe4128b3763
|
| 3 |
+
size 46597590
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e485616e7dda5fe4fa89d8d79b84efd155c2f3887b071112de298706103eeca7
|
| 3 |
+
size 46606791
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tf_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c22fe26dba4f135cb849b0b37a4fe623bbd41cb28d646a127a9966def37939bc
|
| 3 |
+
size 80002760
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"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
|
|
|