Instructions to use Yamemaru/gemma-3-4b-Darija with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Yamemaru/gemma-3-4b-Darija with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Yamemaru/gemma-3-4b-Darija") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Yamemaru/gemma-3-4b-Darija", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Yamemaru/gemma-3-4b-Darija with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Yamemaru/gemma-3-4b-Darija" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Yamemaru/gemma-3-4b-Darija", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Yamemaru/gemma-3-4b-Darija
- SGLang
How to use Yamemaru/gemma-3-4b-Darija 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 "Yamemaru/gemma-3-4b-Darija" \ --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": "Yamemaru/gemma-3-4b-Darija", "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 "Yamemaru/gemma-3-4b-Darija" \ --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": "Yamemaru/gemma-3-4b-Darija", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use Yamemaru/gemma-3-4b-Darija with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Yamemaru/gemma-3-4b-Darija to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Yamemaru/gemma-3-4b-Darija to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Yamemaru/gemma-3-4b-Darija to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Yamemaru/gemma-3-4b-Darija", max_seq_length=2048, ) - Docker Model Runner
How to use Yamemaru/gemma-3-4b-Darija with Docker Model Runner:
docker model run hf.co/Yamemaru/gemma-3-4b-Darija
Gemma-3-4b-Darija
A fine-tuned version of Google's Gemma-3-4b model specialized for Moroccan Darija language translation. This model can translate between English and Darija, providing both Arabic script and Latin transliteration.
Model Description
Gemma-3-4b-Darija is a fine-tuned version of the Google Gemma-3-4b instruction-tuned model, specifically trained to handle translations and language tasks in Moroccan Darija. The model maintains the reasoning capabilities of the base model while adding specialized knowledge of the Darija dialect.
- Developed by: Yamemaru
- Base model: unsloth/gemma-3-4b-it
- Language: English and Moroccan Darija (Arabic script and Latin transliteration)
- License: Apache 2.0
- Training Dataset: atlasia/Atlaset
Intended Uses
- Translation between English and Moroccan Darija
- Generating responses in both Arabic script and Latin transliteration
- Language learning assistance for Darija
- Cultural exchange and communication support
Usage Examples
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model_name = "Yamemaru/gemma-3-4b-Darija"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16, # Use float16 for efficiency
device_map="auto"
)
# Create messages
messages = [{
"role": "user",
"content": [{"type": "text", "text": "How do you say 'Hello, how are you?' in Moroccan Darija?"}]
}]
# Apply chat template for generation
text = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True
)
# Generate response
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=128,
temperature=1.0,
top_p=0.95,
top_k=64
)
# Print the response
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Hardware Requirements
- Minimum GPU: NVIDIA T4 (16GB VRAM)
- This model requires approximately 15GB of GPU memory for inference
- For quantized inference (4-bit), 8GB VRAM may be sufficient
Limitations
- The model is specialized for Darija and may not perform as well on general tasks as the base model
- Coverage of dialectal variations within Darija may be limited to the examples in the training data
- The model may sometimes mix Modern Standard Arabic with Darija in its responses
- Quality of translations may vary based on complexity and context
- Latin transliterations follow common conventions but may not be standardized
Training Details
This model was fine-tuned using the Unsloth library with QLoRA techniques on the atlasia/Atlaset dataset. Training specifications:
License
This model is subject to the license of the original Gemma-3-4B model.
- Finetuned from model : unsloth/gemma-3-4b-it-unsloth-bnb-4bit
Model tree for Yamemaru/gemma-3-4b-Darija
Base model
google/gemma-3-4b-pt