Project

emb

0.0
The project is in a healthy, maintained state
Client for emb: a Redis-compatible embedding server
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme
emb — bytes in. vectors out.

An inference server for embedding with scripting.

GitHub Release Docker Hub emb gem emb-server gem

Quick start

curl -fsSL https://github.com/elcuervo/emb/raw/main/install.sh | sh

# Download a model from HuggingFace and serve on :6379
emb -model-repo Xenova/all-MiniLM-L6-v2

With no -model flag, the model is named model. In another terminal:

redis-cli EMB.READY
# OK

redis-cli EMB.MODELS
# 1) 1) "model"  2) (integer) 384  3) "ready"

redis-cli EMB model "hello world"
# raw float32 bytes: 384 values x 4 bytes

redis-cli -3 EMB model VALUES "hello world"
# dtype FLOAT / shape [1 384] / values [-0.1974, 0.1776, ...]

BLOB is the default reply: little-endian float32 bytes in a bulk string. VALUES asks for a self-describing decimal envelope instead. HELLO 3 (or redis-cli -3) types the numbers as doubles; VALUES works under RESP2 too.

Password and a named model:

emb -model minilm -model-repo Xenova/all-MiniLM-L6-v2 -password "hunter2"
redis-cli -a hunter2 EMB minilm "hello world"

Ruby, Python and Go recipes are in Clients.

What it does

  • Text embeddings — EMB / EMB.MULTI, batched when the graph is batch-deterministic (1 ms window, 32 rows, 16384 tokens by default; a dynamic-quantized int8 graph falls back to one-row runs). An in-process cache exists but is off unless configured.
  • Image embeddings — EMB.IMG / EMB.IMGMULTI take raw JPEG, PNG, GIF or WebP bytes, preprocess them server-side, and reply with a map keyed by output name, so one model can serve a pooled vector and a patch grid from one inference. Image models.
  • Scripted decisions — EMB.EVAL / EMB.EVSHA run sandboxed Lua around the same inference call: pooling, similarity, or a full decision loop. The Laya presets answer typed questions in one forward pass. Scripting.
  • Redis-native operations — INFO, CONFIG GET/SET, EMB.READY, EMB.STATS, MONITOR, and Redis shutdown semantics. The same tarball carries emb-top (terminal dashboard), emb-stress (fleet load) and emb-sidekick (read-only web monitor).
  • Any client — RESP2 by default, RESP3 via HELLO 3; the reply is ordinary RESP, so no SDK sits between you and the model.

Configuration is YAML via -config or the same settings as flags. Model names come from the YAML key or -model; model_repo downloads, onnx + tokenizer mount local files, and image: / scripts: enable those paths:

listen: ":6379"
models:
  minilm:
    model_repo: Xenova/all-MiniLM-L6-v2

See Configuration for batching, cache, snapshots, CPU budget, limits and every model option.

Commands

Family Commands
Embed EMB, EMB.MULTI
Images EMB.IMG, EMB.IMGMULTI
Inspect EMB.MODELS, EMB.INFO, EMB.STATS, MONITOR, EMB.READY
Script EMB.EVAL, EMB.EVSHA, EMB.SCRIPT
Admin INFO, CONFIG, EMB.CACHE.FLUSH, EMB.SAVE, EMB.HELP, SHUTDOWN, AUTH, HELLO, PING, CLIENT

Grammar, reply formats, image options and RESP3 differences are in Commands; the machine-readable contract is commands.json.

Operations

EMB.READY answers +OK or a reason (loading, draining, no models). EMB.STATS and MONITOR cover capacity and recent requests; emb-top reads them for one node or a DNS-discovered fleet, emb-stress drives that fleet, and emb-sidekick serves a sampled read-only view at http://127.0.0.1:8080:

emb-sidekick -node 127.0.0.1:6379

Shutdown follows Redis: SHUTDOWN blocks its caller and replies nothing; SHUTDOWN ABORT releases blocked callers. The default grace is 0, so clients stop immediately; without a password only loopback clients may call it. Details in Operations and Configuration.

Laya decision models

Laya is a multilingual, non-autoregressive decision engine: typed choice / score / noul decisions over any state in one forward pass, with calibrated probabilities. Serve one of its ONNX checkpoints as a scripted model:

models:
  laya:
    model_repo: codenamev/laya-onnx
    model_subfolder: english
    script_preload: true
    scripts:
      - path: ./scripts/laya.lua
        config: {max_len: 512, head_max_len: 192}
EMBSHA=$(redis-cli EMB.SCRIPT LOAD laya "$(cat scripts/laya.lua)")
redis-cli EMB.EVSHA laya "$EMBSHA" 1 '"hello"' \
  '{"department": {"type": "choice", "instructions": "which team", "criteria": {"billing": "invoices", "technical": "bugs", "other": null}}}'

Every question is answered in one pass; the reply carries one answer per question id and usage.input_tokens / usage.inference_ms. Checkpoint envelopes, int8 mounting, language routing, the wire contract and two decision loops are in Laya decision models.

Install options

The installer defaults to /usr/local/bin; point it elsewhere with EMB_INSTALL_DIR (and use sudo when the target is root-owned):

curl -fsSL https://github.com/elcuervo/emb/raw/main/install.sh | EMB_INSTALL_DIR=~/.local/bin sh

It verifies the release's SHA256SUMS manifest before extraction and refuses a release that has none; EMB_SKIP_VERIFY=1 opts out. Release tarballs bundle ONNX Runtime beside the binary. For a system install, pass -ort-lib /path/to/lib, or set LD_LIBRARY_PATH (Linux) / DYLD_LIBRARY_PATH (macOS).

Docker needs a mounted config — the image entrypoint is emb -config /etc/emb/config.yaml and that file has no models:

docker run -v ./models:/models elcuervo/emb -config /models/config.yaml

The emb gem is the Ruby client; the emb-server gem ships the server binaries (emb, emb-top, emb-stress). emb-sidekick comes from the release archive or just build.

Development

Everything runs inside the Nix dev shell, which provides Go, ONNX Runtime, golangci-lint and the CGo configuration:

nix develop
just format          # gofmt + goimports
just lint            # golangci-lint + go vet
just test            # Run tests
just build           # emb, emb-top, emb-stress, emb-sidekick
just dev             # Build and run the server
just download-model  # Download a model from HuggingFace

Model download, coverage gate, verification harness and CI rules are in Testing; measured numbers and their provenance are in BENCHMARK.md and Performance validation.

Documentation

Document What's in it
Commands Every command, BLOB / VALUES, RESP3, image replies
Configuration Config file, model options, images, batching, cache, CPU budget
Image models The DINOv3 catalog, ONNX dialects, named outputs, presets
Scripting Lua EMB.EVAL / EMB.EVSHA surface and examples
Operations Health, limits, observability, emb-top, emb-sidekick, load testing
Clients Ruby, Python and Go recipes
Laya decision models Checkpoints, mounting, wire contract, decision loops
The DNS zone dns.emb.is: emoji query grammar, TXT replies, deployment
Testing Coverage gate, harness, fixtures, CI contract
BENCHMARK.md Measured throughput and latency, reproduction steps
examples/scripts/ Maintained and illustrative Lua scripts
gems/emb · gems/emb-server Ruby client and server distribution
Website · CHANGELOG.md Product site and release notes

License

MIT — see LICENSE.