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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio Hub: rank Latest by trending against creation date, not last modified (#14329)
Michael Hanad2fc0659c02
diff --git a/studio/frontend/src/features/hub/lib/channels.ts b/studio/frontend/src/features/hub/lib/channels.tsindex 4edb8ff7c09..9855241ada1 100644--- a/studio/frontend/src/features/hub/lib/channels.ts+++ b/studio/frontend/src/features/hub/lib/channels.ts@@ -48,7 +48,7 @@ export const CHANNEL_PRESETS: readonly ChannelPreset[] = [hint: "Freshly released models from the Unsloth channel.",owner: "unsloth",format: "all",- // Trending weighed against release age (lib/fresh-ranking.ts).+ // Trending weighed against creation date (lib/fresh-ranking.ts).sort: "fresh",},{diff --git a/studio/frontend/src/features/hub/lib/fresh-ranking.ts b/studio/frontend/src/features/hub/lib/fresh-ranking.tsindex c7807c0dbf8..8e615c61787 100644--- a/studio/frontend/src/features/hub/lib/fresh-ranking.ts+++ b/studio/frontend/src/features/hub/lib/fresh-ranking.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-/** The Latest feed's order: trending, decayed by age, as Hacker News ranks stories. */+/** The Latest feed's order: trending, decayed by creation age, as Hacker News ranks stories. */export interface FreshRankable {createdAt?: string | Date;@@ -15,41 +15,29 @@ const DAY_MS = 86_400_000;const GRAVITY = 1.6;const AGE_OFFSET_DAYS = 2;const TREND_OFFSET = 2;-/** At least this many likes, nearly all of them recent, before likes may vouch for the date. */-const RECENT_LIKES_MIN = 5;-const RECENT_LIKES_SHARE = 0.8;-function ageDays(value: string | Date | undefined, now: number): number | null {- if (value === undefined) {- return null;+/** Days since the repo was created. Never last modified: a re-upload of a week-old model is not new. */+export function createdAgeDays(model: FreshRankable, now: number): number {+ if (model.createdAt === undefined) {+ return Number.POSITIVE_INFINITY;}- const time = new Date(value).getTime();- return Number.isFinite(time) ? Math.max(0, (now - time) / DAY_MS) : null;-}--/** The Hub has no publish date and createdAt predates a private-until-launch repo going public; nearly all-recent likes mean it just went public, so its last change dates it. */-export function releaseAgeDays(model: FreshRankable, now: number): number {- const created = ageDays(model.createdAt, now);- const updated = ageDays(model.updatedAt, now);- const likes = model.likes ?? 0;- const trending = model.trendingScore ?? 0;- const recentlyPublic =- likes >= RECENT_LIKES_MIN && trending >= RECENT_LIKES_SHARE * likes;- if (recentlyPublic && updated !== null) {- return created === null ? updated : Math.min(created, updated);- }- return created ?? updated ?? Number.POSITIVE_INFINITY;+ const time = new Date(model.createdAt).getTime();+ return Number.isFinite(time)+ ? Math.max(0, (now - time) / DAY_MS)+ : Number.POSITIVE_INFINITY;}export function freshScore(model: FreshRankable, now: number): number {- const age = releaseAgeDays(model, now);return (((model.trendingScore ?? 0) + TREND_OFFSET) /- (age + AGE_OFFSET_DAYS) ** GRAVITY+ (createdAgeDays(model, now) + AGE_OFFSET_DAYS) ** GRAVITY);}-export function rankFresh<T extends FreshRankable>(models: readonly T[], now: number): T[] {+export function rankFresh<T extends FreshRankable>(+ models: readonly T[],+ now: number,+): T[] {return models.map((model) => ({ model, score: freshScore(model, now) })).sort((a, b) => b.score - a.score)diff --git a/studio/frontend/tests/hub-fresh-ranking.test.ts b/studio/frontend/tests/hub-fresh-ranking.test.tsindex e07312c0453..5e21854afb2 100644--- a/studio/frontend/tests/hub-fresh-ranking.test.ts+++ b/studio/frontend/tests/hub-fresh-ranking.test.ts@@ -1,89 +1,100 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// The Latest feed ranks trending against release age, not by repo creation date alone.+// The Latest feed ranks trending against creation date, never against last modified.import assert from "node:assert/strict";import test from "node:test";import {+ createdAgeDays,freshScore,rankFresh,- releaseAgeDays,} from "../src/features/hub/lib/fresh-ranking.ts";import { readSrc } from "./helpers/kit.ts";-const NOW = Date.parse("2026-10-15T23:00:00Z");-const daysAgo = (days: number) => new Date(NOW - days * 86_400_000).toISOString();+const NOW = Date.parse("2026-10-20T10:00:00Z");+const daysAgo = (days: number) =>+ new Date(NOW - days * 86_400_000).toISOString();-// Shapes from the Hub's unsloth listing on 2026-10-15.-const museSpark = {- name: "Muse-Spark-Open-816B-A42B-GGUF",- createdAt: daysAgo(26.5),- updatedAt: daysAgo(0.2),- likes: 47,- trendingScore: 47,+// Shapes from the Hub's unsloth listing on 2026-10-20.+const deepseekFlash = {+ name: "DeepSeek-V4.1-Flash-1017-GGUF",+ createdAt: daysAgo(2.6),+ updatedAt: daysAgo(0.4),+ trendingScore: 85,};const nemotronBolt = {name: "NVIDIA-Nemotron-3.5-Bolt-74B-A9B-GGUF",- createdAt: daysAgo(1.3),- updatedAt: daysAgo(0.2),- likes: 40,- trendingScore: 40,+ createdAt: daysAgo(5.8),+ updatedAt: daysAgo(3.9),+ trendingScore: 76,+};+// Re-uploaded 3 hours ago; created a week ago.+const lfm = {+ name: "LFM2.5-24B-A2B-GGUF",+ createdAt: daysAgo(6.8),+ updatedAt: daysAgo(0.1),+ trendingScore: 89,};const embeddingGemma = {name: "embeddinggemma-2-GGUF",- createdAt: daysAgo(9.5),- updatedAt: daysAgo(8.7),- likes: 314,- trendingScore: 87,-};-const qwenOld = {- name: "Qwen3.8-27B-GGUF",- createdAt: daysAgo(63.6),- updatedAt: daysAgo(56),- likes: 5123,- trendingScore: 120,+ createdAt: daysAgo(14),+ updatedAt: daysAgo(13),+ trendingScore: 43,};const quietNew = {- name: "LTX-2.5-FP8",- createdAt: daysAgo(2.9),- updatedAt: daysAgo(2.9),- likes: 1,- trendingScore: 1,+ name: "sam3.1",+ createdAt: daysAgo(0.3),+ updatedAt: daysAgo(0.3),+ trendingScore: 2,};const retouched = {name: "Qwen-Image-2512-FP8",- createdAt: daysAgo(288),- updatedAt: daysAgo(2.7),- likes: 0,+ createdAt: daysAgo(293),+ updatedAt: daysAgo(0.5),trendingScore: 0,};-test("a repo kept private until launch is dated by its launch, not its creation", () => {- assert.ok(releaseAgeDays(museSpark, NOW) < 1);- assert.ok(Math.abs(releaseAgeDays(embeddingGemma, NOW) - 9.5) < 0.01);- // Re-touching an old repo nobody likes does not make it new.- assert.ok(releaseAgeDays(retouched, NOW) > 280);+test("age is counted from creation, so a re-upload is not new", () => {+ assert.ok(Math.abs(createdAgeDays(lfm, NOW) - 6.8) < 0.01);+ assert.ok(createdAgeDays(retouched, NOW) > 290);+ assert.equal(+ createdAgeDays({ trendingScore: 5 }, NOW),+ Number.POSITIVE_INFINITY,+ );});-test("trending and age are weighed together", () => {+test("trending and creation date are weighed together", () => {const ranked = rankFresh(- [qwenOld, quietNew, retouched, embeddingGemma, nemotronBolt, museSpark],+ [retouched, quietNew, embeddingGemma, lfm, nemotronBolt, deepseekFlash],NOW,).map((model) => model.name);- assert.deepEqual(ranked.slice(0, 3), [museSpark.name, nemotronBolt.name, embeddingGemma.name]);- // A two-month-old hit stays below this week's models, and an untouched old repo ranks last.- assert.ok(ranked.indexOf(qwenOld.name) > ranked.indexOf(embeddingGemma.name));+ // The re-uploaded LFM no longer jumps above models released after it.+ assert.deepEqual(ranked.slice(0, 3), [+ deepseekFlash.name,+ nemotronBolt.name,+ lfm.name,+ ]);+ assert.ok(ranked.indexOf(embeddingGemma.name) > ranked.indexOf(lfm.name));assert.equal(ranked.at(-1), retouched.name);assert.ok(freshScore(quietNew, NOW) > 0);});test("the Latest feed uses the fresh ranking, which no Hub request ever sends", () => {- assert.match(readSrc("features/hub/lib/channels.ts"), /id: "unsloth-latest",[\s\S]*?sort: "fresh",/);+ assert.match(+ readSrc("features/hub/lib/channels.ts"),+ /id: "unsloth-latest",[\s\S]*?sort: "fresh",/,+ );const hook = readSrc("features/hub/hooks/use-hub-model-search.ts");- assert.match(hook, /if \(opts\.sortBy === "fresh"\) \{\n\s*return freshChannelIterator\(channel, opts\);/);- assert.match(hook, /url\.searchParams\.set\("sort", hubListingSort\(sortBy\)\)/);+ assert.match(+ hook,+ /if \(opts\.sortBy === "fresh"\) \{\n\s*return freshChannelIterator\(channel, opts\);/,+ );+ assert.match(+ hook,+ /url\.searchParams\.set\("sort", hubListingSort\(sortBy\)\)/,+ );assert.doesNotMatch(hook, /sort: (opts\.)?sortBy,/);});@@ -93,13 +104,22 @@ test("Latest picked from the sort menu, outside any section, ranks the same way"hook,/if \(sortBy === "fresh" && !trimmed\) \{[\s\S]*?freshChannelIterator\(\n\s*\{ owner: unslothOnly \? "unsloth" : undefined \},[\s\S]*?tasks: normalizeTaskFilter\(task\),/,);- assert.match(hook, /const poolSize = FRESH_POOL \* Math\.max\(1, tasks\.length\);/);+ assert.match(+ hook,+ /const poolSize = FRESH_POOL \* Math\.max\(1, tasks\.length\);/,+ );// The task scopes both candidate listings, not only the ranked result.assert.match(hook, /\.\.\.\(opts\.task \? \{ task: opts\.task \} : \{\}\),/);});test("datasets and ModelScope never offer Latest", () => {const toolbar = readSrc("features/hub/catalog/models-toolbar.tsx");- assert.match(toolbar, /!\(option\.value === "fresh" && \(isDataset \|\| hubSource === "modelscope"\)\)/);- assert.match(readSrc("features/hub/hub-page.tsx"), /isDatasetMode && requestedSort === "fresh"\n\s*\? "createdAt"/);+ assert.match(+ toolbar,+ /!\(option\.value === "fresh" && \(isDataset \|\| hubSource === "modelscope"\)\)/,+ );+ assert.match(+ readSrc("features/hub/hub-page.tsx"),+ /isDatasetMode && requestedSort === "fresh"\n\s*\? "createdAt"/,+ );});