embed-demo

command
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package main is a minimal demonstration of the battery/embed package.

What it does:

  1. Opens an in-process embed.Index with the dependency-free stub embedder and the in-process embed.MemoryKeyword backend.
  2. Indexes a handful of seed documents so a fresh run is already queryable.
  3. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL