--- license: cc-by-nc-4.0 base_model: facebook/contriever tags: - coreml - checkpoint-conversion --- # contriever — COREML Dense retrieval embeddings with mask-aware mean pooling. Embeddings are not L2-normalized. Conversion of [facebook/contriever](https://huggingface.co/facebook/contriever/tree/2bd46a25019aeea091fd42d1f0fd4801675cf699) at revision `2bd46a25019aeea091fd42d1f0fd4801675cf699`. No fine-tuning or replacement checkpoint. F32 baseline, **not a 4-bit quantization**. Original authors retain credit and license rights. ## Usage and compatibility Core ML ML Program, F32 computation and weights. Input shape is fixed at `[1, 128]` (batch 1). macOS 14+/iOS 17+ export target. Prediction was tested on macOS, not on an iPhone. ```python from huggingface_hub import snapshot_download import coremltools as ct, numpy as np path = snapshot_download("masahiroid/contriever-coreml") from transformers import AutoTokenizer tok = AutoTokenizer.from_pretrained(path, use_fast=True) enc = tok("Thank you so much!", return_tensors="np", padding="max_length", truncation=True, max_length=128) model = ct.models.MLModel(path + "/model.mlpackage") output = model.predict(dict(input_ids=enc["input_ids"].astype(np.int32), attention_mask=enc["attention_mask"].astype(np.int32)))["output"] print(output.shape) ``` ## Numerical validation Compared against the original PyTorch implementation, 6 deterministic cases. Maximum absolute output difference: **3.5017729e-07**; minimum cosine similarity: **0.99999993**. See `validation.json` for each case. These are conversion parity checks, not a full task-quality benchmark or latency benchmark. Text tests cover English emotions, neutral retrieval text, Japanese, empty input and truncation. Chronos tests cover a trend plus sinusoid, a constant series and a series with missing observations. Only applicable tests are used for each model. Core ML/Core AI text exports use batch 1 and sequence length 128; tokenization must pad/truncate to 128. Chronos Apple exports use batch 1 and context length 2048. MLX/custom GGUF preserve the original maximum context rather than adding training. Short Chronos inputs can be left-padded with NaN for the fixed Apple exports. Forecast horizon remains 64. ## Reproducibility Source revision and output semantics: `provenance.json`. Conversion scripts are included. Reproduce in a checkout with `sources//`, `sources.json` and `publish/` directories as in the scripts. PyTorch 2.14.1; Transformers 4.57.3; MLX 0.32.4; NumPy 1.26.4 (MLX/Core ML environment); coremltools 9.0; chronos-forecasting 2.3.2; GGUF 0.19.0; Core AI export uses coreai-torch 0.4.3. Core AI validation uses its separate Python 3.14 environment. Version compatibility outside the tested environment is not guaranteed. ## License Weights remain under **cc-by-nc-4.0**, with upstream terms in `LICENSE`. Non-commercial use only under the original CC BY-NC 4.0 terms. Converter/runtime additions are MIT licensed (`CODE_LICENSE`). No new task training, safety certification or commercial license is implied. ## Other formats - [mlx](https://huggingface.co/masahiroid/contriever-mlx) - [coreml](https://huggingface.co/masahiroid/contriever-coreml) - [coreai](https://huggingface.co/masahiroid/contriever-coreai) - [gguf](https://huggingface.co/masahiroid/contriever-gguf)