CAMeLBERT-msa-CoreAI — Apple Core AI

A Core AI (.aimodel) build of CAMeL-Lab/bert-base-arabic-camelbert-msa for on-device Arabic inference on Apple Silicon.

Upstream ships PyTorch (and often ONNX/TF) weights and no Core AI build. This is one.

Outputs

Key Shape and meaning
embeddings float32[1,768] mean-pooled + L2 normalised — OUR addition

Labels, in config.json id2label order:


Verified equivalence

Every number below was produced by running the exported graph and the original PyTorch model on the same inputs and diffing the raw outputs. The reference outputs are in ref-output.json, so the check can be re-run rather than believed.

Input embeddings cosine
الخدمة كانت ممتازة وأنصح به بشدة. 2.09e-07 1.0000000000
تجربة سيئة جدا ولن أعود مرة أخرى. 2.68e-07 1.0000000000
المنتج وصل أمس. 1.79e-07 1.0000000000
فريق الدعم ساعدني بسرعة وحل المشكلة. 1.42e-07 1.0000000000
الطلب اتأخر أسبوعين وما حد رد عليا. 1.83e-07 1.0000000000
كيف أستعيد كلمة المرور؟ 1.64e-07 1.0000000000
ابغى اعرف ايش صار بالظبط 1.50e-07 1.0000000000
الرياض 2.83e-07 1.0000000000

Worst absolute difference 2.831e-07. Minimum cosine 1.0000000000 between the embeddings.

This is arithmetic equivalence only. There is no quality benchmark here — no F1, no accuracy score, no comparison with upstream's reported numbers.

Use

import asyncio, numpy as np
from coreai.runtime import AIModel, NDArray, SpecializationOptions
from transformers import AutoTokenizer

LABELS = []
SEQUENCE_LENGTH = 512      # fixed shape: pad to it

async def run(text: str):
    tok = AutoTokenizer.from_pretrained(".")
    model = await AIModel.load("camelbert-arabic-msa.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"))})
    # the runtime names outputs after the op that produced them, so select by shape, not by name
    return [np.asarray(v.numpy()) for v in out.values()]

print([a.shape for a in asyncio.run(run("نص عربي"))])

What is in here

File
camelbert-arabic-msa.aimodel/ the graph
manifest.json label order, shapes, output selection, precision, toolchain
validation.json every measured number
ref-output.json the reference outputs, so the numbers can be re-checked
arabic_encoder_coreai.py the exporter and measurer
tokenizer files so the tokenizer loads from this repository

Limits

  • Fixed at 512 tokens. Longer inputs need chunking.
  • 8 sentences measured, listed above. Dialect text, long documents and domain-specific vocabulary were not.
  • No quality benchmark and no speed or memory measurement.
  • The graph returns raw outputs; pooling, softmax, argmax and BIO decoding are the caller's steps, exactly as in the library.

Licence and attribution

apache-2.0, as declared by upstream. A derivative work of CAMeL-Lab/bert-base-arabic-camelbert-msa; credit for the model is theirs.

Downloads last month
23
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ahmedandaloes/CAMeLBERT-msa-CoreAI

Finetuned
(20)
this model