Skip to content

Commit 4b7ef5b

Browse files
authored
fix: improve model downloader CI logs (#329)
* fix: improve model downloader CI logs * fix: `CodeGemma` adaptations
1 parent ebc4e83 commit 4b7ef5b

File tree

6 files changed

+59
-11
lines changed

6 files changed

+59
-11
lines changed

package-lock.json

Lines changed: 20 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"filenamify": "^6.0.0",
182182
"fs-extra": "^11.2.0",
183183
"ignore": "^5.3.2",
184-
"ipull": "^3.6.2",
184+
"ipull": "^3.7.2",
185185
"is-unicode-supported": "^2.1.0",
186186
"lifecycle-utils": "^1.7.0",
187187
"log-symbols": "^7.0.0",

src/cli/recommendedModels.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ export const recommendedModels: ModelRecommendation[] = [{
158158
name: "Mixtral 8x7B MoE",
159159
abilities: ["chat", "complete"],
160160
description: "Mixtral models were created by Mistal AI and are general purpose models that utilize a Mixture of Experts architecture.\n" +
161-
"Mixtures of Experts (MoE) is a technique where different models, each skilled in solving a particular kind of problem, work together to the improve the overall performance on complex tasks.\n"
162-
+ "This model includes 8 expert models, each with 7 billion parameters.",
161+
"Mixtures of Experts (MoE) is a technique where different models, each skilled in solving a particular kind of problem, work together to the improve the overall performance on complex tasks.\n" +
162+
"This model includes 8 expert models, each with 7 billion parameters.",
163163

164164
fileOptions: [{
165165
huggingFace: {
@@ -178,7 +178,7 @@ export const recommendedModels: ModelRecommendation[] = [{
178178
name: "Mistral 7B Instruct v0.2",
179179
abilities: ["chat", "complete"],
180180
description: "Mistral models were created by Mistal AI and are general purpose models.\n" +
181-
+ "This is the 7 billion parameters version of the model.",
181+
"This is the 7 billion parameters version of the model.",
182182

183183
fileOptions: [{
184184
huggingFace: {
@@ -518,6 +518,7 @@ export const recommendedModels: ModelRecommendation[] = [{
518518
abilities: ["code", "complete", "infill"],
519519
description: "CodeGemma models were created by Google and are optimized for code completion, code generation, " +
520520
"natual language understanding, mathematical reasoning, and instruction following.\n" +
521+
"This model is not suited for chat.\n" +
521522
"This is the 2 billion parameters version of the model.\n",
522523

523524
fileOptions: [{
@@ -556,6 +557,7 @@ export const recommendedModels: ModelRecommendation[] = [{
556557
abilities: ["code", "complete", "infill"],
557558
description: "CodeGemma models were created by Google and are optimized for code completion, code generation, " +
558559
"natual language understanding, mathematical reasoning, and instruction following.\n" +
560+
"This model is not suited for chat.\n" +
559561
"This is the 7 billion parameters version of the model.\n",
560562

561563
fileOptions: [{

src/evaluator/LlamaCompletion.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ export class LlamaCompletion {
265265
const bosToken = this._sequence.model.tokens.bos;
266266
const shouldPrependBosToken = this._sequence.model.tokens.shouldPrependBosToken;
267267

268+
const extraEosTokens = getExtraCompletionEosTokens(this._sequence.model);
269+
268270
async function fitInputIntoContext({
269271
maxTokens, tokens
270272
}: {
@@ -348,7 +350,8 @@ export class LlamaCompletion {
348350
tokens: [...resolvedInput, ...res, ...pendingTokens]
349351
})
350352
};
351-
}
353+
},
354+
extraEosTokens
352355
});
353356
});
354357
}
@@ -840,6 +843,26 @@ async function resolveContextShiftSize(
840843
return defaultContextShiftSize(sequence);
841844
}
842845

846+
function getExtraCompletionEosTokens(model: LlamaModel) {
847+
const extraEosTokens = new Set<Token>();
848+
849+
if (model.fileInfo.metadata?.general?.architecture === GgufArchitectureType.gemma ||
850+
model.fileInfo.metadata?.general?.architecture === GgufArchitectureType.gemma2
851+
) {
852+
for (const token of model.iterateAllTokens()) {
853+
const tokenText = model.detokenize([token], true);
854+
if (tokenText === "<|file_separator|>" || tokenText === "<|fim_prefix|>") {
855+
extraEosTokens.add(token);
856+
857+
if (extraEosTokens.size === 2)
858+
break;
859+
}
860+
}
861+
}
862+
863+
return extraEosTokens;
864+
}
865+
843866
function getExtraInfillEosTokens(model: LlamaModel) {
844867
const extraEosTokens = new Set<Token>();
845868

src/utils/createModelDownloader.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import fs from "fs-extra";
55
import {normalizeGgufDownloadUrl} from "../gguf/utils/normalizeGgufDownloadUrl.js";
66
import {createSplitPartFilename, resolveSplitGgufParts} from "../gguf/utils/resolveSplitGgufParts.js";
77
import {getFilenameForBinarySplitGgufPartUrls, resolveBinarySplitGgufPartUrls} from "../gguf/utils/resolveBinarySplitGgufPartUrls.js";
8-
import {cliModelsDirectory} from "../config.js";
8+
import {cliModelsDirectory, isCI} from "../config.js";
99
import {safeEventCallback} from "./safeEventCallback.js";
1010
import {ModelFileAccessTokens, resolveModelFileAccessTokensTryHeaders} from "./modelFileAccesTokens.js";
1111
import {pushAll} from "./pushAll.js";
@@ -312,6 +312,7 @@ export class ModelDownloader {
312312
directory: this._dirPath,
313313
fileName: this._fileName ?? getFilenameForBinarySplitGgufPartUrls(binarySplitPartUrls),
314314
cliProgress: this._showCliProgress,
315+
cliStyle: isCI ? "ci" : "fancy",
315316
headers: this._headers ?? {},
316317
tryHeaders: this._tryHeaders.slice(),
317318
skipExisting: this._skipExisting
@@ -335,6 +336,7 @@ export class ModelDownloader {
335336
directory: this._dirPath,
336337
fileName: this._fileName ?? undefined,
337338
cliProgress: this._showCliProgress,
339+
cliStyle: isCI ? "ci" : "fancy",
338340
headers: this._headers ?? {},
339341
tryHeaders: this._tryHeaders.slice(),
340342
skipExisting: this._skipExisting
@@ -364,6 +366,7 @@ export class ModelDownloader {
364366
this._downloader = await downloadSequence(
365367
{
366368
cliProgress: this._showCliProgress,
369+
cliStyle: isCI ? "ci" : "fancy",
367370
parallelDownloads: this._parallelDownloads
368371
},
369372
...partDownloads
@@ -541,6 +544,7 @@ export class CombinedModelDownloader {
541544
this._downloader = await downloadSequence(
542545
{
543546
cliProgress: this._showCliProgress,
547+
cliStyle: isCI ? "ci" : "fancy",
544548
parallelDownloads: this._parallelDownloads
545549
},
546550
...(await Promise.all(this._downloaders)).flatMap((downloader) => downloader._specificFileDownloaders)

test/utils/modelFiles.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fs from "fs-extra";
55
import chalk from "chalk";
66
import withStatusLogs from "../../src/utils/withStatusLogs.js";
77
import {withLockfile} from "../../src/utils/withLockfile.js";
8+
import {isCI} from "../../src/config.js";
89

910
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1011

@@ -44,7 +45,8 @@ export async function getModelFile(modelName: keyof typeof supportedModels) {
4445
url: modelUrl,
4546
directory: path.dirname(modelFilePath),
4647
fileName: path.basename(modelFilePath),
47-
cliProgress: true
48+
cliProgress: true,
49+
cliStyle: isCI ? "ci" : "fancy"
4850
});
4951
await downloader.download();
5052

@@ -89,6 +91,7 @@ export async function downloadAllModels() {
8991
console.info(`Downloading ${pendingDownloads.length} model${pendingDownloads.length === 1 ? "" : "s"}`);
9092
const downloader = await downloadSequence({
9193
cliProgress: true,
94+
cliStyle: isCI ? "ci" : "fancy",
9295
parallelDownloads: 4
9396
}, ...pendingDownloads);
9497
await downloader.download();

0 commit comments

Comments
 (0)