Noql: A Tiny and Efficient Persian Text Embedding Model
Noql is a Persian sentence embedding model with only 12M parameters. It is trained with Matryoshka representation learning, so its 768-dimensional embeddings can be truncated to 512, 256, 128 or 64 dimensions with little loss in quality.
| Parameters | 11.9M |
| Architecture | ALBERT-base, mean pooling, L2-normalized |
| Embedding size | 768 (Matryoshka: 512 / 256 / 128 / 64) |
| Max sequence length | 512 tokens |
| Similarity | cosine |
Training
Noql was trained on the Shiraz dataset in three stages:
- Positive pairs: query–document pairs with in-batch negatives (2M samples).
- Hard negatives: half positive pairs, half pairs with mined hard negatives (2M samples).
- Paraphrases and hard negatives: LLM-written paraphrases of Shiraz sentences and paragraphs (formal and colloquial), each with four hard negatives that keep nearly the same wording but change the meaning. These were mixed with about nine batches of query–document pairs with mined hard negatives for every paraphrase batch (1.8M triplets), so retrieval is preserved while the model learns finer distinctions of meaning.
Usage
pip install -U sentence-transformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("shekar-ai/Noql")
sentences = [
"پایتخت ایران تهران است.",
"تهران بزرگترین شهر ایران است.",
"امروز هوا بارانی است.",
]
embeddings = model.encode(sentences)
print(model.similarity(embeddings, embeddings))
# tensor([[1.0000, 0.9082, 0.1614],
# [0.9082, 1.0000, 0.1654],
# [0.1614, 0.1654, 1.0000]])
Retrieval
query = "بهترین زمان برای سفر به شیراز چه موقع است؟"
documents = [
"بهار به دلیل هوای معتدل و شکوفههای نارنج بهترین فصل سفر به شیراز است.",
"قیمت طلا در بازار امروز کاهش یافت.",
"حافظیه و سعدیه از جاذبههای معروف شیراز هستند.",
]
scores = model.similarity(model.encode(query), model.encode(documents))
print(scores)
# tensor([[ 0.6919, -0.1672, 0.5561]])
Smaller embeddings
model = SentenceTransformer("shekar-ai/Noql", truncate_dim=256)
embeddings = model.encode(documents) # shape: (3, 256)
Evaluation
Results on FaMTEB (MTEB(fas, v2), all 52 tasks) at each embedding size.
| Metric | 768 | 512 | 256 | 128 | 64 |
|---|---|---|---|---|---|
| Mean (task) | 59.03 | 58.95 | 58.56 | 58.34 | 56.76 |
| Mean (type) | 63.11 | 63.07 | 62.67 | 62.74 | 61.52 |
| % of 768 score | 100% | 99.9% | 99.2% | 98.8% | 96.2% |
| Storage per vector (fp32) | 3,072 B | 2,048 B | 1,024 B | 512 B | 256 B |
| Task type | Tasks | 768 | 512 | 256 | 128 | 64 |
|---|---|---|---|---|---|---|
| Retrieval | 17 | 48.45 | 48.35 | 48.19 | 47.61 | 44.91 |
| Reranking | 2 | 66.51 | 66.26 | 66.14 | 66.36 | 65.31 |
| Pair Classification | 7 | 82.58 | 82.66 | 82.64 | 82.73 | 82.49 |
| Classification | 16 | 58.70 | 58.47 | 57.93 | 57.29 | 55.92 |
| Clustering | 5 | 56.37 | 56.59 | 55.37 | 56.87 | 56.35 |
| STS | 2 | 73.83 | 73.76 | 73.80 | 73.73 | 73.51 |
| Bitext Mining | 3 | 55.32 | 55.38 | 54.64 | 54.59 | 52.17 |
Citation
@article{Amirivojdan2025Shekar,
author = {Amirivojdan, Ahmad},
title = {{Shekar: A Python Toolkit for Persian Natural Language Processing}},
journal = {Journal of Open Source Software},
volume = {10},
number = {114},
pages = {9128},
year = {2025},
doi = {10.21105/joss.09128},
url = {https://joss.theoj.org/papers/10.21105/joss.09128}
}