Downloads · 30 days
32
49% of all-time downloads
haihengh/all-MiniLM-L6-v2-coreml
all-MiniLM-L6-v2-coreml is a feature extraction model from haihengh. Use it when you need embeddings to search or compare text. It is set up for coremltools. The card lists the license as apache-2.0.
Core ML conversion of sentence-transformers/all-MiniLM-L6-v2 for on-device text embeddings on iOS/macOS.
Downloads · 30 days
32
49% of all-time downloads
All-time downloads
65
Public
Repo size
45 MB
Likes
0
Public
Click a slice to open those files.
.bin89.9 MB · 99%
From the Hugging Face model README
Core ML conversion of sentence-transformers/all-MiniLM-L6-v2 for on-device text embeddings on iOS/macOS.
| Property | Value |
|---|---|
| Parameters | 22.7M |
| Embedding dim | 384 |
| Max input tokens | 256 |
| Original model | ~90 MB (FP32) |
| Core ML size | ~43 MB (FP16) |
| Compute units | CPU + Neural Engine |
| Min deployment | iOS 18 / macOS 15 |
all-minilm-l6-v2.mlpackage/ — Core ML model package (portable format). Compile with xcrun coremlcompiler for your target device.all-minilm-l6-v2.mlmodelc/ — Pre-compiled model for Apple Silicon Macs.tokenizer/ — BERT WordPiece tokenizer (tokenizer.json, vocab.txt, config files).import CoreML
let model = try MLModel(contentsOf: modelURL)
let prediction = try await model.prediction(input: [
"input_ids": inputIds,
"attention_mask": attentionMask,
"token_type_ids": tokenTypeIds
])
let embedding = prediction.featureValue(for: "div_1")!.multiArrayValue!
// Shape: (1, 384), L2-normalized
import coremltools as ct
from transformers import AutoTokenizer
model = ct.models.MLModel("all-minilm-l6-v2.mlpackage")
tokenizer = AutoTokenizer.from_pretrained("tokenizer/")
encoded = tokenizer("Hello world", return_tensors="np",
padding="max_length", truncation=True, max_length=256)
prediction = model.predict({
"input_ids": encoded["input_ids"].astype("int32"),
"attention_mask": encoded["attention_mask"].astype("int32"),
"token_type_ids": encoded["token_type_ids"].astype("int32"),
})
embedding = prediction["div_1"] # (1, 384), L2-normalized
| Metric | Value |
|---|---|
| Max element diff vs PyTorch FP32 | ~0.001 |
| Cosine similarity vs original | > 0.99995 |
Conversion was done with FP16 precision — effectively lossless for semantic search.
sentence-transformers/all-MiniLM-L6-v2 (PyTorch)
→ torch.export (dynamo)
→ coremltools 9.0 (FP16, iOS18)
→ all-minilm-l6-v2.mlpackage
→ xcrun coremlcompiler
→ all-minilm-l6-v2.mlmodelc
Apache 2.0 (same as the original model).