Update model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- coreml
|
| 5 |
+
- sentence-transformers
|
| 6 |
+
- embedding
|
| 7 |
+
- code
|
| 8 |
+
- roberta
|
| 9 |
+
base_model: microsoft/codebert-base
|
| 10 |
+
library_name: coremltools
|
| 11 |
+
pipeline_tag: feature-extraction
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# codebert-base — CoreML (.mlpackage)
|
| 15 |
+
|
| 16 |
+
CoreML conversion of [microsoft/codebert-base](https://huggingface.co/microsoft/codebert-base) for native Apple Neural Engine / GPU inference on macOS and iOS.
|
| 17 |
+
|
| 18 |
+
## Files
|
| 19 |
+
|
| 20 |
+
| File | Description |
|
| 21 |
+
|------|-------------|
|
| 22 |
+
| `model.mlpackage/` | CoreML model (FP16, flexible shapes) |
|
| 23 |
+
| `tokenizer.json` | HF fast tokenizer |
|
| 24 |
+
|
| 25 |
+
## Details
|
| 26 |
+
|
| 27 |
+
- **Architecture**: RoBERTa (encoder-only, no token_type_ids)
|
| 28 |
+
- **Precision**: FP16 (native ANE precision)
|
| 29 |
+
- **Compute units**: `.all` — CoreML schedules across ANE, GPU, and CPU
|
| 30 |
+
- **Input shapes**: batch=1..512, seq_len=1..512 (flexible range)
|
| 31 |
+
- **Embedding dimension**: 768
|
| 32 |
+
|
| 33 |
+
## Usage with cai
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
cai index --embed-backend swift --embed-model "rsvalerio/codebert-base-coreml"
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
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.
|
| 40 |
+
|
| 41 |
+
## Conversion
|
| 42 |
+
|
| 43 |
+
Converted using [rsvalerio/models](https://github.com/rsvalerio/models) CI pipeline with `coremltools`.
|
| 44 |
+
|
| 45 |
+
```bash
|
| 46 |
+
pip install coremltools transformers torch
|
| 47 |
+
python convert.py
|
| 48 |
+
```
|