Skip to content

Commit a0e1166

Browse files
authored
Account for the fact that there non-llama.cpp gguf files now (huggingface#856)
[companion internal PR](huggingface-internal/moon-landing#10946) **TL;DR:** we want the ability to discriminate non-llama.cpp gguf repos I've picked `${architecture}.context_length` as a property that, if it's in the gguf file, we assume it's compatible with llama.cpp Another option was to check whether `architecture` is inside the list in `@huggingface/gguf` (and keep this list up to date with upstream, maybe through some CI) Both options are possible, so let me know what you think is best
1 parent 177edf6 commit a0e1166

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

packages/tasks/src/local-apps.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,15 @@ export type LocalApp = {
5858
}
5959
);
6060

61+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6162
function isGgufModel(model: ModelData) {
6263
return model.tags.includes("gguf");
6364
}
6465

66+
function isLlamaCppGgufModel(model: ModelData) {
67+
return !!model.gguf?.context_length;
68+
}
69+
6570
const snippetLlamacpp = (model: ModelData, filepath?: string): LocalAppSnippet[] => {
6671
const command = (binary: string) =>
6772
[
@@ -138,56 +143,56 @@ export const LOCAL_APPS = {
138143
prettyLabel: "llama.cpp",
139144
docsUrl: "https://github.com/ggerganov/llama.cpp",
140145
mainTask: "text-generation",
141-
displayOnModelPage: isGgufModel,
146+
displayOnModelPage: isLlamaCppGgufModel,
142147
snippet: snippetLlamacpp,
143148
},
144149
lmstudio: {
145150
prettyLabel: "LM Studio",
146151
docsUrl: "https://lmstudio.ai",
147152
mainTask: "text-generation",
148-
displayOnModelPage: isGgufModel,
153+
displayOnModelPage: isLlamaCppGgufModel,
149154
deeplink: (model, filepath) =>
150155
new URL(`lmstudio://open_from_hf?model=${model.id}${filepath ? `&file=${filepath}` : ""}`),
151156
},
152157
localai: {
153158
prettyLabel: "LocalAI",
154159
docsUrl: "https://github.com/mudler/LocalAI",
155160
mainTask: "text-generation",
156-
displayOnModelPage: isGgufModel,
161+
displayOnModelPage: isLlamaCppGgufModel,
157162
snippet: snippetLocalAI,
158163
},
159164
jan: {
160165
prettyLabel: "Jan",
161166
docsUrl: "https://jan.ai",
162167
mainTask: "text-generation",
163-
displayOnModelPage: isGgufModel,
168+
displayOnModelPage: isLlamaCppGgufModel,
164169
deeplink: (model) => new URL(`jan://models/huggingface/${model.id}`),
165170
},
166171
backyard: {
167172
prettyLabel: "Backyard AI",
168173
docsUrl: "https://backyard.ai",
169174
mainTask: "text-generation",
170-
displayOnModelPage: isGgufModel,
175+
displayOnModelPage: isLlamaCppGgufModel,
171176
deeplink: (model) => new URL(`https://backyard.ai/hf/model/${model.id}`),
172177
},
173178
sanctum: {
174179
prettyLabel: "Sanctum",
175180
docsUrl: "https://sanctum.ai",
176181
mainTask: "text-generation",
177-
displayOnModelPage: isGgufModel,
182+
displayOnModelPage: isLlamaCppGgufModel,
178183
deeplink: (model) => new URL(`sanctum://open_from_hf?model=${model.id}`),
179184
},
180185
jellybox: {
181186
prettyLabel: "Jellybox",
182187
docsUrl: "https://jellybox.com",
183188
mainTask: "text-generation",
184189
displayOnModelPage: (model) =>
185-
isGgufModel(model) ||
190+
isLlamaCppGgufModel(model) ||
186191
(model.library_name === "diffusers" &&
187192
model.tags.includes("safetensors") &&
188193
(model.pipeline_tag === "text-to-image" || model.tags.includes("lora"))),
189194
deeplink: (model) => {
190-
if (isGgufModel(model)) {
195+
if (isLlamaCppGgufModel(model)) {
191196
return new URL(`jellybox://llm/models/huggingface/LLM/${model.id}`);
192197
} else if (model.tags.includes("lora")) {
193198
return new URL(`jellybox://image/models/huggingface/ImageLora/${model.id}`);
@@ -200,15 +205,15 @@ export const LOCAL_APPS = {
200205
prettyLabel: "Msty",
201206
docsUrl: "https://msty.app",
202207
mainTask: "text-generation",
203-
displayOnModelPage: isGgufModel,
208+
displayOnModelPage: isLlamaCppGgufModel,
204209
deeplink: (model) => new URL(`msty://models/search/hf/${model.id}`),
205210
},
206211
recursechat: {
207212
prettyLabel: "RecurseChat",
208213
docsUrl: "https://recurse.chat",
209214
mainTask: "text-generation",
210215
macOSOnly: true,
211-
displayOnModelPage: isGgufModel,
216+
displayOnModelPage: isLlamaCppGgufModel,
212217
deeplink: (model) => new URL(`recursechat://new-hf-gguf-model?hf-model-id=${model.id}`),
213218
},
214219
drawthings: {

packages/tasks/src/model-data.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ export interface ModelData {
109109
* Example: transformers, SpeechBrain, Stanza, etc.
110110
*/
111111
library_name?: string;
112+
safetensors?: {
113+
parameters: Record<string, number>;
114+
total: number;
115+
sharded: boolean;
116+
};
117+
gguf?: {
118+
total: number;
119+
architecture?: string;
120+
context_length?: number;
121+
};
112122
}
113123

114124
/**

0 commit comments

Comments
 (0)