GATE-AraBert-v1 — Apple Core AI, Arabic sentence embeddings
A Core AI (.aimodel) build of
Omartificial-Intelligence-Space/GATE-AraBert-v1
for on-device Arabic sentence embeddings on Apple Silicon.
Upstream ships model.safetensors and a sentence-transformers config — and no MLX, no ONNX and no
Core AI. 14,743 downloads, and this is the Core AI build.
Read this first: the vectors are deliberately NOT normalised
Upstream's modules.json declares Transformer -> Pooling and nothing else, and
1_Pooling/config.json sets pooling_mode_mean_tokens: true. There is no 2_Normalize module — so
the library returns mean-pooled vectors with no L2 normalisation, and so does this bundle. The
norms below are ~21–23, not 1.0.
That is a deliberate difference from
Vela-1.0-Encoder-307M-Embedding-CoreAI,
whose upstream pipeline does include a Normalize module and whose bundle therefore normalises. Copy
the wrong behaviour across bundles and the cosine scores stop matching the library.
If you want cosine similarity, normalise on your side:
v = v / np.linalg.norm(v)
Illustrative comparison with a masked-language BERT
GATE-AraBert was trained for similarity, and it shows. Compare with the CAMeLBERT-mix bundle, where mean pooling on a model with no such objective left unrelated Arabic sentences at 0.65:
| Pair | GATE-AraBert | CAMeLBERT-mix |
|---|---|---|
| كيف أستعيد كلمة المرور؟ ↔ نسيت كلمة المرور… | 0.4737 | 0.8605 |
| ما هي سياسة أمن التطبيقات… ↔ أريد أن أعرف سياسة… | 0.7077 | 0.9108 |
| كيف أستعيد كلمة المرور؟ ↔ الطقس في الرياض (unrelated) | 0.1626 | 0.6538 |
Lower absolute scores but a wider margin on these pairs: 0.31 to 0.55 of separation against 0.16 to 0.21. The gap, not the height, is what matters for retrieval — but this is three sentence pairs, not an information-retrieval benchmark. No NDCG, MRR or MAP was computed.
Cross-lingual: "How do I reset my password?" sits at 0.4274 from its Arabic counterpart.
Verified equivalence
Measured against the library's own encoder — sentence_transformers.SentenceTransformer.encode
with normalize_embeddings=False, not a reimplementation of its pooling:
| Input | max abs diff | cosine | norm |
|---|---|---|---|
| كيف أستعيد كلمة المرور؟ | 3.99e-06 | 1.00000000 | 22.87 |
| نسيت كلمة المرور ولا أستطيع تسجيل الدخول. | 3.81e-06 | 1.00000000 | 22.31 |
| الطقس في الرياض حار اليوم. | 3.46e-06 | 1.00000000 | 22.60 |
| ما هي سياسة أمن التطبيقات في الشركة؟ | 2.32e-06 | 1.00000000 | 22.20 |
| أريد أن أعرف سياسة أمن التطبيقات المعتمدة. | 2.74e-06 | 1.00000000 | 21.50 |
| How do I reset my password? | 3.55e-06 | 1.00000000 | 21.02 |
Worst: 3.99e-06 on vectors of norm ~22 — relative ~1.8e-7, float32 rounding.
Use
import asyncio, numpy as np
from coreai.runtime import AIModel, NDArray, SpecializationOptions
from transformers import AutoTokenizer
SEQUENCE_LENGTH = 512 # fixed shape: pad to it
async def embed(text: str):
tok = AutoTokenizer.from_pretrained(".")
model = await AIModel.load("gate-arabert.aimodel", SpecializationOptions.default())
fn = model.load_function("main")
enc = tok([text], padding="max_length", truncation=True, max_length=SEQUENCE_LENGTH,
return_tensors="np")
out = await fn({"input_ids": NDArray(enc["input_ids"].astype("int32")),
"attention_mask": NDArray(enc["attention_mask"].astype("int32"))})
v = np.asarray(list(out.values())[0].numpy()).reshape(-1).astype("float64")
return v / np.linalg.norm(v) # normalise yourself; upstream does not
print(asyncio.run(embed("كيف أستعيد كلمة المرور؟")).shape) # (768,)
What is in here
| File | |
|---|---|
gate-arabert.aimodel/ |
the graph |
manifest.json |
source, revision, the no-normalise decision, shapes, precision |
validation.json |
PyTorch-to-Core AI equivalence for each case above; the comparison numbers above are in this README |
gate_coreai.py |
the exporter and measurer — --check, --export, --measure |
1_Pooling/config.json, modules.json, sentence_bert_config.json |
upstream's own pipeline description, so the choice is auditable |
| tokenizer files | so the tokenizer loads from this repository |
Limits
- Fixed at 512 tokens; pad rather than passing a shorter sequence.
- Six inputs measured. Arabic dialects, long documents, and the 512-token boundary were not.
- No speed or memory benchmark. Equivalence only.
- Un-normalised output is intentional — see above. Do not assume cosine works without normalising.
Licence and attribution
Apache-2.0, as declared by upstream. A derivative work of
Omartificial-Intelligence-Space/GATE-AraBert-v1; credit for the model is theirs.
One caveat, because the chain matters: GATE-AraBert-v1's card names
Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2 as its base, and the licence situation
further up that chain is not declared. This bundle reproduces the licence that the model it
redistributes declares, and makes no claim about anything deeper.