Downloads · 30 days
0
valindotai/embeddinggemma-300m-coreml
embeddinggemma-300m-coreml is a sentence similarity model from valindotai. Use it when you need a score for how close two texts are. It is set up for coreml. The card lists the license as gemma.
Downloads · 30 days
0
Access
Public
Updated Aug 16, 2026
Repo size
347 MB
Likes
0
Public
Click a slice to open those files.
.bin309 MB · 89%
From the Hugging Face model README
Package.swift:
.package(url: "https://github.com/john-rocky/CoreML-LLM", branch: "main"),
// In your target:
.product(name: "CoreMLLLM", package: "CoreML-LLM"),
Platforms: iOS 18+ / macOS 15+.
import CoreMLLLM
let modelsDir = try FileManager.default.url(
for: .applicationSupportDirectory, in: .userDomainMask,
appropriateFor: nil, create: true)
let eg = try await EmbeddingGemma.downloadAndLoad(modelsDir: modelsDir)
// 768-dim L2-normalised embedding
let v = try eg.encode(text: "How do I list files in Swift?")
// Matryoshka: cheap-to-truncate dims (768 / 512 / 256 / 128)
let v256 = try eg.encode(text: "How do I list files in Swift?",
dim: 256)
// Task-prefixed (RAG document vs. query)
let q = try eg.encode(text: "list files",
task: .retrievalQuery)
let d = try eg.encode(text: "Use FileManager.contentsOfDirectory(...)",
task: .retrievalDocument)
See Gemma3EmbeddingGemma.swift
for task prefixes and dim list.
CoreML conversion of google/embeddinggemma-300m produced with the
CoreML-LLM pipeline. Targets
iOS 26 / macOS 26.
| File | Notes |
|---|---|
encoder.mlmodelc/ | Compiled stateless bidirectional encoder (INT8, ~295 MB) |
encoder.mlpackage/ | Complete generated Core ML source package (INT8, ~295 MB) |
model_config.json | I/O contract, Matryoshka dims, task prefixes |
hf_model/ | Tokenizer files |
99.80% on Apple Neural Engine (1950/1954 dispatched ops, verified via
MLComputePlan on macOS 26). Achieved by:
sum(x²) bounded)Via the CoreML-LLM Swift package:
import CoreMLLLM
let bundleURL = try await Gemma3BundleDownloader.download(
.embeddingGemma300m, into: appSupportDir)
let eg = try await EmbeddingGemma.load(bundleURL: bundleURL)
let vec = try eg.encode(text: "On-device embeddings",
task: .retrievalQuery,
dim: 768) // or 512 / 256 / 128 (Matryoshka)
I/O contract:
input_ids (1, 256) int32, attention_mask (1, 256) fp16 (1.0 valid, 0.0 pad)embedding (1, 768) fp16 — L2 unit norm; truncate the trailing dim and
re-normalize for Matryoshka 512 / 256 / 128The bundle in this repo is built for max_seq_len=256. To choose a different
fixed input length, re-run
python conversion/build_embeddinggemma_bundle.py --max-seq-len <length> --quantize int8.
cosine("cat sat on mat", "feline rested on rug") = 0.7345 (high — similar)
cosine("cat sat on mat", "quantum mechanics") = 0.4650 (low — different)
Inherits Google's Gemma terms of use.
<!-- funnel:v1 -->More models in this format: Core ML Model Zoo — 46 models, each with the recipe that produced it.
Want a different model on-device? Open a request — free, open weights only; the export and its measured numbers get published publicly.
<!-- /funnel:v1 -->