Instructions to use MathematicianNLPer/GemMaroc-4b-deita with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MathematicianNLPer/GemMaroc-4b-deita with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MathematicianNLPer/GemMaroc-4b-deita") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("MathematicianNLPer/GemMaroc-4b-deita") model = AutoModelForMultimodalLM.from_pretrained("MathematicianNLPer/GemMaroc-4b-deita", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MathematicianNLPer/GemMaroc-4b-deita with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MathematicianNLPer/GemMaroc-4b-deita" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MathematicianNLPer/GemMaroc-4b-deita", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MathematicianNLPer/GemMaroc-4b-deita
- SGLang
How to use MathematicianNLPer/GemMaroc-4b-deita 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 "MathematicianNLPer/GemMaroc-4b-deita" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MathematicianNLPer/GemMaroc-4b-deita", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "MathematicianNLPer/GemMaroc-4b-deita" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MathematicianNLPer/GemMaroc-4b-deita", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MathematicianNLPer/GemMaroc-4b-deita with Docker Model Runner:
docker model run hf.co/MathematicianNLPer/GemMaroc-4b-deita
Model Card for Model ID
GemMarocโ27B
Unlocking MoroccanโฏDarija proficiency in a stateโofโtheโart large language model, trained with a minimalโdata, greenโAI recipe that preserves Gemmaโ27Bโs strong reasoning abilities while adding fluent Darija generation.
Model at a glance
| Details | |
|---|---|
| Model ID | AbderrahmanSkiredj1/GemMaroc-27b-it |
| Base model | google/gemma-3-27b |
| Architecture | Decoderโonly Transformer (Gemma 3) |
| Parameters | 27โฏbillion |
| Context length | 2โฏ048 tokens |
| Training regime | Supervised fineโtuning (LoRA โ merged) on 50โฏK highโquality Darija/English instructions TULUโ50K slice |
| Compute budget | 48 GPUยทh (8โฏรโฏH100โ80GB ร 6โฏh) โ โโฏ26โฏkWh / 10โฏkgโฏCOโe |
| License | Apache 2.0 |
Why another Darija model?
- Inclusive AIโ>โฏ36โฏmillion speakers of Moroccan Arabic remain underserved by open LLMs.
- QualityโoverโquantityโA carefully curated 50โฏK instruction set surfaces Darija competence without sacrificing crossโlingual reasoning.
- Green AIโGemMaroc achieves AtlasโChatโlevel Darija scores using <โฏ2โฏ% of the energy.
Benchmark summary
| Model | DarijaโฏMMLU | DarijaโฏHellaSwag | GSM8K @5 | HellaSwag (EN) |
|---|---|---|---|---|
| AtlasโChatโ27B | 61.9โฏ% | 48.4โฏ% | 82.0โฏ% | 77.8โฏ% |
| GemMarocโ27B | 61.6โฏ% | 60.5โฏ% | 84.2โฏ% | 79.3โฏ% |
Zeroโshot accuracy; full table in the paper.
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_id = "AbderrahmanSkiredj1/GemMaroc-27b-it"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto"
)
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
device_map="auto",
max_new_tokens=1024,
temperature=0.7,
repetition_penalty=1.2,
no_repeat_ngram_size=3,
)
messages = [
{"role": "user", "content": "ุดูู ูู ูุธุฑูุฉ โbutterfly effectโุ ูุณูุฑูุง ุจุฏุงุฑุฌุฉ ููููุท ู
ุซุงู ุจุณูุท."}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
print(pipe(prompt)[0]["generated_text"][len(prompt):])
Chat template (Gemma 3 format)
The tokenizer provides a bakedโin Jinja template that starts with a beginโofโsequence token (<bos>), then alternates user/model turns, each wrapped by <start_of_turn> โฆ <end_of_turn> markers. When you set add_generation_prompt=True it ends after the opening model tag so the model can continue:
<bos><start_of_turn>user
{user message}<end_of_turn>
<start_of_turn>model
The assistant will keep generating tokens until it decides to emit <end_of_turn>.
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
No manual token juggling requiredโthe call above handles BOS, turn delimiters, and newline placement automatically.
Preโquantised checkpoints will be published under the same repo tags (gemmarocโ27bโawqโint4, gemmarocโ27bโggufโq4_k_m).
Training recipe (oneโparagraph recap)
- DataโTranslate a 44โฏK reasoning slice of TULU 50K into Darija, keeping 20โฏ% English for crossโlingual robustness.
- LoRA SFTโRank 16, ฮฑโฏ=โฏ32, 3โฏepochs, bf16, context 2โฏ048.
- Merge & pushโMerge LoRA into base weights (
peft.merge_and_unload), convert to safetensors, upload.
Limitations & ethical considerations
- Sentiment and abstractive summarisation still trail stateโofโtheโart.
- Tokeniser is unchanged; rare Darija spellings may fragment.
- Model may inherit societal biases present in preโtraining data.
- No RLHF / RLAIF safety alignment yet โ apply a moderation layer in production.
Citation
If you use GemMaroc in your work, please cite:
@misc{abderrahman2025gemmaroc,
author = {Skiredj, Abderrahman and Azhari, Ferdaous and Atou, Houdaifa and Tazi, Nouamane and Berrada, Ismail},
title = {{GemMaroc: Unlocking Darija Proficiency in LLMs with Minimal Data}},
year = {2025},
publisher = {Zenodo},
doi = {10.5281/zenodo.15492072},
url = {https://doi.org/10.5281/zenodo.15492072}
}
- Downloads last month
- 10