Repository navigation
Studio: embedding model picker searches the Hub and downloads what you pick - #9739
Conversation
…u pick Settings -> Documents & RAG used a text combobox. It searched Hugging Face, but selecting a model only wrote a string into a field: the PUT verified the repo and saved it, then the weights were fetched lazily and invisibly at the first index. Picking a model you did not have looked like nothing happened. Backend: new GET /api/settings/embedding-model/resolve answers what saving a model would need fetched and whether it is already here. It composes what was already there rather than inventing rules: gguf_repo_for_embedding_model for the companion repo, LlamaServerBackend._resolve_cached_gguf for the offline cache check, _pick_gguf for which .gguf, and _hf_gguf_backend_error for the failure text, so resolve and save cannot disagree about what is usable. The HF token rides the X-Unsloth-HF-Token header rather than a query parameter. Frontend: embedding-model-picker.tsx replaces the combobox, built the same way as the dictation picker in voice-tab.tsx. Button trigger, one search field placeheld "Search any model on HF", unsloth's own embedders on the empty query and the whole Hub once you type, sizes on the right, a Recommended pill on the default and the Hub's green on-device dot for models already cached. Selecting applies immediately, as dictation does, so the Save button is gone. A model that is not on disk raises a confirm dialog with its name and size, and the transfer then runs through downloadManager.requestStart, the same call the Hub's own download cards make, so progress, cancel and Xet/HTTP transport all come from the shared panel. It fetches only the one .gguf the embedder opens, not every quant in the companion repo. Reset to default, the re-index warning and the forceable "Save anyway" path are unchanged. 409 and 403 keep their existing meanings.
|
Pushed a fix for this. Testing the branch surfaced that the picker still refused most models with "No GGUF weights found in '...-GGUF' or '...'", so the download was never offered. The name guess was the problem. Only 2 of unsloth's 14 embedders publish a same-owner GGUF, so
On a llama-server install, which is the macOS and CPU default, that meant most picks hit a 409 instead of a download. Candidate derivation is now shared. When no candidate has a GGUF, resolve asks the Hub for a conversion of the same model rather than giving up. Only repos whose name starts with the model's own name qualify, so it cannot wander onto an unrelated model. Checked against the unsloth embedder list: 10 of 10 resolve now, against 4 before. The resolved repo is stored alongside the model. A conversion under another owner follows no naming rule, so The picker resolves before it saves, so the download is offered instead of the save being attempted and refused, and the confirm dialog names the repo it will pull from, since that is often a different owner. Tests: 9 resolve cases including the Hub fallback, the stale-pair guard and the stored-repo round trip. 213 backend tests and 5144 frontend tests pass, typecheck and build clean. |
…g its name
Reported after testing the picker: selecting a model you have not downloaded
still showed "No GGUF weights found in ... -GGUF or ...", instead of downloading
anything.
The name guess was the problem. Only two of unsloth's fourteen embedders publish
a same-owner GGUF, so `{model}-GGUF` misses almost everything:
unsloth/embeddinggemma-300m-qat-q8_0-unquantized -> no -GGUF repo exists,
but unsloth/embeddinggemma-300m-GGUF does
unsloth/Qwen3-Embedding-4B -> no -GGUF repo exists,
but Qwen/Qwen3-Embedding-4B-GGUF does
On a llama-server install (the macOS and CPU default) that meant most picks hit
a 409 rather than a download, which is exactly what was reported.
Three changes:
Candidates now live in one place, config.gguf_repo_candidates, used by the
loader, the resolve endpoint and the save check so they cannot disagree. It adds
the base name with unsloth's unquantized suffixes stripped, which is what fixes
the embeddinggemma variants.
When no candidate has a GGUF, the resolve endpoint asks the Hub for a conversion
of the same model instead of giving up. Only repos whose name starts with the
model's own name qualify, so it cannot wander onto an unrelated model. All ten
unsloth embedders resolve with this, against four before.
A conversion under another owner follows no naming rule, so the repo the resolve
picked is stored alongside the model and effective_gguf_repo returns it. The
loader then opens exactly what was downloaded, with no searching on its path.
The pair is only honoured for the model it was recorded for, so a stale entry
can never point the loader at the wrong weights.
The picker now resolves before it saves, so the download is offered rather than
the save being attempted and refused, and the confirm dialog names the repo it
will download from since that is often a different owner.
…er GGUFs only Three fixes from testing the picker. Dictation reported a download twice. Voice settings drew its own progress bar and Cancel next to the shared downloads panel, which was already showing the same transfer. The settings copy is gone; the status line still names the state, and cancelling belongs to the panel row. Its rate estimator went with it, so there is one estimator again instead of two. The embedding confirm dialog is gone. A modal for a one-click action was noise, so the row now works like dictation: a status line saying whether the model is on device, downloading, or not downloaded with its size, and an action button beside it. Reset to default is replaced by Download or Unload, matching voice; the default model is still one pick away in the list. The button reads the shared download manager, so a transfer started anywhere disables it. Unload needed somewhere to go, so embeddings.release_backend drops the embedder and stops its llama-server, exposed as POST /embedding-model/unload with a loaded flag on the settings response. Safe mid-index: the next embed rebuilds, and the llama backend's POST retry already covers a server that went away. GGUF conversions are now restricted to the model's own owner. The search fallback took the most-downloaded match by name, so picking unsloth/X could pull a third party's re-upload. A repo name is not proof of provenance, so an unsloth/ pick only downloads from unsloth, and the search is scoped by author rather than filtered afterwards. Picking a publisher's own model still resolves its own GGUF.
|
Pushed three more fixes from testing. Dictation reported the same download twiceVoice settings drew its own progress bar and Cancel right next to the shared downloads panel, which was already showing that exact transfer. Removed the settings copy. The status line still names the state, and cancelling belongs to the panel row. Its private rate estimator went with it, so there is one estimator again instead of two computing the same number. The embedding confirm dialog is goneA modal for a one-click action was noise. The row now works the way dictation does: a status line saying whether the model is on device, downloading, or not downloaded with its size, and an action button beside it.
Unload needed somewhere to go, so GGUF conversions are restricted to the model's own ownerThis one was a real problem with the previous commit. The search fallback took the most-downloaded name match, so picking The search is now scoped by
Picking a publisher's own model still resolves that publisher's own GGUF, so the models that genuinely have one are unaffected. The trade is that a few unsloth embedders with no unsloth GGUF cannot be downloaded on a llama-server install. With the inline row that now reads as an empty action slot and a plain status line rather than a wall of red text, and Tests: 121 backend tests in the embedding and RAG suites, 5148 frontend tests, typecheck and build clean. The 12 unrelated failures elsewhere in the backend suite are present on |
…th GGUF Embedding models do not need GGUF. Safetensors load fine on sentence-transformers, for about 1 GB more memory, so an embedder whose publisher never shipped a GGUF should run on its own weights rather than be refused or quietly pulled from a stranger's conversion. The resolve endpoint now tries the GGUF candidates and the same-owner Hub search first, and only then the model's own safetensors. The chosen backend is persisted with the model and honoured by auto backend selection, so a safetensors-only model is never handed to llama-server, which would have nothing to open. A GGUF-only install (no torch) is not offered the fallback and still reports the original reason. The runtime ST-to-llama fallback now pins its choice, so a saved model that asks for sentence-transformers cannot walk the process back into the encoder that just failed. An unload clears the pin. Resolved against the Hub: bge-small-en-v1.5 and embeddinggemma-300m take the unsloth GGUF; Qwen3-Embedding-8B, gte-modernbert-base and snowflake-arctic-embed-l-v2.0 take unsloth safetensors. No third-party repo is used as a source in either path.
|
Follow-up pushed: an embedder with no unsloth GGUF now falls back to its own safetensors instead of being refused. Embedding models do not need GGUF. Safetensors load fine on sentence-transformers, at roughly 1 GB more memory, so the picker now tries the GGUF candidates and the same-owner Hub search first, and only then the model's own weights. The chosen backend is stored with the model and honoured by auto backend selection, so a safetensors-only model is never handed to llama-server. A GGUF-only install (no torch) is not offered the fallback and still reports the original reason. Resolved against the Hub:
Neither path uses a third-party repo as a source. Also in this commit: the runtime sentence-transformers to llama-server fallback now pins its choice, so a saved model asking for sentence-transformers cannot walk the process back into the encoder that just failed. An unload clears the pin. Frontend: 5154 tests pass, tsc clean. Backend: the embedding, RAG and security-gate suites pass, with the two pre-existing macOS/MLX failures in test_startup_defers_torch.py unchanged from the branch point. |
The row already says what is on disk and what it costs to fetch; the extra line explained an implementation detail the user did not choose.
|
Checked this against main, where gguf_repo_for_embedding_model still guesses one {model}-GGUF name, so the resolve endpoint and shared candidate derivation are a real improvement for Documents and RAG. The direction is right, but the branch also removes the dictation progress bar and rate estimator in voice settings and adds the embedder unload endpoint and backend pinning; could you split the voice-tab change out so this one stays the embedding picker? |
…normalized companion A pending transfer no longer makes the security scan think it is offline. local_only folded two questions together: load from cache without fetching, which a pending transfer also demands, and whether the Hub is reachable, which is what the gate needs. Told offline while online, it applies the fail-closed cached-pickle rule and rejects a .bin-only repo the resolver had just accepted and scanned online, so the first index after a successful download failed with a misleading offline-security error. The load still stays cache-only; only the gate now sees the real network state. The picker's on-device dot mirrors the backend's quant-suffix normalization. An unquantized re-upload resolves its GGUF on the base name, so unsloth/embeddinggemma-300m-qat-q8_0-unquantized is served from unsloth/embeddinggemma-300m-GGUF and the dot never lit up however complete the download was. The added pattern uses no lookbehind: this build target ships regex verbatim, so anything Safari 16 cannot parse would break the bundle.
… cache entry hiding a good one Three fixes. The pending marker was cleared before the SentenceTransformer constructor ran. A snapshot can be complete while the constructor still fails, on an unsupported architecture or a device that cannot initialize, and _build_st_backend_or_fallback then swaps to llama-server with no marker left to stop it fetching the GGUF companion during the first index. It is now retired only once the model is built. The resolver conjoined the generic loadable check with the alias-aware ST one. The generic one stops at the first matching cache directory, so a stale literal entry beside a complete sentence-transformers/ snapshot reported the model uncached, and offline the Hub probe could not rescue it: /resolve returned an error the loader would have disagreed with. The alias-aware predicate already pairs the ST file family with the loadable check per candidate, so it is now used on its own, and the llama-to-ST fallback asks it about the repo the plan named rather than the alias the user typed. The memo survives a reset so a job still pinned to a model keeps its artifact, but the restored default is not a running job: new work resolves through it too, and a process-only answer would change identity on the next restart, stranding whatever was indexed in between. A reset now writes any remembered resolution for the restored default back durably instead of leaving it memory-only.
…n a fallback quant Two ways a legitimately selected embedding model could never finish loading. A repo id that itself names GGUF weights was only recognized when it was a local path. On a host where auto resolves to sentence-transformers, a typed or API-selected owner/model-GGUF was therefore searched for safetensors, found to publish none, and could only be saved over that error, which sets the pending marker. The ST loader answers a pending model with "not downloaded" before the runtime fallback to llama-server can run, so the repo stayed unloadable however it was cached. The remote form now routes to llama-server the same way the local one does; the test is a pure name test, and a local directory that merely ends in -gguf is still resolved by looking at what it holds. A repo that publishes no RAG_EMBED_GGUF_VARIANT is downloaded as whatever quant it does publish, and the loader's variant-matching lookup cannot recognize that as the transfer it advertised, so it left the marker set: the model was cache-only for the life of the install and a later eviction was refused as "not downloaded" though the download had finished. The resolution record now carries the planned file family, and the relaxed lookup retires the marker when exactly that family lands. A quant left in the same repo by an earlier setting still does not, and a record written before the family was stored keeps the conservative answer. The conditional clear now compares against the record as read rather than a rebuilt one, so it keeps working on a record whose field set this build does not know about, which is what an existing install has.
… a missing binary Three ways a request could get an answer that belonged to something else. The resolve preflight took the model-load lock to order the torchao stub against the sentence-transformers import. _get holds that lock across an entire SentenceTransformer construction, download included, so opening or saving Settings during a first load blocked for as long as the load took, past every deadline the resolver applies to its own Hub calls. The stub keeps its ordering guarantee under a lock of its own, taken innermost. dim() ran readiness, the cache read and the width probe outside the lock the request path uses, while _dim belongs to whichever GGUF the one subprocess is serving. With two jobs pinned to models of different width, one could ready A, have the other switch to B and cache B's width, and then answer A with it. It now takes the same lock, which is reentrant for exactly this reason. A GGUF-named model routes to llama-server whatever the hardware says, because nothing else can open those weights, but that says nothing about whether the install can run that backend. Without a binary the plan was advertised as valid and the transfer persisted, and the first warm then failed in _resolve_binary with the download already done. The resolver now refuses it with a reason. Scoped to models only llama can serve: one that publishes safetensors still takes the sentence-transformers fallback, which is a usable plan rather than an error.
…ot select Four ways a request could be served weights other than the ones it named. A slashless model cached only under sentence-transformers/<name> was reported with the literal alias as its download repo, and the PUT verifies and scans whatever that names. Both therefore inspected a top-level repo that usually does not exist, rejecting with a 409 a cached model the loader would have opened. The resolver now keeps the candidate the cache hit came from, which is the same question it already asks when the answer comes from the Hub. A local path that shares its name with a cached Hub model was replaced by that snapshot, because the alias-aware cache lookup was asked about it at all. The picker takes a slashless relative directory, so a folder named all-MiniLM-L6-v2 beside a cached sentence-transformers copy indexed the Hub's weights while tagging the vectors with the local path's identity. A local path is the artifact the resolver accepted; it is no longer looked up. The planned GGUF family was compared by base name, so a repo that files each quant in its own directory (Q8_0/model.gguf beside Q4_K_M/model.gguf) let a stale quant pass for the planned one, retire the marker and pin the wrong weights. Compared by the path relative to the snapshot now, which is the layout the record already describes. warm() readied the server itself, outside the serving lock, so warming B could kill and respawn between an encode pinned to A passing its own readiness check and its POST. Readiness is left to dim(), which holds that lock across it.
A repo id ending in -GGUF was read as llama-server ahead of the record the picker wrote. The same repo can publish a torn or absent GGUF family and usable safetensors, in which case the resolver deliberately falls back to sentence-transformers and persists that plan; overruling it sent the first index down the GGUF pending path, to fail as "not downloaded" on a model whose weights had just been validated. The name test now runs below the stored record, so it decides only when nothing was validated, which is still the case a forced save over a failed plan leaves behind. The local .gguf check keeps its place above the record: that one asked the filesystem rather than guessing from a name, and a stored sentence-transformers record for a .gguf can only come from a force-save that then failed.
…t unload keep its place The alias-aware cache lookup reported which candidate supplied the weights, but took the snapshot from a lookup that tries the alias itself, so a slashless name came back paired with the literal id rather than the sentence-transformers one that actually held the files. That is the id the PUT verifies and security-scans, so a cached model was rejected with a 409 at a repo that usually does not exist. There is now an exact per-repo lookup for callers that have to say which repo answered, with the alias-trying one left for "is this cached at all". A local SentenceTransformer directory was accepted on any one matching filename. Half a shard family, or a module modules.json declares that the directory does not have, therefore read as ready and failed at the first index when ST opened it. The completeness test the Hub snapshot already gets is now shared, so a local copy of a model is judged the way the downloaded one is. Unloading went through the ordinary save, which takes a place in save order. That retired the reservation a selection still running its preflight on the other surface was holding, and the selection then returned without ever persisting the model. Unloading releases residency and leaves the selection alone, so it now applies its answer without claiming that order, and defers to the re-read when a write is still out.
…nd a reloaded model The missing-binary refusal was scoped to GGUF-named models, on the reasoning that anything else still has the safetensors fallback. Under an explicit RAG_EMBED_BACKEND=llama-server that fallback is refused for every model, so an ordinary repo id is just as unservable, yet its companion repo was offered and a potentially large managed download persisted for a model _resolve_binary rejects at first use. The condition is now "only llama can serve this", which covers the explicit policy and a runtime pin as well as the name, and the message no longer claims the model publishes GGUF. An ST wrapper descheduled between _get_backend() returning it and its encode starting is retired by an unload that lands in the gap, and then reloads the module-level model with no backend to publish. Reporting residency off the published backend alone called that unloaded, and the next unload saw no backend and freed nothing, so the weights sat in memory for the life of the process. Residency now also answers for a model with no backend beside it, and unload frees one, which makes the reload recoverable however the race falls rather than depending on catching it.
… repo The stored GGUF family was consulted only while the transfer was pending. Once the marker retired, a preferred variant arriving later in the same repo (a full-repo download, a republished revision) was picked up by the configured-variant lookup and served instead, while the stored identity carries the model and the repo but not the file, so an existing index was queried with weights it was not built from. The family is now honoured whenever it is fully on disk, ahead of that lookup, which is what makes the record an artifact identity rather than a transfer receipt. A partly present family is still not served: entering a torn one at shard 1 gives llama-server a model it cannot finish opening. The backend selector decided "is this a GGUF repo" with a suffix test while config.gguf_repo_candidates already answers it by whole name segment, so owner/GGUF-model and owner/model-GGUF-Q8 were sent to sentence-transformers, which has nothing to open, and stayed there even under a forced selection. It now calls config's predicate. The ST cache source took its snapshot from an exact per-repo lookup but its completeness verdict from the alias-expanding one. With several cache roots those find different directories, so a complete namespaced copy in one root could vouch for a partial literal copy in another that is what actually gets loaded. A reset dropped a remembered resolution that had only the pending flag, which is what a default saved over a failed plan legitimately looks like, restoring the model without the marker that keeps the first index from downloading invisibly. The settings fixture now clears the process-wide resolution memo. It outlives the patched store, so a pending default recorded in one test answered for the same model in every later file.
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Comment-only. The blocks written over the last dozen rounds had grown into retellings of each bug's history; this keeps the reason a reader needs and drops the narrative around it. No code changes: verified with an AST comparison over every touched file.
Reading the effective model is how a job commits to one, but only the repo and backend getters populated the per-model memo. A worker that pinned A, scanned for a while and embedded afterwards therefore had nothing memoized, so a save for B in that gap took A's one stored record away and moved the run onto the derived A-GGUF: an off-convention mirror silently replaced, and one document set split across two identities. The pin records the resolution now, which is the point at which the job's answer has to be fixed.
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Selecting an embedding model you do not have on disk did nothing visible. This makes it behave like the dictation model picker: search the whole Hub, and actually download what you choose.
What was wrong
Settings -> Documents & RAG used a text combobox. It searched Hugging Face, but selecting only wrote a string into a field.
PUT /api/settings/embedding-modelverified the repo and persisted it, and the weights were then fetched lazily and invisibly at the first index (core/rag/embeddings.py,core/rag/embed_llama_server.py). So picking a model you did not have looked like a no-op, with no progress, no size and no way to cancel.The dictation picker already solved exactly this problem, so this borrows its shape rather than inventing a second one.
Backend
New
GET /api/settings/embedding-model/resolve, which answers what saving a model would need fetched and whether it is already here:It composes existing helpers rather than inventing rules:
config.gguf_repo_for_embedding_modelfor the companion repo, honouringRAG_EMBED_GGUF_REPOand repos that already name GGUFLlamaServerBackend._resolve_cached_gguffor the offline cache checkLlamaServerBackend._pick_gguffor which.ggufmatchesEMBED_GGUF_VARIANThf_cache_snapshot_is_loadablefor the sentence-transformers path_hf_gguf_backend_errorand_local_gguf_backend_errorforerror, so resolve and the PUT cannot disagree about what is usableCandidate order follows
_resolve_model_pathexactly, so the picker can never fetch from a repo the loader would not have used. The HF token rides theX-Unsloth-HF-Tokenheader rather than a query parameter, keeping a gated repo credential out of URLs and access logs.Frontend
embedding-model-picker.tsxreplaces the combobox, built the same way asSttModelPickerinvoice-tab.tsx:Selecting applies immediately, as dictation does, so the Save button is gone. A model that is not on disk raises a confirm dialog with its name and size, and the transfer then runs through
downloadManager.requestStartwith a scopedfileslist. That is the same call the Hub's own download cards andchat-page.tsxmake, so progress, cancel and Xet/HTTP transport all come from the shared download panel, and only the one.ggufthe embedder opens is fetched rather than every quant in the companion repo.Reset to default, the re-index warning and the forceable "Save anyway" path are untouched, and 409 and 403 keep their existing meanings.Strings are added to
en.tsand translated into all 12 locales.Testing
test_embedding_model_resolve.py: 7 cases covering a cached repo, an uncached repo, a repo with no GGUF anywhere, a local.gguf, sentence-transformers, candidate ordering, and the token-in-header rule.test_embedding_model_settings.pyandtest_embedding_model_security_gate.pystill pass, so the PUT behaviour is unchanged.embedding-model-combobox-query.test.tsis replaced byembedding-model-picker.test.ts, which keeps its "General and Data render one shared section" assertion.tsc --noEmitandnpm run buildclean.