All Projects → aub-mind → Arabert

aub-mind / Arabert

Licence: other
Pre-trained Transformers for the Arabic Language Understanding and Generation (Arabic BERT, Arabic GPT2, Arabic Electra)

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Arabert

BasicArabicOCR
A very basic Arabic OCR based on tesseract OCR engine written in Java.
Stars: ✭ 19 (-89.2%)
Mutual labels:  arabic
Pythoncodes
Stars: ✭ 55 (-68.75%)
Mutual labels:  arabic
Arabicstemmer
Assem's Arabic Light Stemmer is a snowball-based stemming algorithm for Arabic aimed mainly to improve search.
Stars: ✭ 102 (-42.05%)
Mutual labels:  arabic
Awesome Arabic
A curated list of awesome projects and dev/design resources for supporting Arabic computational needs.
Stars: ✭ 309 (+75.57%)
Mutual labels:  arabic
Pragmatapro
PragmataPro font is designed to help pros to work better
Stars: ✭ 887 (+403.98%)
Mutual labels:  arabic
Mikhak
simple monoline Arabic-Latin semi handwriting typeface
Stars: ✭ 64 (-63.64%)
Mutual labels:  arabic
Learn-to-program-with-C AR
ترجمة لدرس تعلّم البرمجة بلغة السي الخاص بموقع OpenClassrooms
Stars: ✭ 51 (-71.02%)
Mutual labels:  arabic
Postcss Rtl
PostCSS plugin for RTL-adaptivity
Stars: ✭ 143 (-18.75%)
Mutual labels:  arabic
Dialectid e2e
End to End Dialect Identification using Convolutional Neural Network
Stars: ✭ 40 (-77.27%)
Mutual labels:  arabic
Qutuf
Qutuf (قُطُوْف): An Arabic Morphological analyzer and Part-Of-Speech tagger as an Expert System.
Stars: ✭ 84 (-52.27%)
Mutual labels:  arabic
Rofimoji
An emoji and character picker for rofi 😁
Stars: ✭ 319 (+81.25%)
Mutual labels:  arabic
Arabiccompetitiveprogramming
The repository contains the ENGLISH description files attached to the video series in my ARABIC algorithms channel.
Stars: ✭ 675 (+283.52%)
Mutual labels:  arabic
Redux React I18n
An i18n solution for React/Redux and React Native projects
Stars: ✭ 64 (-63.64%)
Mutual labels:  arabic
Python Arabic Reshaper
Reconstruct Arabic sentences to be used in applications that don't support Arabic
Stars: ✭ 273 (+55.11%)
Mutual labels:  arabic
Bootstrap Rtl
Bootstrap RTL Standard 3 and 4
Stars: ✭ 106 (-39.77%)
Mutual labels:  arabic
MyGoldenDict
My personal goldendict-dictionaries collection
Stars: ✭ 13 (-92.61%)
Mutual labels:  arabic
Vazir Font
Vazir is a Persian/Arabic font. وزیر یک فونت فارسی/عربی است https://rastikerdar.github.io/vazir-font/
Stars: ✭ 1,085 (+516.48%)
Mutual labels:  arabic
Mishkal
Mishkal is an arabic text vocalization software
Stars: ✭ 158 (-10.23%)
Mutual labels:  arabic
Camel tools
A suite of Arabic natural language processing tools developed by the CAMeL Lab at New York University Abu Dhabi.
Stars: ✭ 124 (-29.55%)
Mutual labels:  arabic
Soqal
Arabic Open Domain Question Answering System using Neural Reading Comprehension
Stars: ✭ 72 (-59.09%)
Mutual labels:  arabic

AraBERTv2 / AraGPT2 / AraELECTRA

This repository now contains code and implementation for:

  • AraBERT v0.1/v1: Original
  • AraBERT v0.2/v2: Base and large versions with better vocabulary, more data, more training, Read More..
  • AraGPT2: base, medium, large and MEGA. Trained from scratch on Arabic, Read More..
  • AraELECTRA: Trained from scratch on Arabic Read More..

If you want to clone the old repository:

git clone https://github.com/aub-mind/arabert/
cd arabert && git checkout 6a58ca118911ef311cbe8cdcdcc1d03601123291

AraBERTv2

What's New!

AraBERT now comes in 4 new variants to replace the old v1 versions:

More Detail in the AraBERT folder and in the README and in the AraBERT Paper

Model HuggingFace Model Name Size (MB/Params) Pre-Segmentation DataSet (Sentences/Size/nWords)
AraBERTv0.2-base bert-base-arabertv02 543MB / 136M No 200M / 77GB / 8.6B
AraBERTv0.2-large bert-large-arabertv02 1.38G / 371M No 200M / 77GB / 8.6B
AraBERTv2-base bert-base-arabertv2 543MB / 136M Yes 200M / 77GB / 8.6B
AraBERTv2-large bert-large-arabertv2 1.38G / 371M Yes 200M / 77GB / 8.6B
AraBERTv0.1-base bert-base-arabertv01 543MB / 136M No 77M / 23GB / 2.7B
AraBERTv1-base bert-base-arabert 543MB / 136M Yes 77M / 23GB / 2.7B

All models are available in the HuggingFace model page under the aubmindlab name. Checkpoints are available in PyTorch, TF2 and TF1 formats.

Better Pre-Processing and New Vocab

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.

The new vocabulary was learnt using the BertWordpieceTokenizer from the tokenizers library, and should now support the Fast tokenizer implementation from the transformers library.

P.S.: All the old BERT codes should work with the new BERT, just change the model name and check the new preprocessing function

Please read the section on how to use the preprocessing function

Bigger Dataset and More Compute

