Instructions to use Duino/Darija-LM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Duino/Darija-LM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Duino/Darija-LM")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Duino/Darija-LM", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Duino/Darija-LM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Duino/Darija-LM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Duino/Darija-LM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Duino/Darija-LM
- SGLang
How to use Duino/Darija-LM 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 "Duino/Darija-LM" \ --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": "Duino/Darija-LM", "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 "Duino/Darija-LM" \ --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": "Duino/Darija-LM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Duino/Darija-LM with Docker Model Runner:
docker model run hf.co/Duino/Darija-LM
Darija-LM
This is a multilingual language model trained on Arabic and Darija (Moroccan Arabic) Wikipedia datasets.
Model Description
This model is a causal language model based on a GPT-like Transformer architecture. It is trained on a combination of Arabic and Darija (Moroccan Arabic) Wikipedia datasets from the 20231101 snapshot. The model utilizes SentencePiece for tokenization with a BPE algorithm and a vocabulary size of 32000.
Key Model Details:
- Architecture: GPT-like Transformer
- Training Data: Arabic and Darija Wikipedia (20231101 snapshot)
- Tokenizer: SentencePiece (BPE, vocab size: 32000)
- Parameters:
- Embedding Dimension (
n_embd): 384 - Number of Heads (
n_head): 6 - Number of Layers (
n_layer): 6 - Block Size (
block_size): 256 - Dropout: 0.2
- Embedding Dimension (
- Training Hyperparameters: [Specify hyperparameters like learning rate, batch size, optimizer, iterations etc. TODO: Fill in details]
Intended Uses & Limitations
This model is intended for research purposes, specifically in the areas of multilingual NLP and low-resource language modeling, with a focus on Arabic and Darija. It can be used for text generation tasks and further fine-tuning on downstream applications.
Limitations:
- Research Use Only: This model is primarily for research and experimentation. It has not been rigorously evaluated for production environments.
- Data Bias: As it is trained on Wikipedia data, the model may exhibit biases present in the dataset.
- Generation Quality: The quality of generated text may vary. Further fine-tuning and evaluation are recommended for specific use cases.
- Language Coverage: While trained on Arabic and Darija, its performance on other languages is not guaranteed.
How to Use
You can load and use this model using the transformers library from Hugging Face. Make sure you have transformers and sentencepiece installed.
from transformers import AutoModelForCausalLM, AutoTokenizer
import sentencepiece as spm # Ensure sentencepiece is installed
model_name = "Duino/Darija-LM" # or path to your saved model locally
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Example generation code:
input_text = "ู
ุฑุญุจุง ุจุงูุนุงูู
" # Example Arabic/Darija input
input_ids = tokenizer.encode(input_text, return_tensors="pt").to("cuda" if torch.cuda.is_available() else "cpu")
# Generate text (adjust parameters as needed)
output = model.generate(
input_ids,
max_new_tokens=100,
do_sample=True,
temperature=0.7,
top_p=0.9,
top_k=50,
repetition_penalty=1.1
)
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
print(generated_text)
Note on Tokenizer: This model uses a SentencePiece tokenizer. When loading with transformers, it should automatically handle the SentencePiece model if it's correctly configured in the repository.
Training Details
The model was trained using the following steps:
- Data Streaming and Preprocessing: Wikipedia datasets for Arabic and Darija were streamed using
datasetslibrary and preprocessed. - SentencePiece Tokenization: A SentencePiece model was trained on a sample of the Arabic Wikipedia data.
- Model Training: A GPT-like Transformer model was trained from scratch using PyTorch.
- Memory Optimization: Memory mapping was used to handle large datasets efficiently.
- Robust Download: Implemented retry mechanisms for robust dataset downloading.
[TODO: Add more specific details about your training process, optimizer, learning rate schedule, hardware used, training time etc.]
Evaluation
[TODO: Include evaluation metrics if you have them. It's highly recommended to evaluate your model and add metrics here. For example, you could calculate perplexity on a held-out validation set.]
- [Metrics and results on a validation set or benchmark.]
Citation
[TODO: Add citation information if applicable. If you want to be cited, provide the preferred citation format.]
Model Card Contact
[TODO: Add your contact information so people can reach out with questions or feedback.]
- [Your name/organization]
- [Your email/website/Hugging Face profile]
- Downloads last month
- 24