File size: 1,371 Bytes
1825eb0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
license: apache-2.0
tags:
  - coreml
  - sentence-transformers
  - embedding
  - nomic
  - code
base_model: nomic-ai/nomic-embed-code
library_name: coremltools
pipeline_tag: feature-extraction
---

# nomic-embed-code — CoreML (.mlpackage)

CoreML conversion of [nomic-ai/nomic-embed-code](https://huggingface.co/nomic-ai/nomic-embed-code) for native Apple Neural Engine / GPU inference on macOS and iOS.

## Files

| File | Description |
|------|-------------|
| `model.mlpackage/` | CoreML model (FP16, flexible shapes) |
| `tokenizer.json` | HF fast tokenizer |
| `config.json` | Model configuration |

## Details

- **Architecture**: NomicBERT (RoPE, SwiGLU, no token_type_ids)
- **Precision**: FP16 (native ANE precision)
- **Compute units**: `.all` — CoreML schedules across ANE, GPU, and CPU
- **Input shapes**: batch=1, seq_len=1..8192 (flexible range)
- **Embedding dimension**: 768

## Usage with cai

```bash
cai index --embed-backend swift --embed-model "rsvalerio/nomic-embed-code-coreml"
```

The Swift backend downloads the `.mlpackage` from this repo, compiles it to `.mlmodelc` on first run (~30-60s), and caches the compiled model for subsequent runs.

## Conversion

Converted using [rsvalerio/models](https://github.com/rsvalerio/models) CI pipeline with `coremltools`.

```bash
pip install coremltools transformers torch
python convert.py
```