Documentation
¶
Overview ¶
Package main is a minimal demonstration of the battery/embed package.
What it does:
- Opens an in-process embed.Index with the dependency-free stub embedder and the in-process embed.MemoryKeyword backend.
- Indexes a handful of seed documents so a fresh run is already queryable.
- Registers embed.Plugin on a framework.App so the standard /embed/index, /embed/query, /embed/stats, and /embed/doc/{id} routes are auto-mounted.
Run with:
go run ./examples/embed-demo
Then exercise the API:
curl 'http://localhost:8086/embed/stats'
curl -X POST 'http://localhost:8086/embed/query' \
-H 'content-type: application/json' \
-d '{"text":"cache battery","k":3,"hybrid":true}'
curl -X POST 'http://localhost:8086/embed/index' \
-H 'content-type: application/json' \
-d '{"documents":[{"id":"new","text":"my new doc"}]}'
The example uses the stub embedder, so retrieval is keyword-strong and semantic-weak. Swap in the ONNX embedder (M1.5) for real semantic similarity.
Click to show internal directories.
Click to hide internal directories.