feat(embed): embed CLI with download-only and JSON event output#199
Merged
Conversation
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>
E2E Parity ReportPASS: all 3 prompts match within first 3 tokens
print(fib
print(fib |
--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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
New
embedCLI 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-onlyemits a@@latticedownload-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 binarycrates/embed/src/service/native.rs— addsNativeEmbeddingService::ensure_loaded(load-only path, no encode)crates/embed/Cargo.toml(+5:[[bin]]withrequired-features = ["native"])Fix (codex round-1)
--download-onlypreviously calledservice.embed(&["warmup"], model), running a fullencode_batchafter load. It now callsensure_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 embedclean.cargo clippy -p lattice-embed --bin embed -- -D warningsclean.cargo test -p lattice-embed --libgreen. 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.