Skip to content

Commit 3d72e2a

Browse files
feat(search): make the embedding model configurable (#83)
Co-authored-by: Harlan Wilton <harlan@harlanzw.com>
1 parent 5fb4132 commit 3d72e2a

13 files changed

Lines changed: 698 additions & 81 deletions

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,59 @@ Generation runs locally: free, offline, no API key. Unlike the CLI and API backe
239239

240240
The large default context can exceed memory for big models on constrained hardware (Ollama returns a 500). Lower `OLLAMA_NUM_CTX` or pick a smaller model if generation fails to load.
241241

242+
### Embedding Model
243+
244+
`skilld search` uses a local embedding model. It runs offline through transformers.js. It needs no API key or network after the first download. Pick one under **Embedding model** in `skilld config`:
245+
246+
| Model | Dimensions | Notes |
247+
|-------|-----------:|-------|
248+
| `bge-small-en-v1.5` | 384 | Default. Fastest to index, smallest download. |
249+
| `bge-base-en-v1.5` | 768 | Balanced accuracy and speed. |
250+
| `bge-m3` | 1024 | Multilingual, 8192-token context. |
251+
252+
Larger models retrieve more accurately but cost more time and memory when indexing. Set `SKILLD_EMBED_MODEL` to override the saved setting:
253+
254+
```bash
255+
export SKILLD_EMBED_MODEL=bge-m3
256+
skilld update --force
257+
```
258+
259+
Each search index belongs to one model and device. Keep environment overrides set for both indexing and querying. Rebuild indexes after either setting changes:
260+
261+
```bash
262+
skilld update --force
263+
```
264+
265+
### Embedding Device
266+
267+
The embedding model runs on the CPU by default. **Embedding device** in `skilld config` moves it onto a GPU backend, which can be substantially faster:
268+
269+
| Device | Notes |
270+
|--------|-------|
271+
| `auto` | Default. Lets transformers.js choose, CPU under Node. |
272+
| `cpu` | Always available, predictable. |
273+
| `webgpu` | Fastest on Apple Silicon in testing. |
274+
| `coreml` | Apple Neural Engine. Measured slower than CPU for these models. |
275+
276+
Measured on an Apple M5 Max, 120 documents, best of 3 after warm-up (docs/sec):
277+
278+
| Model | `cpu` | `coreml` | `webgpu` |
279+
|-------|------:|---------:|---------:|
280+
| `bge-small-en-v1.5` | 664 | 198 | **1713** |
281+
| `bge-base-en-v1.5` | 198 | 68 | **580** |
282+
| `Xenova/bge-large-en-v1.5` | 71 | 9 | **201** |
283+
284+
WebGPU was 2.6 to 2.9 times faster than CPU at every size. `bge-large` on WebGPU indexed faster than `bge-base` on CPU. CoreML was consistently slower.
285+
286+
The ranking is hardware-specific, so benchmark before trusting a device on other machines. Set `SKILLD_EMBED_DEVICE` to override the saved setting:
287+
288+
```bash
289+
export SKILLD_EMBED_DEVICE=cpu
290+
skilld update --force
291+
```
292+
293+
If a backend is unavailable, indexing fails to start. Switch back to `auto`.
294+
242295
### Eject
243296

244297
Export a skill as a portable, self-contained directory for sharing via git repos:

pnpm-lock.yaml

Lines changed: 17 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ catalogMode: prefer
22
minimumReleaseAgeExclude:
33
- verkit@0.2.0
44
- '@mdream/rust-wasm32-wasi@1.5.12'
5+
- retriv@0.15.0
56
shellEmulator: true
67

78
trustPolicy: no-downgrade
@@ -23,7 +24,7 @@ catalog:
2324
ofetch: ^1.5.1
2425
pathe: ^2.0.3
2526
publint: ^0.3.23
26-
retriv: ^0.14.7
27+
retriv: ^0.15.0
2728
std-env: ^4.2.0
2829
tsx: ^4.23.8
2930
typebox: ^1.3.10

0 commit comments

Comments
 (0)