🚀 SILMA AI
SILMA.AI is a leading Generative AI startup dedicated to empowering Arabic speakers with state-of-the-art AI solutions.
🚀 Quick Start
Installation
First, install the Transformers library with:
pip install -U transformers sentencepiece
Usage Examples
Basic Usage
Below are some code snippets to quickly start running the model. Copy the snippet relevant to your use case.
Running with the pipeline
API
import 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",
)
messages = [
{"role": "user", "content": "اكتب رسالة تعتذر فيها لمديري في العمل عن الحضور اليوم لأسباب مرضية."},
]
outputs = pipe(messages, max_new_tokens=256)
assistant_response = outputs[0]["generated_text"][-1]["content"].strip()
print(assistant_response)
السلام عليكم ورحمة الله وبركاته
أودّ أن أعتذر عن عدم الحضور إلى العمل اليوم بسبب مرضي. أشعر بالسوء الشديد وأحتاج إلى الراحة. سأعود إلى العمل فور تعافيي.
شكراً لتفهمكم.
مع تحياتي،
[اسمك]
Advanced Usage
Running the model on a single / multi GPU
First, install the accelerate
library:
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("<start_of_turn>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]
n = 10
even_numbers = generate_even_numbers(n)
print(f"The first {n} even numbers are: {even_numbers}")
✨ Features
Our Flagship Model: SILMA 1.0
- SILMA 1.0 was the TOP-RANKED open-weights Arabic LLM (Until February 2025) with an impressive 9 billion parameter size, surpassing models that are over seven times larger 🏆
💡 Usage Tip
For RAG use-cases please use SILMA Kashif v1.0 as it has been specifically trained for Question Answering tasks.
What makes SILMA exceptional?
- SIMLA is a small language model outperforming 72B models in most arabic language tasks, thus more practical for business use-cases
- SILMA is built over the robust foundational models of Google Gemma, combining the strengths of both to provide you with unparalleled performance
- SILMA is an open-weight model, free to use in accordance with our open license
👥 Our Team
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
📚 Documentation
Model Information
Property |
Details |
Model Type |
SILMA-9B-Instruct-v1.0 |
Library Name |
transformers |
Pipeline Tag |
text-generation |
License |
gemma |
Languages Supported |
Arabic (ar), English (en) |
Tags |
conversational |
Model Performance
The model has been evaluated on various datasets, and here are some of the results: