aubmindlab
commited on
Commit
·
fb9c65e
1
Parent(s):
197489b
Added model files
Browse files- README.md +104 -0
- config.json +21 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tf1_model.tar.gz +3 -0
- tf_model.h5 +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
README.md
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: ar
|
3 |
+
datasets:
|
4 |
+
- wikipedia
|
5 |
+
- OSIAN
|
6 |
+
- 1.5B Arabic Corpus
|
7 |
+
- OSCAR Arabic Unshuffled
|
8 |
+
widget:
|
9 |
+
- text: " عاصمة لبنان هي [MASK] ."
|
10 |
+
---
|
11 |
+
|
12 |
+
# AraELECTRA
|
13 |
+
|
14 |
+
**ELECTRA** is a method for self-supervised language representation learning. It can be used to pre-train transformer networks using relatively little compute. ELECTRA models are trained to distinguish "real" input tokens vs "fake" input tokens generated by another neural network, similar to the discriminator of a [GAN](https://arxiv.org/pdf/1406.2661.pdf). AraELECTRA achieves state-of-the-art results on Arabic QA dataset.
|
15 |
+
|
16 |
+
For a detailed description, please refer to the AraELECTRA paper [AraELECTRA: Pre-Training Text Discriminators for Arabic Language Understanding](https://arxiv.org/abs/2012.15516).
|
17 |
+
|
18 |
+
## How to use the generator in `transformers`
|
19 |
+
|
20 |
+
```python
|
21 |
+
from transformers import pipeline
|
22 |
+
|
23 |
+
fill_mask = pipeline(
|
24 |
+
"fill-mask",
|
25 |
+
model="aubmindlab/araelectra-base-generator",
|
26 |
+
tokenizer="aubmindlab/araelectra-base-generator"
|
27 |
+
)
|
28 |
+
|
29 |
+
print(
|
30 |
+
fill_mask(" عاصمة لبنان هي [MASK] .)
|
31 |
+
)
|
32 |
+
```
|
33 |
+
|
34 |
+
# Preprocessing
|
35 |
+
|
36 |
+
It is recommended to apply our preprocessing function before training/testing on any dataset.
|
37 |
+
**Install farasapy to segment text for AraBERT v1 & v2 `pip install farasapy`**
|
38 |
+
|
39 |
+
```python
|
40 |
+
from arabert.preprocess import ArabertPreprocessor
|
41 |
+
|
42 |
+
model_name="araelectra-base"
|
43 |
+
arabert_prep = ArabertPreprocessor(model_name=model_name, keep_emojis=True)
|
44 |
+
|
45 |
+
text = "ولن نبالغ إذا قلنا إن هاتف أو كمبيوتر المكتب في زمننا هذا ضروري"
|
46 |
+
arabert_prep.preprocess(text)
|
47 |
+
```
|
48 |
+
|
49 |
+
# Model
|
50 |
+
|
51 |
+
Model | HuggingFace Model Name | Size (MB/Params)|
|
52 |
+
---|:---:|:---:
|
53 |
+
AraELECTRA-base-generator | [araelectra-base-generator](https://huggingface.co/aubmindlab/araelectra-base-generator) | 227MB/60M |
|
54 |
+
AraELECTRA-base-discriminator | [araelectra-base-discriminator](https://huggingface.co/aubmindlab/araelectra-base-discriminator) | 516MB/135M |
|
55 |
+
|
56 |
+
# Compute
|
57 |
+
Model | Hardware | num of examples (seq len = 512) | Batch Size | Num of Steps | Time (in days)
|
58 |
+
---|:---:|:---:|:---:|:---:|:---:
|
59 |
+
AraELECTRA-base | TPUv3-8 | - | 256 | 2M | 24
|
60 |
+
|
61 |
+
# Dataset
|
62 |
+
|
63 |
+
The pretraining data used for the new AraELECTRA model is also used for **AraGPT2 and AraELECTRA**.
|
64 |
+
|
65 |
+
The dataset consists of 77GB or 200,095,961 lines or 8,655,948,860 words or 82,232,988,358 chars (before applying Farasa Segmentation)
|
66 |
+
|
67 |
+
For the new dataset we added the unshuffled OSCAR corpus, after we thoroughly filter it, to the previous dataset used in AraBERTv1 but with out the websites that we previously crawled:
|
68 |
+
- OSCAR unshuffled and filtered.
|
69 |
+
- [Arabic Wikipedia dump](https://archive.org/details/arwiki-20190201) from 2020/09/01
|
70 |
+
- [The 1.5B words Arabic Corpus](https://www.semanticscholar.org/paper/1.5-billion-words-Arabic-Corpus-El-Khair/f3eeef4afb81223df96575adadf808fe7fe440b4)
|
71 |
+
- [The OSIAN Corpus](https://www.aclweb.org/anthology/W19-4619)
|
72 |
+
- Assafir news articles. Huge thank you for Assafir for giving us the data
|
73 |
+
|
74 |
+
|
75 |
+
# TensorFlow 1.x models
|
76 |
+
|
77 |
+
The TF1.x model are avaiable in the HuggingFace models repo.
|
78 |
+
To download them as follows:
|
79 |
+
```bash
|
80 |
+
wget https://s3.amazonaws.com/models.huggingface.co/bert/aubmindlab/MODEL_NAME/tf1_model.tar.gz
|
81 |
+
```
|
82 |
+
where `MODEL_NAME` is any model under the `aubmindlab` name
|
83 |
+
|
84 |
+
|
85 |
+
# If you used this model please cite us as :
|
86 |
+
|
87 |
+
```
|
88 |
+
@misc{antoun2020aragpt2,
|
89 |
+
title={AraGPT2: Pre-Trained Transformer for Arabic Language Generation},
|
90 |
+
author={Wissam Antoun and Fady Baly and Hazem Hajj},
|
91 |
+
year={2020},
|
92 |
+
eprint={2012.15520},
|
93 |
+
archivePrefix={arXiv},
|
94 |
+
primaryClass={cs.CL}
|
95 |
+
}
|
96 |
+
```
|
97 |
+
|
98 |
+
# Acknowledgments
|
99 |
+
Thanks to TensorFlow Research Cloud (TFRC) for the free access to Cloud TPUs, couldn't have done it without this program, and to the [AUB MIND Lab](https://sites.aub.edu.lb/mindlab/) Members for the continous support. Also thanks to [Yakshof](https://www.yakshof.com/#/) and Assafir for data and storage access. Another thanks for Habib Rahal (https://www.behance.net/rahalhabib), for putting a face to AraBERT.
|
100 |
+
|
101 |
+
# Contacts
|
102 |
+
**Wissam Antoun**: [Linkedin](https://www.linkedin.com/in/wissam-antoun-622142b4/) | [Twitter](https://twitter.com/wissam_antoun) | [Github](https://github.com/WissamAntoun) | <[email protected]> | <[email protected]>
|
103 |
+
|
104 |
+
**Fady Baly**: [Linkedin](https://www.linkedin.com/in/fadybaly/) | [Twitter](https://twitter.com/fadybaly) | [Github](https://github.com/fadybaly) | <[email protected]> | <[email protected]>
|
config.json
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"ElectraForMaskedLM"
|
4 |
+
],
|
5 |
+
"attention_probs_dropout_prob": 0.1,
|
6 |
+
"embedding_size": 768,
|
7 |
+
"generator_hidden_size" : 0.33333,
|
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": "electra",
|
16 |
+
"num_attention_heads": 4,
|
17 |
+
"num_hidden_layers": 12,
|
18 |
+
"pad_token_id": 0,
|
19 |
+
"type_vocab_size": 2,
|
20 |
+
"vocab_size": 64000
|
21 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dcdd8c97faade89786721463b6112362c5af06eb40c0fa827cbafadc374e95e2
|
3 |
+
size 238027683
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tf1_model.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cbca4d0cedf32683a99a235494e946ba11a373095f4040260e005948c88f2af1
|
3 |
+
size 538931319
|
tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf11fac28e22bee416e038b4d0a11b58c702e852109f2809357e2c2bf5532085
|
3 |
+
size 436415552
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": false, "do_basic_tokenize": true, "never_split": ["[بريد]", "[مستخدم]", "[رابط]"], "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "special_tokens_map_file": null, "tokenizer_file": null, "name_or_path": "./torch_model_noseg"}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|