Mannyking/embeddinggemma-coreml
EmbeddingGemma → Core ML
This repository contains Core ML conversions of Google's official embeddinggemma-300m checkpoint. Each package uses a fixed 512-token input and returns one normalized 768-dimensional embedding.
Conversion scripts, validation details, and the evidence trail live in the source repository.
Packages
The F32 iOS 18 package is the source for the int4 candidate. The mixed-FP16 package uses FP16 only for gather and linear operations; attention, normalization, pooling, and outputs remain Float32. The int4 candidate uses per-block int4 linear weights, except attention Q/K/V/output projections, which remain int8.
Tokenizer and Inputs
Tokenizer assets are in `tokenizer/`.
Use right padding. Add BOS and EOS tokens; <pad> is ID 0, <eos> is ID 1, <bos> is ID 2, and <unk> is ID 3. The 512-token limit includes the prompt and special tokens.
Use these prompts before tokenization as adviced by The Gemma team:
- Query:
task: search result | query: - Document:
title: none | text:
Validation
The original checkpoint is pinned to `57c266a740f537b4dc058e1b0cda161fd15afa75`.
The saved F32 iOS 18 package passed macOS assessment on ten fixtures, including exact 511- and 512-token inputs; its largest recorded elementwise error against the original-model baseline was 4.34e-7.
The mixed-FP16 package passed its saved-artifact assessment with cosine similarity from 0.999911 to 0.999960 against that baseline. The int4/int8 package is intentionally lossy; its exact 511- and 512-token fixtures had cosine near 0.901 against F32.
BEIR SciFact Retrieval
The F32 and int4/int8 packages were evaluated across 252 eligible SciFact claims and 4,799 abstracts. Records over the fixed 512-token limit were excluded.
This is a quick, single-dataset retrieval check added to catch large quality regressions from conversion or quantization. It is not a broad benchmark, an app-quality claim, or a device-performance result.
Source and License
Based on google/embeddinggemma-300m. These packages and tokenizer assets are Gemma model derivatives and are subject to the Gemma Terms of Use.
