CoolFace
Modelpublic

algerian-nlp/DZAIR-FP16

sourceHugging Faceapache-2.0updated 2d agoView on Hugging Face
0likes32downloads
Model Card

DZAIR-FP16

Half-precision build of algerian-nlp/DZAIR, the 105.3M-parameter encoder for Algerian Darija. Same weights, half the bytes, same outputs to five decimal places.

Fidelity

Measured on a fixed 4×96 token probe with one padded row, against the fp32 release. The full report ships as quant_report.json.

fp32fp16
Directory size422.3 MB211.7 MB (2.00× smaller)
model.safetensors421.2 MB210.6 MB
Cosine against fp321.000000 (reference)0.999999
Max absolute difference0.0000000.007960

Release gate: cosine ≥ 0.999.

This build was broken until 2026-09-19 and is worth re-downloading. The earlier upload shipped an fp32 config.json alongside half-precision weights, so transformers reloaded them as float32 — the file was half the size but bought nothing at inference. Loading it genuinely in float16 returned an all-zero hidden state, because RMSNorm squared its input in half precision: trunk activations reach about 316, and 316² = 99,856 overflows the float16 maximum of 65,504, so the mean became inf and its reciprocal square root became 0. The norm statistic is now computed in float32 and cast back — float32 outputs are bit-identical to before (verified: max absolute difference exactly 0.0), and float16 works.

Usage

python
import torch
from transformers import AutoModel, AutoTokenizer

REPO = "algerian-nlp/DZAIR-FP16"
tokenizer = AutoTokenizer.from_pretrained(REPO, trust_remote_code=True)
encoder = AutoModel.from_pretrained(REPO, trust_remote_code=True).eval()

texts = ["يعطيك الصحة خويا", "ya3tik saha khoya, bon courage f projet"]
inputs = tokenizer([t.lower() for t in texts], padding=True, return_tensors="pt")
with torch.inference_mode():
    hidden = encoder(**inputs).last_hidden_state
print(hidden.dtype, hidden.shape)  # torch.float16 torch.Size([2, N, 768])

Lowercase Latin spans before encoding — the vocabulary was built over lowercased Latin and raw uppercase costs about 10% fertility. Arabizi phoneme digits (3, 7, 9) are atomic pieces; never transliterate them away.

Files

filesizecontents
model.safetensors210.6 MBfloat16 weights
config.json1 KBarchitecture, dtype: float16, auto_map
modeling_dzair.py59 KBthe architecture in one self-contained file
tokenizer.model, tokenizer_config.jsonabout 1.0 MB48k SentencePiece Unigram via DebertaV2Tokenizer, specials at ids 0–4, right padding
tokenizer_rules.yaml2 KBversioned normalisation rules
quant_report.jsonunder 1 KBthe measurement above

Licence

Apache-2.0, inherited from the base model. Read the licence composition on the base card before redistributing derivatives: a permissive grant on the weights makes no claim about the underlying text, most of which has no resolvable licence.