Model reference · open weights
SILMA is an open-weight language model from silma-ai. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | silma-ai |
|---|---|
| Type | Language models |
| Task | Text gen |
| Parameters (lead) | 9.2B |
| Context | 8k tokens |
| Runs with | transformers |
| Released | 2024-08-17 |
| Popularity | 1k downloads / month |
| Licence | Open, with conditions |
About
SILMA.AI is a leading Generative AI startup dedicated to empowering Arabic speakers with state-of-the-art AI solutions.
Important Tip: 💡 For RAG use-cases please use SILMA Kashif v1.0 as it has been specifically trained for Question Answering tasks.
We are a team of seasoned Arabic AI experts who understand the nuances of the language and cultural considerations, enabling us to build solutions that truly resonate with Arabic users.
Authors: silma.ai
Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
pip install -U transformers sentencepiece
Then, copy the snippet from the section that is relevant for your usecase.
pipeline APIimport torch
from transformers import pipeline
pipe = pipeline(
"text-generation",
model="silma-ai/SILMA-9B-Instruct-v1.0",
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda", # replace with "mps" to run on a Mac device
)
messages = [
{"role": "user", "content": "اكتب رسالة تعتذر فيها لمديري في العمل عن الحضور اليوم لأسباب مرضية."},
]
outputs = pipe(messages, max_new_tokens=256)
assistant_response = outputs[0]["generated_text"][-1]["content"].strip()
print(assistant_response)
السلام عليكم ورحمة الله وبركاته
أودّ أن أعتذر عن عدم الحضور إلى العمل اليوم بسبب مرضي. أشعر بالسوء الشديد وأحتاج إلى الراحة. سأعود إلى العمل فور تعافيي.
شكراً لتفهمكم.
مع تحياتي،
[اسمك]
pip install accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "silma-ai/SILMA-9B-Instruct-v1.0"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.bfloat16,
)
messages = [
{"role": "system", "content": "أنت مساعد ذكي للإجابة عن أسئلة المستخدمين."},
{"role": "user", "content": "أيهما أبعد عن الأرض, الشمس أم القمر؟"},
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=256)
print(tokenizer.decode(outputs[0]))
الشمس
You can ensure the correct chat template is applied by using tokenizer.apply_chat_template as follows:
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "silma-ai/SILMA-9B-Instruct-v1.0"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.bfloat16,
)
messages = [
{"role": "system", "content": "أنت مساعد ذكي للإجابة عن أسئلة المستخدمين."},
{"role": "user", "content": "اكتب كود بايثون لتوليد متسلسلة أرقام زوجية."},
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=256)
print(tokenizer.decode(outputs[0]).split("model")[-1])
def generate_even_numbers(n):
"""
This function generates a list of even numbers from 1 to n.
Args:
n: The upper limit of the range.
Returns:
A list of even numbers.
"""
return [i for i in range(1, n + 1) if i % 2 == 0]
# Example usage
n = 10
even_numbers = generate_even_numbers(n)
print(f"The first {n} even numbers are: {even_numbers}")
bitsandbytesUsing 8-bit precision (int8)
pip install bitsandbytes accelerate
# pip install bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
model_id = "silma-ai/SILMA-9B-Instruct-v1.0"
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=quantization_config,
)
messages = [
{"role": "system", "content": "أنت مساعد ذكي للإجابة عن أسئلة المستخدمين."},
{"role": "user", "content": "اذكر خمس انواع فواكه بها نسب عالية من فيتامين ج."},
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=256)
print(tokenizer.decode(outputs[0]).split("model")[-1])
الليمون، البرتقال، الموز، الكيوي، الفراولة
Using 4-bit precision
# pip install bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
model_id = "silma-ai/SILMA-9B-Instruct-v1.0"
quantization_config = BitsAndBytesConfig(load_in_4bit=True)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=quantization_config,
)
messages = [
{"role": "system", "content": "أنت مساعد ذكي للإجابة عن أسئلة المستخدمين."},
{"role": "user", "content": "في أي عام توفى صلاح الدين الأيوبي؟"},
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=256)
print(tokenizer.decode(outputs[0]).splFrom the published model card. Full card on the HuggingFace links in the sidebar.
Benchmarks
As published on the model card — the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| text-generation | Arabic Broad Benchmark (ABB) | benchmark_score | 6.150 |
| text-generation | MMLU (Arabic) | acc_norm | 52.550 |
| text-generation | AlGhafa | acc_norm | 71.850 |
| text-generation | ARC Challenge (Arabic) | acc_norm | 78.190 |
| text-generation | ACVA | acc_norm | 78.890 |
| text-generation | Arabic_EXAMS | acc_norm | 51.400 |
| text-generation | ARC Easy | acc_norm | 86 |
| text-generation | BOOLQ (Arabic) | acc_norm | 64.050 |
| text-generation | COPA (Arabic) | acc_norm | 78.890 |
| text-generation | HELLASWAG (Arabic) | acc_norm | 47.640 |
| text-generation | OPENBOOK QA (Arabic) | acc_norm | 72.930 |
| text-generation | PIQA (Arabic) | acc_norm | 71.960 |
| text-generation | RACE (Arabic) | acc_norm | 75.550 |
| text-generation | SCIQ (Arabic) | acc_norm | 91.260 |
| text-generation | TOXIGEN (Arabic) | acc_norm | 67.590 |
| Text Generation | IFEval (0-Shot) | strict accuracy | 58.420 |
| Text Generation | BBH (3-Shot) | normalized accuracy | 30.710 |
| Text Generation | MATH Lvl 5 (4-Shot) | exact match | 0 |
| Text Generation | GPQA (0-shot) | acc_norm | 7.380 |
| Text Generation | MuSR (0-shot) | acc_norm | 17.260 |
| Text Generation | MMLU-PRO (5-shot) | accuracy | 32.440 |
Using it via the API
Once AxForge deploys silma for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (silma below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/chat/completions \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"silma","messages":[{"role":"user","content":"Hello"}]}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.