We used ~3.5 times more data, and trained for longer. For Dataset Sources see the Dataset Section

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)
AraBERTv0.2-base TPUv3-8 420M / 207M 2560 / 1M 384/ 2M 3M 36
AraBERTv0.2-large TPUv3-128 420M / 207M 13440 / 250K 2056 / 300K 550K 7
AraBERTv2-base TPUv3-8 420M / 207M 2560 / 1M 384/ 2M 3M 36
AraBERTv2-large TPUv3-128 520M / 245M 13440 / 250K 2056 / 300K 550K 7
AraBERT-base (v1/v0.1) TPUv2-8 - 512 / 900K 128 / 300K 1.2M 4

AraGPT2

More details and code are available in the AraGPT2 folder and README

Model

Model HuggingFace Model Name Size / Params
AraGPT2-base aragpt2-base 527MB/135M
AraGPT2-medium aragpt2-medium 1.38G/370M
AraGPT2-large aragpt2-large 2.98GB/792M
AraGPT2-mega aragpt2-mega 5.5GB/1.46B

All models are available in the HuggingFace model page under the aubmindlab name. Checkpoints are available in PyTorch, TF2 and TF1 formats.

Dataset and Compute

For Dataset Source see the Dataset Section

Model Hardware num of examples (seq len = 1024) Batch Size Num of Steps Time (in days)
AraGPT2-base TPUv3-128 9.7M 1792 125K 1.5
AraGPT2-medium TPUv3-128 9.7M 1152 85K 1.5
AraGPT2-large TPUv3-128 9.7M 256 220k 3
AraGPT2-mega TPUv3-128 9.7M 256 800K 9

AraELECTRA

More details and code are available in the AraELECTRA folder and README

Model

Model HuggingFace Model Name Size (MB/Params)
AraELECTRA-base-generator araelectra-base-generator 227MB/60M
AraELECTRA-base-discriminator araelectra-base-discriminator 516MB/135M

Dataset and Compute

Model Hardware num of examples (seq len = 512) Batch Size Num of Steps Time (in days)
ELECTRA-base TPUv3-8 - 256 2M 24

Dataset

The pretraining data used for the new AraBERT model is also used for AraGPT2 and AraELECTRA.

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)

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:

Preprocessing

It is recommended to apply our preprocessing function before training/testing on any dataset. Install farasapy to segment text for AraBERT v1 & v2 pip install farasapy

from arabert.preprocess import ArabertPreprocessor

model_name = "aubmindlab/bert-base-arabertv2"
arabert_prep = ArabertPreprocessor(model_name=model_name)

text = "ولن نبالغ إذا قلنا: إن 'هاتف' أو 'كمبيوتر المكتب' في زمننا هذا ضروري"
arabert_prep.preprocess(text)
>>>"و+ لن نبالغ إذا قل +نا : إن ' هاتف ' أو ' كمبيوتر ال+ مكتب ' في زمن +نا هذا ضروري"

You can also use the unpreprocess() function to reverse the preprocessing changes, by fixing the spacing around non alphabetical characters, and also de-segmenting if the model selected need pre-segmentation. We highly recommend unprocessing generated content of AraGPT2 model, to make it look more natural.

output_text = "و+ لن نبالغ إذا قل +نا : إن ' هاتف ' أو ' كمبيوتر ال+ مكتب ' في زمن +نا هذا ضروري"
arabert_prep.unpreprocess(output_text)
>>>"ولن نبالغ إذا قلنا: إن 'هاتف' أو 'كمبيوتر المكتب' في زمننا هذا ضروري"

Accepted Model Names:

The ArabertPreprocessor class expects one of the following model names:

Note: You can also use the same model name from the HuggingFace model repository without removing aubmindlab/

bert-base-arabertv01
bert-base-arabert
bert-base-arabertv02
bert-base-arabertv2
bert-large-arabertv02
bert-large-arabertv2
araelectra-base
araelectra-base-discriminator
araelectra-base-generator
aragpt2-base
aragpt2-medium
aragpt2-large
aragpt2-mega

Examples Notebooks

  • You can find the old examples that work with AraBERTv1 in the examples/old folder
  • Check the Readme.md file in the examples folder for new links to colab notebooks

TensorFlow 1.x models

You can find the PyTorch, TF2 and TF1 models in HuggingFace's Transformer Library under the aubmindlab username

  • wget https://huggingface.co/aubmindlab/MODEL_NAME/resolve/main/tf1_model.tar.gz where MODEL_NAME is any model under the aubmindlab name

If you used this model please cite us as :

AraBERT

Google Scholar has our Bibtex wrong (missing name), use this instead

@inproceedings{antoun2020arabert,
  title={AraBERT: Transformer-based Model for Arabic Language Understanding},
  author={Antoun, Wissam and Baly, Fady and Hajj, Hazem},
  booktitle={LREC 2020 Workshop Language Resources and Evaluation Conference 11--16 May 2020},
  pages={9}
}

AraGPT2

@misc{antoun2020aragpt2,
      title={AraGPT2: Pre-Trained Transformer for Arabic Language Generation},
      author={Wissam Antoun and Fady Baly and Hazem Hajj},
      year={2020},
      eprint={2012.15520},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

AraELECTRA

@misc{antoun2020araelectra,
      title={AraELECTRA: Pre-Training Text Discriminators for Arabic Language Understanding},
      author={Wissam Antoun and Fady Baly and Hazem Hajj},
      year={2020},
      eprint={2012.15516},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Acknowledgments

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 Members for the continous support. Also thanks to Yakshof and Assafir for data and storage access. Another thanks for Habib Rahal (https://www.behance.net/rahalhabib), for putting a face to AraBERT.

Contacts

Wissam Antoun: Linkedin | Twitter | Github | [email protected] | [email protected]

Fady Baly: Linkedin | Twitter | Github | [email protected] | [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].