wissamantoun commited on
Commit
73ec04c
1 Parent(s): 9c9e35e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +134 -145
README.md CHANGED
@@ -1,145 +1,134 @@
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
- # AraBERT v1 & v2 : Pre-training BERT for Arabic Language Understanding
13
-
14
- <img src="https://raw.githubusercontent.com/aub-mind/arabert/master/arabert_logo.png" width="100" align="left"/>
15
-
16
- **AraBERT** is an Arabic pretrained lanaguage model based on [Google's BERT architechture](https://github.com/google-research/bert). AraBERT uses the same BERT-Base config. More details are available in the [AraBERT Paper](https://arxiv.org/abs/2003.00104) and in the [AraBERT Meetup](https://github.com/WissamAntoun/pydata_khobar_meetup)
17
-
18
- There are two versions of the model, AraBERTv0.1 and AraBERTv1, with the difference being that AraBERTv1 uses pre-segmented text where prefixes and suffixes were splitted using the [Farasa Segmenter](http://alt.qcri.org/farasa/segmenter.html).
19
-
20
-
21
- We evalaute AraBERT models on different downstream tasks and compare them to [mBERT]((https://github.com/google-research/bert/blob/master/multilingual.md)), and other state of the art models (*To the extent of our knowledge*). The Tasks were Sentiment Analysis on 6 different datasets ([HARD](https://github.com/elnagara/HARD-Arabic-Dataset), [ASTD-Balanced](https://www.aclweb.org/anthology/D15-1299), [ArsenTD-Lev](https://staff.aub.edu.lb/~we07/Publications/ArSentD-LEV_Sentiment_Corpus.pdf), [LABR](https://github.com/mohamedadaly/LABR)), Named Entity Recognition with the [ANERcorp](http://curtis.ml.cmu.edu/w/courses/index.php/ANERcorp), and Arabic Question Answering on [Arabic-SQuAD and ARCD](https://github.com/husseinmozannar/SOQAL)
22
-
23
- # AraBERTv2
24
-
25
- ## What's New!
26
-
27
- AraBERT now comes in 4 new variants to replace the old v1 versions:
28
-
29
- More Detail in the AraBERT folder and in the [README](https://github.com/aub-mind/arabert/blob/master/AraBERT/README.md) and in the [AraBERT Paper](https://arxiv.org/abs/2003.00104v2)
30
-
31
- Model | HuggingFace Model Name | Size (MB/Params)| Pre-Segmentation | DataSet (Sentences/Size/nWords) |
32
- ---|:---:|:---:|:---:|:---:
33
- AraBERTv0.2-base | [bert-base-arabertv02](https://huggingface.co/aubmindlab/bert-base-arabertv02) | 543MB / 136M | No | 200M / 77GB / 8.6B |
34
- AraBERTv0.2-large| [bert-large-arabertv02](https://huggingface.co/aubmindlab/bert-large-arabertv02) | 1.38G 371M | No | 200M / 77GB / 8.6B |
35
- AraBERTv2-base| [bert-base-arabertv2](https://huggingface.co/aubmindlab/bert-base-arabertv2) | 543MB 136M | Yes | 200M / 77GB / 8.6B |
36
- AraBERTv2-large| [bert-large-arabertv2](https://huggingface.co/aubmindlab/bert-large-arabertv2) | 1.38G 371M | Yes | 200M / 77GB / 8.6B |
37
- AraBERTv0.1-base| [bert-base-arabertv01](https://huggingface.co/aubmindlab/bert-base-arabertv01) | 543MB 136M | No | 77M / 23GB / 2.7B |
38
- AraBERTv1-base| [bert-base-arabert](https://huggingface.co/aubmindlab/bert-base-arabert) | 543MB 136M | Yes | 77M / 23GB / 2.7B |
39
-
40
- All models are available in the `HuggingFace` model page under the [aubmindlab](https://huggingface.co/aubmindlab/) name. Checkpoints are available in PyTorch, TF2 and TF1 formats.
41
-
42
- ## Better Pre-Processing and New Vocab
43
-
44
- We identified an issue with AraBERTv1's wordpiece vocabulary. The issue came from punctuations and numbers that were still attached to words when learned the wordpiece vocab. We now insert a space between numbers and characters and around punctuation characters.
45
-
46
- The new vocabulary was learnt using the `BertWordpieceTokenizer` from the `tokenizers` library, and should now support the Fast tokenizer implementation from the `transformers` library.
47
-
48
- **P.S.**: All the old BERT codes should work with the new BERT, just change the model name and check the new preprocessing dunction
49
- **Please read the section on how to use the [preprocessing function](#Preprocessing)**
50
-
51
- ## Bigger Dataset and More Compute
52
-
53
- We used ~3.5 times more data, and trained for longer.
54
- For Dataset Sources see the [Dataset Section](#Dataset)
55
-
56
- Model | Hardware | num of examples with seq len (128 / 512) |128 (Batch Size/ Num of Steps) | 512 (Batch Size/ Num of Steps) | Total Steps | Total Time (in Days) |
57
- ---|:---:|:---:|:---:|:---:|:---:|:---:
58
- AraBERTv0.2-base | TPUv3-8 | 420M / 207M | 2560 / 1M | 384/ 2M | 3M | -
59
- AraBERTv0.2-large | TPUv3-128 | 420M / 207M | 13440 / 250K | 2056 / 300K | 550K | 7
60
- AraBERTv2-base | TPUv3-8 | 420M / 207M | 2560 / 1M | 384/ 2M | 3M | -
61
- AraBERTv2-large | TPUv3-128 | 520M / 245M | 13440 / 250K | 2056 / 300K | 550K | 7
62
- AraBERT-base (v1/v0.1) | TPUv2-8 | - |512 / 900K | 128 / 300K| 1.2M | 4
63
-
64
- # Dataset
65
-
66
- The pretraining data used for the new AraBERT model is also used for Arabic **GPT2 and ELECTRA**.
67
-
68
- 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)
69
-
70
- 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:
71
- - OSCAR unshuffled and filtered.
72
- - [Arabic Wikipedia dump](https://archive.org/details/arwiki-20190201) from 2020/09/01
73
- - [The 1.5B words Arabic Corpus](https://www.semanticscholar.org/paper/1.5-billion-words-Arabic-Corpus-El-Khair/f3eeef4afb81223df96575adadf808fe7fe440b4)
74
- - [The OSIAN Corpus](https://www.aclweb.org/anthology/W19-4619)
75
- - Assafir news articles. Huge thank you for Assafir for giving us the data
76
-
77
- # Preprocessing
78
-
79
- It is recommended to apply our preprocessing function before training/testing on any dataset.
80
- **Install farasapy to segment text for AraBERT v1 & v2 `pip install farasapy`**
81
-
82
- ```python
83
- from arabert.preprocess import ArabertPreprocessor
84
-
85
- model_name="bert-large-arabertv2"
86
- arabert_prep = ArabertPreprocessor(model_name=model_name)
87
-
88
- text = "ولن نبالغ إذا قلنا إن هاتف أو كمبيوتر المكتب في زمننا هذا ضروري"
89
- arabert_prep.preprocess(text)
90
- >>>"و+ لن نبالغ إذا قل +نا إن هاتف أو كمبيوتر ال+ مكتب في زمن +نا هذا ضروري"
91
- ```
92
-
93
- ## Accepted_models
94
- ```
95
- bert-base-arabertv01
96
- bert-base-arabert
97
- bert-base-arabertv02
98
- bert-base-arabertv2
99
- bert-large-arabertv02
100
- bert-large-arabertv2
101
- araelectra-base
102
- aragpt2-base
103
- aragpt2-medium
104
- aragpt2-large
105
- aragpt2-mega
106
- ```
107
-
108
- # TensorFlow 1.x models
109
-
110
- The TF1.x model are available in the HuggingFace models repo.
111
- You can download them as follows:
112
- - via git-lfs: clone all the models in a repo
113
- ```bash
114
- curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
115
- sudo apt-get install git-lfs
116
- git lfs install
117
- git clone https://huggingface.co/aubmindlab/MODEL_NAME
118
- tar -C ./MODEL_NAME -zxvf /content/MODEL_NAME/tf1_model.tar.gz
119
- ```
120
- where `MODEL_NAME` is any model under the `aubmindlab` name
121
-
122
- - via `wget`:
123
- - Go to the tf1_model.tar.gz file on huggingface.co/models/aubmindlab/MODEL_NAME.
124
- - copy the `oid sha256`
125
- - then run `wget https://cdn-lfs.huggingface.co/aubmindlab/aragpt2-base/INSERT_THE_SHA_HERE` (ex: for `aragpt2-base`: `wget https://cdn-lfs.huggingface.co/aubmindlab/aragpt2-base/3766fc03d7c2593ff2fb991d275e96b81b0ecb2098b71ff315611d052ce65248`)
126
-
127
-
128
- # If you used this model please cite us as :
129
- Google Scholar has our Bibtex wrong (missing name), use this instead
130
- ```
131
- @inproceedings{antoun2020arabert,
132
- title={AraBERT: Transformer-based Model for Arabic Language Understanding},
133
- author={Antoun, Wissam and Baly, Fady and Hajj, Hazem},
134
- booktitle={LREC 2020 Workshop Language Resources and Evaluation Conference 11--16 May 2020},
135
- pages={9}
136
- }
137
- ```
138
- # Acknowledgments
139
- 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.
140
-
141
- # Contacts
142
- **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]>
143
-
144
- **Fady Baly**: [Linkedin](https://www.linkedin.com/in/fadybaly/) | [Twitter](https://twitter.com/fadybaly) | [Github](https://github.com/fadybaly) | <[email protected]> | <[email protected]>
145
-
 
1
+ ---
2
+ language: ar
3
+ datasets:
4
+ - wikipedia
5
+ - Osian
6
+ - 1.5B-Arabic-Corpus
7
+ - oscar-arabic-unshuffled
8
+ - Assafir(private)
9
+ widget:
10
+ - text: " عاصم +ة لبنان هي [MASK] ."
11
+ ---
12
+
13
+ # AraBERT v1 & v2 : Pre-training BERT for Arabic Language Understanding
14
+
15
+ <img src="https://raw.githubusercontent.com/aub-mind/arabert/master/arabert_logo.png" width="100" align="left"/>
16
+
17
+ **AraBERT** is an Arabic pretrained lanaguage model based on [Google's BERT architechture](https://github.com/google-research/bert). AraBERT uses the same BERT-Base config. More details are available in the [AraBERT Paper](https://arxiv.org/abs/2003.00104) and in the [AraBERT Meetup](https://github.com/WissamAntoun/pydata_khobar_meetup)
18
+
19
+ There are two versions of the model, AraBERTv0.1 and AraBERTv1, with the difference being that AraBERTv1 uses pre-segmented text where prefixes and suffixes were splitted using the [Farasa Segmenter](http://alt.qcri.org/farasa/segmenter.html).
20
+
21
+
22
+ We evalaute AraBERT models on different downstream tasks and compare them to [mBERT]((https://github.com/google-research/bert/blob/master/multilingual.md)), and other state of the art models (*To the extent of our knowledge*). The Tasks were Sentiment Analysis on 6 different datasets ([HARD](https://github.com/elnagara/HARD-Arabic-Dataset), [ASTD-Balanced](https://www.aclweb.org/anthology/D15-1299), [ArsenTD-Lev](https://staff.aub.edu.lb/~we07/Publications/ArSentD-LEV_Sentiment_Corpus.pdf), [LABR](https://github.com/mohamedadaly/LABR)), Named Entity Recognition with the [ANERcorp](http://curtis.ml.cmu.edu/w/courses/index.php/ANERcorp), and Arabic Question Answering on [Arabic-SQuAD and ARCD](https://github.com/husseinmozannar/SOQAL)
23
+
24
+ # AraBERTv2
25
+
26
+ ## What's New!
27
+
28
+ AraBERT now comes in 4 new variants to replace the old v1 versions:
29
+
30
+ More Detail in the AraBERT folder and in the [README](https://github.com/aub-mind/arabert/blob/master/AraBERT/README.md) and in the [AraBERT Paper](https://arxiv.org/abs/2003.00104v2)
31
+
32
+ Model | HuggingFace Model Name | Size (MB/Params)| Pre-Segmentation | DataSet (Sentences/Size/nWords) |
33
+ ---|:---:|:---:|:---:|:---:
34
+ AraBERTv0.2-base | [bert-base-arabertv02](https://huggingface.co/aubmindlab/bert-base-arabertv02) | 543MB / 136M | No | 200M / 77GB / 8.6B |
35
+ AraBERTv0.2-large| [bert-large-arabertv02](https://huggingface.co/aubmindlab/bert-large-arabertv02) | 1.38G 371M | No | 200M / 77GB / 8.6B |
36
+ AraBERTv2-base| [bert-base-arabertv2](https://huggingface.co/aubmindlab/bert-base-arabertv2) | 543MB 136M | Yes | 200M / 77GB / 8.6B |
37
+ AraBERTv2-large| [bert-large-arabertv2](https://huggingface.co/aubmindlab/bert-large-arabertv2) | 1.38G 371M | Yes | 200M / 77GB / 8.6B |
38
+ AraBERTv0.2-Twitter-base| [bert-base-arabertv02-twitter](https://huggingface.co/aubmindlab/bert-base-arabertv02-twitter) | 543MB / 136M | No | Same as v02 + 60M Multi-Dialect Tweets|
39
+ AraBERTv0.2-Twitter-large| [bert-large-arabertv02-twitter](https://huggingface.co/aubmindlab/bert-large-arabertv02-twitter) | 1.38G / 371M | No | Same as v02 + 60M Multi-Dialect Tweets|
40
+ AraBERTv0.1-base| [bert-base-arabertv01](https://huggingface.co/aubmindlab/bert-base-arabertv01) | 543MB 136M | No | 77M / 23GB / 2.7B |
41
+ AraBERTv1-base| [bert-base-arabert](https://huggingface.co/aubmindlab/bert-base-arabert) | 543MB 136M | Yes | 77M / 23GB / 2.7B |
42
+
43
+ All models are available in the `HuggingFace` model page under the [aubmindlab](https://huggingface.co/aubmindlab/) name. Checkpoints are available in PyTorch, TF2 and TF1 formats.
44
+
45
+ ## Better Pre-Processing and New Vocab
46
+
47
+ We identified an issue with AraBERTv1's wordpiece vocabulary. The issue came from punctuations and numbers that were still attached to words when learned the wordpiece vocab. We now insert a space between numbers and characters and around punctuation characters.
48
+
49
+ The new vocabulary was learnt using the `BertWordpieceTokenizer` from the `tokenizers` library, and should now support the Fast tokenizer implementation from the `transformers` library.
50
+
51
+ **P.S.**: All the old BERT codes should work with the new BERT, just change the model name and check the new preprocessing dunction
52
+ **Please read the section on how to use the [preprocessing function](#Preprocessing)**
53
+
54
+ ## Bigger Dataset and More Compute
55
+
56
+ We used ~3.5 times more data, and trained for longer.
57
+ For Dataset Sources see the [Dataset Section](#Dataset)
58
+
59
+ Model | Hardware | num of examples with seq len (128 / 512) |128 (Batch Size/ Num of Steps) | 512 (Batch Size/ Num of Steps) | Total Steps | Total Time (in Days) |
60
+ ---|:---:|:---:|:---:|:---:|:---:|:---:
61
+ AraBERTv0.2-base | TPUv3-8 | 420M / 207M | 2560 / 1M | 384/ 2M | 3M | -
62
+ AraBERTv0.2-large | TPUv3-128 | 420M / 207M | 13440 / 250K | 2056 / 300K | 550K | 7
63
+ AraBERTv2-base | TPUv3-8 | 420M / 207M | 2560 / 1M | 384/ 2M | 3M | -
64
+ AraBERTv2-large | TPUv3-128 | 520M / 245M | 13440 / 250K | 2056 / 300K | 550K | 7
65
+ AraBERT-base (v1/v0.1) | TPUv2-8 | - |512 / 900K | 128 / 300K| 1.2M | 4
66
+
67
+ # Dataset
68
+
69
+ The pretraining data used for the new AraBERT model is also used for Arabic **GPT2 and ELECTRA**.
70
+
71
+ 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)
72
+
73
+ 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:
74
+ - OSCAR unshuffled and filtered.
75
+ - [Arabic Wikipedia dump](https://archive.org/details/arwiki-20190201) from 2020/09/01
76
+ - [The 1.5B words Arabic Corpus](https://www.semanticscholar.org/paper/1.5-billion-words-Arabic-Corpus-El-Khair/f3eeef4afb81223df96575adadf808fe7fe440b4)
77
+ - [The OSIAN Corpus](https://www.aclweb.org/anthology/W19-4619)
78
+ - Assafir news articles. Huge thank you for Assafir for providing us the data
79
+
80
+ # Preprocessing
81
+
82
+ It is recommended to apply our preprocessing function before training/testing on any dataset.
83
+
84
+ **Install the arabert python package to segment text for AraBERT v1 & v2 or to clean your data `pip install arabert`**
85
+
86
+ ```python
87
+ from arabert.preprocess import ArabertPreprocessor
88
+
89
+ model_name="aubmindlab/bert-large-arabertv2"
90
+ arabert_prep = ArabertPreprocessor(model_name=model_name)
91
+
92
+ text = "ولن نبالغ إذا قلنا إن هاتف أو كمبيوتر المكتب في زمننا هذا ضروري"
93
+ arabert_prep.preprocess(text)
94
+ >>>"و+ لن نبالغ إذا قل +نا إن هاتف أو كمبيوتر ال+ مكتب في زمن +نا هذا ضروري"
95
+ ```
96
+
97
+ # TensorFlow 1.x models
98
+
99
+ The TF1.x model are available in the HuggingFace models repo.
100
+ You can download them as follows:
101
+ - via git-lfs: clone all the models in a repo
102
+ ```bash
103
+ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
104
+ sudo apt-get install git-lfs
105
+ git lfs install
106
+ git clone https://huggingface.co/aubmindlab/MODEL_NAME
107
+ tar -C ./MODEL_NAME -zxvf /content/MODEL_NAME/tf1_model.tar.gz
108
+ ```
109
+ where `MODEL_NAME` is any model under the `aubmindlab` name
110
+
111
+ - via `wget`:
112
+ - Go to the tf1_model.tar.gz file on huggingface.co/models/aubmindlab/MODEL_NAME.
113
+ - copy the `oid sha256`
114
+ - then run `wget https://cdn-lfs.huggingface.co/aubmindlab/aragpt2-base/INSERT_THE_SHA_HERE` (ex: for `aragpt2-base`: `wget https://cdn-lfs.huggingface.co/aubmindlab/aragpt2-base/3766fc03d7c2593ff2fb991d275e96b81b0ecb2098b71ff315611d052ce65248`)
115
+
116
+
117
+ # If you used this model please cite us as :
118
+ Google Scholar has our Bibtex wrong (missing name), use this instead
119
+ ```
120
+ @inproceedings{antoun2020arabert,
121
+ title={AraBERT: Transformer-based Model for Arabic Language Understanding},
122
+ author={Antoun, Wissam and Baly, Fady and Hajj, Hazem},
123
+ booktitle={LREC 2020 Workshop Language Resources and Evaluation Conference 11--16 May 2020},
124
+ pages={9}
125
+ }
126
+ ```
127
+ # Acknowledgments
128
+ 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.
129
+
130
+ # Contacts
131
+ **Wissam Antoun**: [Linkedin](https://www.linkedin.com/in/wissam-antoun-622142b4/) | [Twitter](https://twitter.com/wissam_antoun) | [Github](https://github.com/WissamAntoun) | <wfa07@mail.aub.edu> | <[email protected]>
132
+
133
+ **Fady Baly**: [Linkedin](https://www.linkedin.com/in/fadybaly/) | [Twitter](https://twitter.com/fadybaly) | [Github](https://github.com/fadybaly) | <[email protected]> | <[email protected]>
134
+