Instructions to use monsoon-nlp/dialect-ar-gpt-2021 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use monsoon-nlp/dialect-ar-gpt-2021 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="monsoon-nlp/dialect-ar-gpt-2021")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("monsoon-nlp/dialect-ar-gpt-2021") model = AutoModelForCausalLM.from_pretrained("monsoon-nlp/dialect-ar-gpt-2021") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use monsoon-nlp/dialect-ar-gpt-2021 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "monsoon-nlp/dialect-ar-gpt-2021" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "monsoon-nlp/dialect-ar-gpt-2021", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/monsoon-nlp/dialect-ar-gpt-2021
- SGLang
How to use monsoon-nlp/dialect-ar-gpt-2021 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "monsoon-nlp/dialect-ar-gpt-2021" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "monsoon-nlp/dialect-ar-gpt-2021", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "monsoon-nlp/dialect-ar-gpt-2021" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "monsoon-nlp/dialect-ar-gpt-2021", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use monsoon-nlp/dialect-ar-gpt-2021 with Docker Model Runner:
docker model run hf.co/monsoon-nlp/dialect-ar-gpt-2021
Dialect-AR-GPT-2021
Finetuned AraGPT-2 demo
This model started with AraGPT2-Medium, from AUB MIND Lab.
This model was then finetuned on dialect datasets from Qatar University, University of British Columbia / NLP, and Johns Hopkins University / LREC for 10 epochs.
You can use special tokens to prompt five dialects: [EGYPTIAN], [GULF], [LEVANTINE], [MAGHREBI], or [MSA], followed by a space.
from simpletransformers.language_generation import LanguageGenerationModel
model = LanguageGenerationModel("gpt2", "monsoon-nlp/dialect-ar-gpt-2021")
model.generate('[GULF] ' + "مدينتي هي", { 'max_length': 100 })
There is NO content filtering in the current version; do not use for public-facing text generation!
Training and Finetuning details
Original model: https://huggingface.co/aubmindlab/aragpt2-medium
I inserted new tokens into the tokenizer, finetuned the model on the dialect samples, and exported the new model.
Notebook: https://colab.research.google.com/drive/19C0zbkSCt5ncVCa4kY-ik9hSEiJcjI-F
Citations
AraGPT2 model:
@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}
}
Dialect data sources:
- Downloads last month
- 1,959