Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: searching a model maker in the Model hub lists Unsloth's uploads of its models (#13998)

Michael Hand4e005e73eb5
diff --git a/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts b/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts
index b3230abefbc..65bfc7eaa10 100644
--- a/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts
+++ b/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts
@@ -22,6 +22,12 @@ import { mergeTaskIterators } from "../lib/merge-task-iterators";
import { detectBaseModel } from "../lib/model-capabilities";
import { isGgufLike } from "../lib/model-identifiers";
import { type FreshRankable, rankFresh } from "../lib/fresh-ranking";
+import { type ProviderLogo, resolveOwnerProviderLogo } from "../lib/provider-logos";
+import {
+ matchProviderByQuery,
+ providerHubOrgs,
+ providerSearchTerms,
+} from "../lib/provider-search";
import { fetchWithTimeout } from "../lib/network";
import {
type UnslothSupport,
@@ -474,6 +480,140 @@ export interface HfModelSearchChannel {
idSuffix?: string;
}
+/** Unsloth uploads read per search term for a model maker's query. */
+const PROVIDER_POOL = 100;
+
+function rankListing(
+ models: FreshRankable[],
+ sortBy: HfSortKey,
+ direction: HfSortDirection,
+): FreshRankable[] {
+ if (sortBy === "fresh") {
+ return rankFresh(models, Date.now());
+ }
+ const key = (model: FreshRankable & { downloads?: number }) => {
+ if (sortBy === "trendingScore") return model.trendingScore ?? 0;
+ if (sortBy === "likes") return model.likes ?? 0;
+ if (sortBy === "downloads") return model.downloads ?? 0;
+ const date = sortBy === "createdAt" ? model.createdAt : model.updatedAt;
+ return date ? new Date(date).getTime() : 0;
+ };
+ const sign = direction === "asc" ? 1 : -1;
+ return [...models].sort((a, b) => sign * (key(a) - key(b)));
+}
+
+/**
+ * A search naming a model maker ("meta", "alibaba"): Unsloth's uploads of that maker's models, the
+ * ones shown with its avatar, then (beyond Unsloth-only) the maker's own org uploads. Each group's
+ * first pool is ranked by the listing's sort; the rest of each listing follows in its own order,
+ * then the search's own results without repeats.
+ */
+async function* providerUnslothFirstIterator(
+ provider: ProviderLogo,
+ inner: AsyncGenerator<unknown>,
+ opts: {
+ sortBy: HfSortKey;
+ sortDirection: HfSortDirection;
+ accessToken?: string;
+ signal: AbortSignal;
+ parameterFilter?: string;
+ includeOrgs: boolean;
+ filterPriority?: ModelListingTransform;
+ },
+): AsyncGenerator<unknown> {
+ const listing = (search: { query?: string; owner: string }) =>
+ listModels({
+ hubUrl: getHfEndpoint(),
+ search,
+ additionalFields: ALL_FIELDS,
+ fetch: makeSortFetch(opts.sortBy, opts.sortDirection, opts.signal, opts.parameterFilter),
+ sort: hubListingSort(opts.sortBy),
+ ...(opts.accessToken ? { credentials: { accessToken: opts.accessToken } } : {}),
+ }) as AsyncGenerator<unknown>;
+ // Read by hand: breaking out of a for-await would close the listing its tail continues.
+ const take = async (iter: AsyncGenerator<unknown>) => {
+ const items: unknown[] = [];
+ try {
+ while (items.length < PROVIDER_POOL) {
+ const next = await iter.next();
+ if (next.done) break;
+ items.push(next.value);
+ }
+ } catch {
+ // One listing failing leaves the others; the search's own results still follow.
+ }
+ return items;
+ };
+ const drain = async function* (iter: AsyncGenerator<unknown>) {
+ try {
+ yield* iter;
+ } catch {
+ // As above: a failed page ends that listing only.
+ }
+ };
+ const nameOf = (model: unknown) => (model as { name?: string } | null)?.name;
+ const isProviders = (name: string) =>
+ resolveOwnerProviderLogo("unsloth", name.split("/")[1])?.id === provider.id;
+ const unslothIters = providerSearchTerms(provider).map((term) =>
+ listing({ query: term, owner: "unsloth" }),
+ );
+ const orgIters = opts.includeOrgs
+ ? providerHubOrgs(provider).map((owner) => listing({ owner }))
+ : [];
+ // Started together; the Unsloth group yields without waiting on the org listings.
+ const orgFirst = Promise.all(orgIters.map(take));
+ const unslothFirst = await Promise.all(unslothIters.map(take));
+ const shown = new Set<string>();
+ const ranked = function* (models: unknown[], keep: (name: string) => boolean) {
+ const group = new Map<string, FreshRankable>();
+ for (const model of models) {
+ const name = nameOf(model);
+ if (name && !shown.has(name) && !group.has(name) && keep(name)) {
+ group.set(name, model as FreshRankable);
+ }
+ }
+ for (const model of rankListing([...group.values()], opts.sortBy, opts.sortDirection)) {
+ const name = nameOf(model) as string;
+ shown.add(name);
+ primeFromListing(name, opts.accessToken, model);
+ yield model as unknown;
+ }
+ };
+ const tail = async function* (iters: AsyncGenerator<unknown>[], keep: (name: string) => boolean) {
+ for (const iter of iters) {
+ for await (const model of drain(iter)) {
+ const name = nameOf(model);
+ if (!name || shown.has(name) || !keep(name)) continue;
+ shown.add(name);
+ primeFromListing(name, opts.accessToken, model);
+ yield model;
+ }
+ }
+ };
+ const prefix = async function* () {
+ yield* ranked(unslothFirst.flat(), isProviders);
+ yield* ranked((await orgFirst).flat(), () => true);
+ yield* tail(unslothIters, isProviders);
+ yield* tail(orgIters, () => true);
+ };
+ // Like the Unsloth pass in mergedModelIterator: a client-side filter that rejects these groups
+ // gives way to the search's own results after a bounded scan.
+ let rejected = 0;
+ for await (const model of opts.filterPriority ? opts.filterPriority(prefix()) : prefix()) {
+ if (model === null) {
+ yield null;
+ if (++rejected >= UNSLOTH_FILTER_REJECT_LIMIT) break;
+ continue;
+ }
+ yield model;
+ }
+ for await (const model of inner) {
+ const name = nameOf(model);
+ if (name && shown.has(name)) continue;
+ yield model;
+ }
+}
+
const FRESH_POOL = 100;
/** Ranks the newest and most trending together, then the rest by date. */
@@ -762,6 +902,11 @@ export function useHubModelSearch(
};
}, [query]);
+ // An owner/repo query names one repo; only a bare maker name widens to its Unsloth uploads.
+ const queryProvider = useMemo(
+ () => (isPublisherQuery || !trimmed ? null : matchProviderByQuery(trimmed)),
+ [isPublisherQuery, trimmed],
+ );
const hfEndpoint = useHfEndpoint();
const hasFilters = !!filters && hasModelSearchFilters(filters);
const filterRange = filters ? parameterRange(filters) : "";
@@ -884,9 +1029,16 @@ export function useHubModelSearch(
signal,
);
}
+ const providerOpts = {
+ sortBy,
+ sortDirection,
+ accessToken,
+ signal,
+ parameterFilter: filterRange,
+ };
// Unsloth-only typed query: search within the org rather than floating a few hits globally.
if (unslothOnly) {
- return listModels({
+ const orgSearch = listModels({
hubUrl: getHfEndpoint(),
search: { query: searchQuery, owner: "unsloth" },
additionalFields: ALL_FIELDS,
@@ -894,11 +1046,18 @@ export function useHubModelSearch(
sort: hubListingSort(sortBy),
...(accessToken ? { credentials: { accessToken } } : {}),
}) as AsyncGenerator<unknown>;
+ return queryProvider
+ ? providerUnslothFirstIterator(queryProvider, orgSearch, {
+ ...providerOpts,
+ includeOrgs: false,
+ filterPriority,
+ })
+ : orgSearch;
}
// Typed query: drop the task filter so searched models appear despite wrong/missing HF task
// metadata. For an "owner/repo" query, strip the org prefix so unsloth variants surface, then
// pin the original publisher model. Unsloth-owned queries are left as-is.
- return mergedModelIterator(
+ const merged = mergedModelIterator(
searchQuery,
undefined,
accessToken,
@@ -909,11 +1068,19 @@ export function useHubModelSearch(
filterRange,
filterPriority,
) as AsyncGenerator<unknown>;
+ return queryProvider
+ ? providerUnslothFirstIterator(queryProvider, merged, {
+ ...providerOpts,
+ includeOrgs: true,
+ filterPriority,
+ })
+ : merged;
},
[
trimmed,
searchQuery,
pinnedId,
+ queryProvider,
task,
accessToken,
stablePriorityIds,
diff --git a/studio/frontend/src/features/hub/lib/provider-search.ts b/studio/frontend/src/features/hub/lib/provider-search.ts
new file mode 100644
index 00000000000..bb649fb73e1
--- /dev/null
+++ b/studio/frontend/src/features/hub/lib/provider-search.ts
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+/**
+ * A search for a model maker ("meta", "alibaba", "zai", "google") also lists Unsloth's uploads of
+ * that maker's models: the ones the Hub shows with the maker's avatar (provider-logos.ts).
+ */
+
+import { PROVIDER_LOGOS, type ProviderLogo } from "./provider-logos.ts";
+
+/** Names people search by beyond a provider's id, display name and Hub orgs. */
+const QUERY_ALIASES: Readonly<Record<string, readonly string[]>> = {
+ "meta-llama": ["meta", "facebook"],
+ qwen: ["alibaba", "alibaba cloud", "qwen"],
+ "zai-org": ["zai", "z.ai", "zhipu", "zhipu ai", "thudm"],
+ google: ["google", "deepmind", "google deepmind"],
+ "deepseek-ai": ["deepseek"],
+ moonshotai: ["moonshot"],
+ mistralai: ["mistral"],
+ "xai-org": ["xai"],
+ minimax: ["minimax"],
+ huggingface: ["hf"],
+ cohere: ["cohere", "coherelabs"],
+};
+
+/** The maker's own Hub orgs, where the registry lists none. */
+const HUB_ORGS: Readonly<Record<string, readonly string[]>> = {
+ qwen: ["Qwen"],
+ "zai-org": ["zai-org"],
+ google: ["google"],
+ nvidia: ["nvidia"],
+ "deepseek-ai": ["deepseek-ai"],
+ microsoft: ["microsoft"],
+ moonshotai: ["moonshotai"],
+ mistralai: ["mistralai"],
+ "xai-org": ["xai-org"],
+ minimax: ["MiniMaxAI"],
+ huggingface: ["HuggingFaceTB"],
+ ibm: ["ibm-granite"],
+ cohere: ["CohereLabs"],
+ openai: ["openai"],
+};
+
+/** Hub orgs the maker uploads under, so "alibaba" reaches Qwen's own repos. */
+export function providerHubOrgs(provider: ProviderLogo): readonly string[] {
+ return provider.owners ?? HUB_ORGS[provider.id] ?? [];
+}
+
+const normalize = (value: string) => value.toLowerCase().replace(/[\s._-]+/g, "");
+
+/** The provider a whole query names, or null. Exact names only, so "gem" or "metal" match nothing. */
+export function matchProviderByQuery(query: string): ProviderLogo | null {
+ const needle = normalize(query);
+ if (!needle) {
+ return null;
+ }
+ for (const provider of PROVIDER_LOGOS) {
+ const names = [
+ provider.id,
+ provider.name,
+ ...(provider.owners ?? []),
+ ...(QUERY_ALIASES[provider.id] ?? []),
+ ];
+ if (names.some((name) => normalize(name) === needle)) {
+ return provider;
+ }
+ }
+ return null;
+}
+
+/**
+ * Hub search terms that reach the provider's repo names: its prefixes and stems without the
+ * trailing dash, dropping any term that already contains a shorter one (the Hub matches substrings).
+ */
+export function providerSearchTerms(provider: ProviderLogo): string[] {
+ const terms = [...provider.prefixes, ...(provider.stems ?? [])]
+ .map((term) => term.replace(/-+$/, "").toLowerCase())
+ .filter(Boolean);
+ const unique = [...new Set(terms)].sort((a, b) => a.length - b.length);
+ return unique.filter(
+ (term, i) => !unique.slice(0, i).some((shorter) => term.includes(shorter)),
+ );
+}
diff --git a/studio/frontend/tests/hub-provider-search.test.ts b/studio/frontend/tests/hub-provider-search.test.ts
new file mode 100644
index 00000000000..1bd331470cb
--- /dev/null
+++ b/studio/frontend/tests/hub-provider-search.test.ts
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// Searching a model maker by name also lists Unsloth's uploads of that maker's models.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ matchProviderByQuery,
+ providerHubOrgs,
+ providerSearchTerms,
+} from "../src/features/hub/lib/provider-search.ts";
+import { readSrc } from "./helpers/kit.ts";
+
+test("maker names, orgs and common aliases resolve; partial words do not", () => {
+ assert.equal(matchProviderByQuery("Meta")?.id, "meta-llama");
+ assert.equal(matchProviderByQuery("meta-llama")?.id, "meta-llama");
+ assert.equal(matchProviderByQuery("alibaba")?.id, "qwen");
+ assert.equal(matchProviderByQuery("zai")?.id, "zai-org");
+ assert.equal(matchProviderByQuery("Z.ai")?.id, "zai-org");
+ assert.equal(matchProviderByQuery("google")?.id, "google");
+ assert.equal(matchProviderByQuery("NVIDIA")?.id, "nvidia");
+ assert.equal(matchProviderByQuery("metal"), null);
+ assert.equal(matchProviderByQuery("gem"), null);
+ assert.equal(matchProviderByQuery("llama-3"), null);
+ assert.equal(matchProviderByQuery(" "), null);
+});
+
+test("search terms cover the maker's families without redundant requests", () => {
+ const meta = providerSearchTerms(matchProviderByQuery("meta")!);
+ assert.ok(meta.includes("muse"));
+ assert.ok(meta.includes("llama"));
+ assert.ok(!meta.includes("meta-llama"), "contains llama already");
+ assert.deepEqual(providerSearchTerms(matchProviderByQuery("google")!).filter((t) => t.includes("gemma")), ["gemma"]);
+});
+
+test("both typed-search paths put the maker's Unsloth uploads first, never for owner/repo", () => {
+ const hook = readSrc("features/hub/hooks/use-hub-model-search.ts");
+ assert.match(hook, /isPublisherQuery \|\| !trimmed \? null : matchProviderByQuery\(trimmed\)/);
+ assert.equal(hook.match(/providerUnslothFirstIterator\(queryProvider, /g)?.length, 2);
+ assert.match(hook, /resolveOwnerProviderLogo\("unsloth", name\.split\("\/"\)\[1\]\)\?\.id === provider\.id/);
+});
+
+test("a maker search also reaches the maker's own Hub orgs, outside Unsloth-only scope", () => {
+ assert.deepEqual(providerHubOrgs(matchProviderByQuery("alibaba")!), ["Qwen"]);
+ assert.deepEqual(providerHubOrgs(matchProviderByQuery("meta")!), ["meta-models", "meta-llama", "facebook"]);
+ const hook = readSrc("features/hub/hooks/use-hub-model-search.ts");
+ assert.match(hook, /providerUnslothFirstIterator\(queryProvider, orgSearch, \{\n\s*\.\.\.providerOpts,\n\s*includeOrgs: false,/);
+ assert.match(hook, /providerUnslothFirstIterator\(queryProvider, merged, \{\n\s*\.\.\.providerOpts,\n\s*includeOrgs: true,/);
+});
+
+test("the maker groups stream: Unsloth first, listing tails kept, a rejecting filter bounded", () => {
+ const hook = readSrc("features/hub/hooks/use-hub-model-search.ts");
+ const fn = hook.slice(hook.indexOf("async function* providerUnslothFirstIterator("), hook.indexOf("const FRESH_POOL"));
+ // The org listings start with the Unsloth ones but are awaited only after the Unsloth group yields.
+ assert.match(fn, /const orgFirst = Promise\.all\(orgIters\.map\(take\)\);\n[\s\S]*const unslothFirst = await Promise\.all/);
+ assert.match(fn, /yield\* ranked\(unslothFirst\.flat\(\), isProviders\);\n\s*yield\* ranked\(\(await orgFirst\)\.flat\(\)/);
+ // Pools past the first page are not dropped.
+ assert.match(fn, /yield\* tail\(unslothIters, isProviders\);\n\s*yield\* tail\(orgIters, \(\) => true\);/);
+ assert.match(fn, /if \(\+\+rejected >= UNSLOTH_FILTER_REJECT_LIMIT\) break;/);
+ assert.equal(hook.match(/includeOrgs: (true|false),\n\s*filterPriority,/g)?.length, 2);
+});