Skip to content

feat(embed): embed CLI with download-only and JSON event output#199

Merged
ohdearquant merged 3 commits into
mainfrom
pr/eng-3-embed-download
Jun 22, 2026
Merged

feat(embed): embed CLI with download-only and JSON event output#199
ohdearquant merged 3 commits into
mainfrom
pr/eng-3-embed-download

Conversation

@ohdearquant

@ohdearquant ohdearquant commented Jun 22, 2026

Copy link
Copy Markdown
Owner

What

New embed CLI for the embeddings surface: --download-only, --json, --model, --text, --help.

Why

Lattice Studio's Embeddings screen needs a binary to fetch a model and produce embeddings. --download-only emits a @@lattice download-done event the app parses for progress. Genuinely new on main (the binary did not exist before).

Files

  • crates/embed/src/bin/embed.rs (+201) — the CLI binary
  • crates/embed/src/service/native.rs — adds NativeEmbeddingService::ensure_loaded (load-only path, no encode)
  • crates/embed/Cargo.toml (+5: [[bin]] with required-features = ["native"])

Fix (codex round-1)

--download-only previously called service.embed(&["warmup"], model), running a full encode_batch after load. It now calls ensure_loaded(), which drives the same download + model-load path and returns without encoding — so the flag truly stops at load. Error handling and the JSON success event are unchanged; the embedding numeric path (SIMD / int8 / normalize / encode) is untouched, so the PR stays bench-neutral and the leaf-crate dependency direction (embed → inference) is intact.

Verification

cargo build --release -p lattice-embed --bin embed clean. cargo clippy -p lattice-embed --bin embed -- -D warnings clean. cargo test -p lattice-embed --lib green. Built in the integrated-tree gate (scripts/build-app-bins.sh). Codex round-2: APPROVE-WITH-SUGGESTIONS.

Bench

New binary; no existing library hot path modified. make bench-compare's comparator errored assembling the delta (known two-worktree fragility; base benches ran clean) — bench-neutral by construction, as the changed code is off every Criterion-measured path.

Series

Part of the PR #193 engine-slice (finest split). All engine code lands on main; the macOS app surfaces a subset (Models + Chat) for v0.0.1.

Add the embed binary (gated required-features = native), used by Lattice Studio.
The --download-only flag fetches an embedding model and emits an @@lattice
download_done event consumed by the Models "Get Models" surface.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

E2E Parity Report

PASS: all 3 prompts match within first 3 tokens

Prompt Agreement First Diff HF tok/s Lattice tok/s Verdict
The capital of France is 3/15 pos 3 0.4 2.6 PASS
In the year 2024, artificial intelligence 10/15 pos 9 0.4 2.2 PASS
`def fibonacci(n):
if n <= 1:
    return n
return` | 15/15 | none | 0.4 | 1.9 | PASS |

The capital of France is

  • HF: Paris.
    The capital of France is Paris.
    The capital of France
  • Lattice: Paris.
    A: Yes, the capital of France is Paris.

In the year 2024, artificial intelligence

  • HF: (AI) has become a significant part of the global economy. It is
  • Lattice: (AI) has become a significant part of our daily lives. From personal

def fibonacci(n): if n <= 1: return n return

  • HF: fibonacci(n-1) + fibonacci(n-2)

print(fib

  • Lattice: fibonacci(n-1) + fibonacci(n-2)

print(fib

ohdearquant and others added 2 commits June 22, 2026 15:37
--download-only exists to fetch + checksum-verify + load a model without
running inference, but it called service.embed(&["warmup"], model), which
runs a full encode_batch after the load. Add NativeEmbeddingService::
ensure_loaded — it drives the same download + model-load path embed() does
and returns without encoding — and call it from the download-only branch.
The flag now stops at load, saving a forward pass; error handling and the
JSON success event are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ohdearquant ohdearquant enabled auto-merge (squash) June 22, 2026 23:21
@ohdearquant ohdearquant merged commit b914270 into main Jun 22, 2026
10 checks passed
@ohdearquant ohdearquant deleted the pr/eng-3-embed-download branch June 22, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant