Text Generation
Transformers
Safetensors
Arabic
English
llama
lebanese
ammiya
arabizi
nlp
dgx-spark
blackwell
sm_121a
conversational
text-generation-inference
Instructions to use assix-research/lebanese-llama-3.1-8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use assix-research/lebanese-llama-3.1-8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="assix-research/lebanese-llama-3.1-8b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("assix-research/lebanese-llama-3.1-8b") model = AutoModelForCausalLM.from_pretrained("assix-research/lebanese-llama-3.1-8b", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use assix-research/lebanese-llama-3.1-8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "assix-research/lebanese-llama-3.1-8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "assix-research/lebanese-llama-3.1-8b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/assix-research/lebanese-llama-3.1-8b
- SGLang
How to use assix-research/lebanese-llama-3.1-8b 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 "assix-research/lebanese-llama-3.1-8b" \ --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": "assix-research/lebanese-llama-3.1-8b", "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 "assix-research/lebanese-llama-3.1-8b" \ --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": "assix-research/lebanese-llama-3.1-8b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use assix-research/lebanese-llama-3.1-8b with Docker Model Runner:
docker model run hf.co/assix-research/lebanese-llama-3.1-8b
File size: 5,673 Bytes
be48fd2 8081389 be48fd2 cd1f3f6 91d8a64 be48fd2 91d8a64 3ddc9c0 91d8a64 be48fd2 450f1e7 be48fd2 450f1e7 be48fd2 3ddc9c0 7577e18 3ddc9c0 7577e18 3ddc9c0 be48fd2 d1e1207 be48fd2 d1e1207 be48fd2 3144d9d be48fd2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | ---
license: mit
base_model: unsloth/meta-llama-3.1-8b-instruct-bnb-4bit
language:
- ar
- en
library_name: transformers
tags:
- lebanese
- ammiya
- arabizi
- nlp
- dgx-spark
- blackwell
- sm_121a
datasets:
- assix/lebanese-dialect-fusion-v1
metrics:
- loss
---
# ๐ฑ๐ง Lebanese-Llama-3.1-8B
**Lebanese-Llama-3.1-8B** is a high-performance LLM fine-tuned specifically for the Lebanese dialect (**Ammiya**). It bridges the gap between Modern Standard Arabic (MSA) and the multi-modal nature of Lebanese communication, seamlessly blending Arabic script, French/English influences, and **Arabizi** (Romanized Arabic with numbers).
This model was trained and validated on the **NVIDIA DGX Spark**, the worldโs first personal AI supercomputer powered by the **Grace Blackwell (GB10)** architecture.
## ๐ฎ Live Demo
Try the model instantly in your browser without any setup:
๐ **[Lebanese Llama Chat Demo](https://huggingface.co/spaces/esix117/lebanese-llama-demo)**
## ๐ญ The Lebanese Persona
To get the most authentic "Ammiya" experience, use this system prompt. It activates the model's specialized cultural knowledge and linguistic patterns.
**System Prompt:**
> "You are an authentic Lebanese AI assistant. You MUST respond ONLY in Arabizi (Latin/English letters).
Speak strictly in the Lebanese dialect (Ammiya).
Use expressions like 'Yalla', 'Walaw', 'Mni7', and 'Ya zalame'.
Respond in Arabizi (using numbers like 3, 7, 2) or Arabic script as requested.
Example: 'Kifak ya m3allem? Shou el akhbar?'"
### Example Comparison
* **User:** "Kifak? Khabbirni kif l wade3 bi Lebnen l yom bi kel sra7a."
* **Lebanese-Llama:** "Ya zalame, l wade3 de7ek mtl kel marra. Kelshi mni7, hamdellah."
---
## ๐ Model Features
* **Dialectal Authenticity:** Fine-tuned to recognize and generate Lebanese syntax, specifically the "B" prefix for verbs and regional idioms (e.g., *mni7*, *shou fi ma fi*).
* **Arabizi Mastery:** Expertly handles Romanized Lebanese using numbers (e.g., `3` for 'ayn, `7` for ha, `2` for hamza).
* **Blackwell Optimized:** Merged into **16-bit (Bfloat16)** to leverage the 5th Gen Tensor Cores and 128GB Unified Memory of the DGX Spark.
* **Cultural Nuance:** Enhanced understanding of Lebanese culinary, geographic, and social context compared to base Llama-3.1.
## ๐ Training Specifications
* **Infrastructure:** NVIDIA DGX Spark (Grace Blackwell Superchip)
* **Architecture:** Llama-3.1-8B-Instruct (4-bit QLoRA base)
* **Training Steps:** 300 steps
* **Loss Convergence:** Dropped from **5.3** to **2.2285**
* **Optimizer:** Unsloth (Stable Bfloat16 Path)
## ๐ป Usage & Implementation
Because this model was developed on the **sm_121a** architecture, it is best loaded using the "Stable Path" to avoid Triton compiler conflicts.
### Standard Inference (Hugging Face Transformers)
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "esix117/lebanese-llama-3.1-8b"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Recommended System Prompt for a Native Persona
system_prompt = "You are a helpful Lebanese assistant speaking strictly in Lebanese Ammiya (dialect)."
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "Marhaba! Kifak el yom? Khabbirni shway shou fi ma fi."}
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to("cuda")
outputs = model.generate(inputs, max_new_tokens=150, temperature=0.7)
# Slice the output to remove the prompt and only show the assistant's reply
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
```
๐ก Prompting Tips
To get the most out of Lebanese-Llama-3.1-8B, you can "steer" the model's output script and tone by adjusting your system prompt.
๐ Script Control
You can toggle between Arabizi and Arabic Script by changing the persona constraints:
Output Format Keywords to use in System Prompt
Arabizi Only "MUST respond ONLY in Arabizi (Latin script). Do not use Arabic script."
Arabic Script "MUST respond ONLY in Lebanese Arabic script. Do not use Latin letters."
Mixed (Natural) "Respond naturally in Lebanese Ammiya, using the script the user uses."
๐ญ Tone & Slang
Because the model was trained on the DGX Spark with a focus on dialectal authenticity, it responds well to specific slang triggers:
Casual: Add "Use slang like 'Ya zalame' or 'ya m3allem'."
Helpful: Add "You are a friendly Lebanese cousin helping a relative."
Direct: Add "Be short and snappy, like a WhatsApp message."
๐ Troubleshooting for Developers
Handling "Echoing"
When using the transformers library, the model may return your prompt along with its answer. Always slice your output tensor to get the clean Lebanese response:
Python
# Use the input length to slice the output
```python
response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
```
โ ๏ธ Known Limitations & Blackwell Optimization
Triton Compatibility: If running on Blackwell hardware (sm_121a), you may encounter a ptxas fatal : Value 'sm_121a' is not defined error when using custom kernels. To fix this, use the standard PyTorch RMS Norm fallback:
```python
import unsloth.kernels.rms_layernorm
unsloth.kernels.rms_layernorm.fast_rms_layernorm = torch.nn.functional.rms_norm
```
๐ค Contribution & Acknowledgements
Developed by assix on the DGX Spark infrastructure. Special thanks to the researchers behind the open-source dialect datasets used in this fusion.
License: MIT |