CoolFace
Modelpublic

CAMeL-Lab/bert-base-arabic-camelbert-mix-ner

sourceHugging Faceapache-2.0updated 5y agoView on Hugging Face
15likes11kdownloads
README.md77 linesDownload Raw Back to root
1---2language: 3- ar4license: apache-2.05widget:6 - text: "إمارة أبوظبي هي إحدى إمارات دولة الإمارات العربية المتحدة السبع"7---8# CAMeLBERT-Mix NER Model9## Model description10**CAMeLBERT-Mix NER Model** is a Named Entity Recognition (NER) model that was built by fine-tuning the [CAMeLBERT Mix](https://huggingface.co/CAMeL-Lab/bert-base-arabic-camelbert-mix/) model.11For the fine-tuning, we used the [ANERcorp](https://camel.abudhabi.nyu.edu/anercorp/) dataset.12Our fine-tuning procedure and the hyperparameters we used can be found in our paper *"[The Interplay of Variant, Size, and Task Type in Arabic Pre-trained Language Models](https://arxiv.org/abs/2103.06678).13"* Our fine-tuning code can be found [here](https://github.com/CAMeL-Lab/CAMeLBERT).14 15## Intended uses16You can use the CAMeLBERT-Mix NER model directly as part of our [CAMeL Tools](https://github.com/CAMeL-Lab/camel_tools) NER component (*recommended*) or as part of the transformers pipeline.17 18#### How to use19To use the model with the [CAMeL Tools](https://github.com/CAMeL-Lab/camel_tools) NER component:20```python21>>> from camel_tools.ner import NERecognizer22>>> from camel_tools.tokenizers.word import simple_word_tokenize23>>> ner = NERecognizer('CAMeL-Lab/bert-base-arabic-camelbert-mix-ner')24>>> sentence = simple_word_tokenize('إمارة أبوظبي هي إحدى إمارات دولة الإمارات العربية المتحدة السبع')25>>> ner.predict_sentence(sentence)26>>> ['O', 'B-LOC', 'O', 'O', 'O', 'O', 'B-LOC', 'I-LOC', 'I-LOC', 'O']27```28You can also use the NER model directly with a transformers pipeline:29```python30>>> from transformers import pipeline31>>> ner = pipeline('ner', model='CAMeL-Lab/bert-base-arabic-camelbert-mix-ner')32>>> ner("إمارة أبوظبي هي إحدى إمارات دولة الإمارات العربية المتحدة السبع")33[{'word': 'أبوظبي',34  'score': 0.9895730018615723,35  'entity': 'B-LOC',36  'index': 2,37  'start': 6,38  'end': 12},39 {'word': 'الإمارات',40  'score': 0.8156259655952454,41  'entity': 'B-LOC',42  'index': 8,43  'start': 33,44  'end': 41},45 {'word': 'العربية',46  'score': 0.890906810760498,47  'entity': 'I-LOC',48  'index': 9,49  'start': 42,50  'end': 49},51 {'word': 'المتحدة',52  'score': 0.8169114589691162,53  'entity': 'I-LOC',54  'index': 10,55  'start': 50,56  'end': 57}]57```58*Note*: to download our models, you would need `transformers>=3.5.0`.59Otherwise, you could download the models manually.60 61## Citation62```bibtex63@inproceedings{inoue-etal-2021-interplay,64    title = "The Interplay of Variant, Size, and Task Type in {A}rabic Pre-trained Language Models",65    author = "Inoue, Go  and66      Alhafni, Bashar  and67      Baimukan, Nurpeiis  and68      Bouamor, Houda  and69      Habash, Nizar",70    booktitle = "Proceedings of the Sixth Arabic Natural Language Processing Workshop",71    month = apr,72    year = "2021",73    address = "Kyiv, Ukraine (Online)",74    publisher = "Association for Computational Linguistics",75    abstract = "In this paper, we explore the effects of language variants, data sizes, and fine-tuning task types in Arabic pre-trained language models. To do so, we build three pre-trained language models across three variants of Arabic: Modern Standard Arabic (MSA), dialectal Arabic, and classical Arabic, in addition to a fourth language model which is pre-trained on a mix of the three. We also examine the importance of pre-training data size by building additional models that are pre-trained on a scaled-down set of the MSA variant. We compare our different models to each other, as well as to eight publicly available models by fine-tuning them on five NLP tasks spanning 12 datasets. Our results suggest that the variant proximity of pre-training data to fine-tuning data is more important than the pre-training data size. We exploit this insight in defining an optimized system selection model for the studied tasks.",76}77```