CoolFace
Modelpublic

NAMAA-Space/zarra

sourceHugging Facemitupdated 1y agoView on Hugging Face
2likes28downloads
Model Card

Zarra: Arabic Static Embedding Model

image/png

Zarra is a static embedding model built using the Model2Vec distillation framework. It is a distilled version of a Sentence Transformer, specifically optimized for the Arabic language. Unlike traditional transformer-based models, Zarra produces static embeddings, enabling ultra-fast inference on both CPU and GPU—making it ideal for resource-constrained environments or real-time applications.

Why Zarra?

⚡ Exceptional Speed: Delivers embeddings up to 500x faster than sentence transformers.

🧠 Compact & Efficient: Up to 50x smaller in size, allowing easy deployment on edge devices.

🧰 Versatile: Well-suited for search, clustering, classification, deduplication, and more.

🌍 Arabic-First: Specifically trained on high-quality Arabic data, ensuring relevance and performance across a range of Arabic NLP tasks.

<p align="center"> <img src="https://cdn-uploads.huggingface.co/production/uploads/628f7a71dd993507cfcbe587/3JEnPfgF2BfbN5H81K0XD.png" alt="Speed vs Performance Chart" width="700"/> </p>

About Model2Vec

The Model2Vec distillation technique transfers knowledge from large transformer models into lightweight static embedding spaces, preserving semantic quality while dramatically improving speed and efficiency. Zarra represents the best of both worlds: the semantic power of transformers and the speed and simplicity of static vectors.

Installation

Install model2vec using pip:

pip install model2vec

Usage

Using Model2Vec

The Model2Vec library is the fastest and most lightweight way to run Model2Vec models.

Load this model using the from_pretrained method:

python
from model2vec import StaticModel

# Load a pretrained Model2Vec model
model = StaticModel.from_pretrained("NAMAA-Space/zarra")

# Compute text embeddings
embeddings = model.encode(["Example sentence"])

Using Sentence Transformers

You can also use the Sentence Transformers library to load and use the model:

python
from sentence_transformers import SentenceTransformer

# Load a pretrained Sentence Transformer model
model = SentenceTransformer("NAMAA-Space/zarra")

# Compute text embeddings
embeddings = model.encode(["Example sentence"])

How it Works

Model2vec creates a small, fast, and powerful model that outperforms other static embedding models by a large margin on all tasks we could find, while being much faster to create than traditional static embedding models such as GloVe. Best of all, you don't need any data to distill a model using Model2Vec.

It works by passing a vocabulary through a sentence transformer model, then reducing the dimensionality of the resulting embeddings using PCA, and finally weighting the embeddings using SIF weighting. During inference, we simply take the mean of all token embeddings occurring in a sentence.

Benchmark on Arabic

Speed

ModelSpeed (sentences/second)Device
zarra26893.63cpu
bojji27478.15cpu
potion-multilingual-128M27145.31cpu
paraphrase-multilingual-MiniLM-L12-v22363.24cuda
silmaaiembeddingstsv0.1627.13cuda
muffakir_embedding621.77cuda
getmultilingualbase895.41cuda
arabicretrievalv1.0618.56cuda
arabictripletmatryoshka_v2610.64cuda
  • Zarra and Bojji excel in speed, achieving 26893.63 and 27478.15 sentences per second on CPU, respectively, far surpassing CUDA-based models like arabictripletmatryoshka_v2 (610.64).
  • Top Performer: Bojji is the fastest model, slightly ahead of Zarra and potion-multilingual-128M (27145.31), highlighting the efficiency of Model2Vec-based models on CPU.
  • Key Observation: The high speed of Zarra and Bojji on CPU makes them ideal for resource-constrained environments, offering significant advantages over CUDA-dependent models.

Size of the Model

ModelParameters (M)Size (MB)Relative to Largest (%)Less than Largest (x)
zarra64.00244.1441.922.39
bojji124.88476.4081.791.22
potion-multilingual-128M128.09488.6383.891.19
paraphrase-multilingual-MiniLM-…117.65448.8277.061.30
silmaaiembeddingstsv0.1135.19515.7288.541.13
muffakir_embedding135.19515.7288.541.13
arabicretrievalv1.0135.19515.7388.541.13
arabictripletmatryoshka_v2135.19515.7288.541.13
getmultilingualbase305.37582.45100.001.00
  • Zarra is the smallest model, with only 64 million parameters and 244.14 MB in size, making it 2.39 times smaller than the largest model (getmultilingualbase).
  • Bojji is slightly larger at 124.88 million parameters and 476.40 MB, but still significantly smaller than most other models.
  • Top Performer: Zarra leads in compactness, offering the smallest footprint, which is critical for deployment on resource-limited devices.
  • Key Observation: The compact size of Zarra and Bojji aligns with their design goal of efficiency, making them highly suitable for edge computing and real-time applications.
ModelAvgMIRACMLQARMassiMultiSTS17STS22XNLI_
arabictripletmatryoshka_v20.66100.62620.50930.55770.58680.85310.63960.8542
muffakir_embedding0.64940.64240.52670.54620.59430.84850.62910.7583
arabicretrievalv1.00.64730.61590.56740.58320.59930.80020.62540.7393
gate_arabert-v10.64440.57740.48080.53450.58470.82780.63100.8746
getmultilingualbase0.64400.71770.56980.50710.55210.78810.61450.7584
arabicstsmatryoshka0.64130.58280.48400.54570.54940.82900.62420.8740
silmaaiembeddingstsv0.10.61380.37990.50110.56000.57490.85590.61220.8125
Arabic-MiniLM-L12-v2-all-nli-triplet0.54310.22400.36120.47750.56980.81110.55400.8043
paraphrase-multilingual-MiniLM-L12-v20.52080.21910.34960.45150.55730.79160.49080.7859
bojji0.51770.29410.39890.46670.54330.72330.58800.6094
zarra0.48220.22950.34730.41190.52370.64690.62180.5942
potion-multilingual-128M0.46990.16580.31500.42850.53380.65110.59510.5999
allminilml6_v20.28430.00050.00640.19050.49340.50890.25180.5384

Sorted by STS17_main (Score)

Model NameSTS17_main
silmaaiembeddingstsv0.10.856
arabictripletmatryoshka_v20.853
muffakir_embedding0.849
arabicstsmatryoshka0.829
gate_arabert-v10.828
Arabic-MiniLM-L12-v2-all-nli-triplet0.811
arabicretrievalv1.00.800
paraphrase-multilingual-MiniLM-L12-v20.792
getmultilingualbase0.788
bojji0.723
potion-multilingual-128M0.651
zarra0.647
allminilml6_v20.509

Sorted by STS22.v2_main (Score)

Model NameSTS22.v2_main
arabictripletmatryoshka_v20.640
gate_arabert-v10.631
muffakir_embedding0.629
arabicretrievalv1.00.625
arabicstsmatryoshka0.624
zarra0.622
getmultilingualbase0.615
silmaaiembeddingstsv0.10.612
potion-multilingual-128M0.595
bojji0.588
Arabic-MiniLM-L12-v2-all-nli-triplet0.554
paraphrase-multilingual-MiniLM-L12-v20.491
allminilml6_v20.252

Additional Resources