Repository navigation
serve: select embedding prefixes with prompt_name - #414
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No proven behavior or quality defect was found in the changed code.
Checked
Duplicates: 17 new functions and constants checked; no duplicate owner found. Dryer reported zero pairs. Card fetching and front-matter parsing reuse existing owners.
Complexity: sentence_prompts new → 18, source selection and optional HF/base lookup before the existing JSON parser; answer 20 → 27, request validation at the shared HTTP owner; Flags::read 27 → 28, error propagation from one startup call.
Silent failure: 7 default/absence sites followed. Missing optional metadata produces no prompt names; selecting an absent name returns 400. Malformed configs and other fetch/read errors refuse startup. Invalid batch elements and context overflow are rejected before any embedding pass.
Tests: Static mutation inspection covered all 7 added or changed tests. Local startup: crates/gpu-gates/src/model_file.rs:254, discard parsing errors → malformed-file assertion fails. Optional-file classification: crates/gpu-gates/src/model_file.rs:270, drop the offline arm → wrapped-error assertion fails. Restart harness: crates/gpu-gates/src/model_file.rs:223 and the guards at 231/279, restore direct-only missing-file matching → offline restart fails. Prefix parser: crates/hf/src/sentence_transformers.rs:16, trim prefix values → byte assertions fail. Card parser: crates/hf/src/card.rs:16, require a quantized relation → relation-free base assertion fails. HTTP prompts: crates/serve/src/embeddings.rs:144, omit the prefix → recorded-token assertion fails. Discovery: crates/serve/src/api.rs:1822, omit prompt_names → exact metadata assertion fails.
Gates: No band, tolerance, lint or existing case removed or relaxed. The serve recipe adds the restart regression. The PR reports FAIL-first for all three missing-file guards.
Escape catalog: C1–C4 do not match the changed recipe or the fixture's shell script.
Adversarial checks: Offline fallback preserves cached prompts; malformed metadata refuses startup; a mixed batch runs no pass; empty batches and prefixed context overflow are rejected. Concurrent requests read an immutable prompt map.
Notes
Dryer excluded gpu-gates; its changed owners were checked manually. Review was static; builds and tests were not run.
GPU comparison summaries lack the required just gate-* commands with output and complete base/head evidence.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/model_file.rs, crates/gpu-gates/src/side_seat.rs, crates/gpu-gates/tests/sentence_prompts.rs and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
Part of #59 (plan and PR order in #190), follow-up 4: named query and document prefixes.
What and why
prompt_nameselects a prefix from the embedding model'sconfig_sentence_transformers.json. Both/v1/embeddingsand/embeddingapply the prefix before tokenization, using the names and bytes from the config. Requests withoutprompt_namekeep their input unchanged.The existing model-file owner reads the config once at startup, beside a local embedding model or from its HF repository. If the repository has no config, its model card's single
base_modelsupplies it. The same lookup works from verified cached files underHF_HUB_OFFLINEor during a network outage. If neither config can be found, lookup leaves no named prefixes; malformed files still refuse startup. The embedding model's/v1/modelsmetadata listsprompt_names.Unknown names and non-string names return OpenAI-shaped 400 errors. Named prompts accept text strings and batches of strings. Token IDs and media inputs remain available without
prompt_name.Release notes: Added: Select embedding query and document prefixes with
prompt_name.Code shape
cargo fmtandcargo clippy: formatting applied; static review is pending.Duplication found or removed: the existing model-card fetch and front-matter parser now serve both callers.
What I ran
RUSTFLAGS=-Ctarget-cpu=native cargo test -p bloomery-gpu-gates --test sentence_prompts -- --nocapturepassed all 20 startup combinations at3a8c3ef3. The restart regression first resolves a GGUF and its prompt metadata online, then repeats startup with the cache, withHF_HUB_OFFLINE=1and with an unreachable hub. It covers a repo's own config, a base-model config, a missing card, a missing base config and malformed config JSON. Restoring each of the three original missing-file guards made its offline restart fail withOffline { cache: NoFile }.RUSTFLAGS=-Ctarget-cpu=native cargo test -p bloomery-gpu-gates --lib model_file::tests -- --nocapturepassed all 3 unit tests on the same head.just check-leversalso passed. The restart harness uses child processes and directory fixtures, with no new environment reads or allow-list entries.The earlier host suite at
a660c8aapassed 63 HF tests, 10 embedding API tests and 2 model-file tests. The config fallback changes leave HF parsing and HTTP prompt handling unchanged.Both card comparisons ran on
4a7d1e00and are carried to3a8c3ef3: the fix changes startup handling of missing optional files, with no change to prefix application, tokenization or the encoder. The restart harness adds no production code. Each buildsbloomery-servethroughcargo oxidewithglm5next,clef,mimo2,gemma-embedding2(sm_121 on GB10, sm_86 on RTX 5090). A sentence-transformers 6.1.0 capture module records the text passed byencode(prompt_name=...), without loading its model weights. The HTTP comparison checks each configured prompt, plus empty text, Unicode and whitespace cases forqueryanddocument.The named and manually prefixed requests to the same Bloomery binary produced identical vectors on both HTTP routes. Bloomery and llama-server ran sequentially on each card, using mainline llama.cpp
6868a52cb337450658006ad2f9281c2eb63f1666with manually prefixed input. The last column reports the minimum cosine against that reference.Across both cards and both models, prompt selection added 0 byte mismatches against sentence-transformers and 0 vector mismatches against manually prefixed Bloomery input (92 cases total).
Hardware: NVIDIA GB10, driver 595.84; NVIDIA GeForce RTX 5090, driver 595.99.02. Both embedding models used Q8_0. The EmbeddingGemma 2 config is pinned at
914f7f89142e33e77833254d9c9b90c3cef7303b; the v1 config is pinned at57c266a740f537b4dc058e1b0cda161fd15afa75.Reproduce
Place the model's
config_sentence_transformers.jsonbeside the embedding GGUF, then start the server with--embd-model FILEas described indocs/serving.md.What I ran into
These metadata details do not block the PR. The GGUF repositories' model cards name a base model without requiring
base_model_relation: quantized. Prefix lookup follows that single base model, while the decision-head reader keeps its existing quantized-only rule.The v1 config's Google download requires authorization. The comparison used the public
unsloth/embeddinggemma-300mcopy atbfa3c846ac738e62aa61806ef9112d34acb1dc5a, whose Git blob SHA-1 matches Google's published file entry (3552ab1b79dc8571d0ecf200db12e5208eda5bdd).AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.