embeddinggemma-2-coreai / model /MODEL-ATTRIBUTION.json
iannedev's picture
v1.2-audio
305fc2a verified
Raw History Blame Contribute Delete
5.17 kB
{
"name": "EmbeddingGemma-2-CoreAI",
"version": "1.2",
"base_model": "google/embeddinggemma-2",
"base_model_author": "Gemma Team, Google DeepMind",
"base_model_source": "https://huggingface.co/google/embeddinggemma-2",
"base_model_license": "Apache-2.0",
"base_model_terms": "Deployments must adhere to the Gemma Prohibited Use Policy: https://ai.google.dev/gemma/prohibited_use_policy",
"base_model_file_sha256": {
"model.safetensors": "197a32965d4b1105faf060417baa899e193fb73cd401f42ec9295234d5553d79"
},
"port": {
"copyright": "2026 Everpaper",
"license": "Apache-2.0 (see LICENSE); attribution and modification notice in NOTICE",
"date": "2026-10-12",
"format": "Apple Core AI .aimodel (macOS 27), fp16, static shapes",
"exporter": {
"coreai_torch": "0.4.3",
"coreai_core": "1.0.0b3",
"torch": "2.9.0",
"recipe": "export/export.py --buckets 32,64,128,288,512,1024,2048 --qchunks 12 --audio-buckets 192,384,1024,1536,3000",
"global_attention": "mqa4d",
"gqa": "grouped5d"
}
},
"modifications": [
"All three encoders of the multimodal checkpoint (text, vision, audio) are included, as separate assets.",
"Architecture re-authored in plain PyTorch for Core AI export; weights are the original ones (bf16 rounded to fp16), with the scale folds and table cuts listed below.",
"Audio: encoder (Gemma4AudioModel: subsampling convolutions, 12 conformer layers) and audio embedder re-authored in plain PyTorch; the chunked local attention is written in its banded form (each token attends to itself and the 11 previous tokens; the relative-position term is a per-layer constant), the q/k scales are folded into q_proj/k_proj and their clip bounds, the gradient-clipping clamps are dropped, the padded-key mask is an additive -10000, every RMSNorm uses the max-abs rescaling (fp16). Mathematically identical to the reference (fp32 soft-token cosine >= 0.99999998 on 213 clips).",
"Audio: fixed frame buckets 192, 384, 1024, 1536, 3000 (10 ms frames) as functions audio_<Tb>; inputs longer than 30 s are truncated by the host (the upstream default). The three masks are host inputs.",
"Audio preprocessing (host): the upstream log-mel feature extractor re-implemented in numpy and Swift (bit-exact in numpy); resampling to 16 kHz with a Kaiser-windowed sinc instead of upstream's libsoxr (see README).",
"Text: the sqrt(512) token-embedding scale and the 512^-0.5 per-layer-embedding scale are folded into the tables.",
"Text: the four global (full-attention, single-kv-head) layers compute attention as a plain 4-D matmul with k/v broadcast over the heads; the sliding-window layers use a 5-D grouped matmul. Mathematically identical to the reference (fp32 max abs diff 3e-7).",
"fp16 everywhere (Neural Engine): every RMSNorm and the final L2 normalization divide the row by its max-abs value before squaring (text activations reach ~2000, the vision residual ~1400); in the model code every division is expressed as rsqrt(x)*rsqrt(x) (the Neural Engine compiler rejects divide).",
"Text: bidirectional attention masks (padding + sliding window 512) are built inside the graph from attention_mask; the additive mask value is -10000 (finite).",
"Text: masked mean pooling, the 512->768 embedding projection and the L2 normalization run inside the graph; the output is the final sentence embedding.",
"Text: an input mix x = embed(ids)*(1-mm_mask) + mm_embeds*mm_mask at the start of the graph, so that image soft tokens replace the <|image|> placeholder embeddings (soft tokens are not scaled); with zero soft tokens the graph is the v1.0 text encoder.",
"Text: fixed sequence buckets 32, 64, 128, 288, 512, 1024, 2048 as functions mm_<S>; input longer than 2048 tokens must be truncated or chunked by the caller (the original model accepts 8192).",
"Vision: encoder (Gemma4VisionModel, 16 layers) and vision embedder, one fixed shape: the default budget of 280 soft tokens (2520 patches of 16x16). Patches are fed in cell-major order so that the 3x3 average pooling is a reshape + mean instead of a one-hot matmul (attention is permutation-equivariant; identical result).",
"Vision: the patches are integer pixel values 0..255 (exact in fp16) instead of pixel/255: the graph computes P - 127.5 and the 2/255 scale is folded into the patch-embedding projection's weights, which equals upstream's projection of 2*(P/255) - 1 without rounding the inputs to fp16 (that rounding cost heavily upscaled tiny images up to 0.004 of cosine).",
"Vision: the pooler's multiplication by sqrt(768) (fp32 upstream, overflows fp16) is dropped and the vision embedder's RMSNorm uses eps/768 instead: RMSNorm(x*s, eps) == RMSNorm(x, eps/s^2).",
"Vision: the 2-D position-embedding tables are cut to the 840 rows reachable at this budget; the axial RoPE cos/sin tables and the key mask are inputs computed by the host; the additive key-mask value is -10000.",
"Image preprocessing (host): the upstream aspect-preserving size rule and the torchvision-exact antialiased bicubic resize on uint8 re-implemented in numpy and Swift."
]
}