Skip to content

Commit 1bb4a78

Browse files
committed
test: Qwen 3.5 checkpoint use
1 parent 8f7209e commit 1bb4a78

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {describe, expect, test} from "vitest";
2+
import {defineChatSessionFunction, LlamaChatSession, QwenChatWrapper} from "../../../src/index.js";
3+
import {getModelFile} from "../../utils/modelFiles.js";
4+
import {getTestLlama} from "../../utils/getTestLlama.js";
5+
6+
describe("qwen3.5 0.8b", () => {
7+
describe("functions", () => {
8+
test("use checkpoints", {timeout: 1000 * 60 * 60 * 2}, async () => {
9+
const modelPath = await getModelFile("Qwen3.5-0.8B-Q8_0.gguf");
10+
const llama = await getTestLlama();
11+
12+
const model = await llama.loadModel({
13+
modelPath
14+
});
15+
const context = await model.createContext({
16+
contextSize: 4096
17+
});
18+
const chatSession = new LlamaChatSession({
19+
contextSequence: context.getSequence()
20+
});
21+
expect(chatSession.chatWrapper).toBeInstanceOf(QwenChatWrapper);
22+
23+
const promptOptions: Parameters<typeof chatSession.prompt>[1] = {
24+
functions: {
25+
getNthWord: defineChatSessionFunction({
26+
description: "Get an n-th word",
27+
params: {
28+
type: "object",
29+
properties: {
30+
n: {
31+
enum: [1, 2, 3, 4]
32+
}
33+
}
34+
},
35+
handler(params) {
36+
return ["very", "secret", "this", "hello"][params.n - 1];
37+
}
38+
})
39+
}
40+
} as const;
41+
42+
const res = await chatSession.prompt("What is the second word? use the function", promptOptions);
43+
44+
expect(res).to.toMatchInlineSnapshot(`
45+
"
46+
47+
48+
49+
The second word is "secret"."
50+
`);
51+
expect(chatSession.sequence.tokenMeter.usedInputTokens).toMatchInlineSnapshot("372");
52+
expect(chatSession.sequence.lastCheckpointIndex).toMatchInlineSnapshot("393");
53+
expect(chatSession.sequence.nextTokenIndex).toMatchInlineSnapshot("405");
54+
55+
const initialMeterState = chatSession.sequence.tokenMeter.getState();
56+
const res2 = await chatSession.prompt("Explain what this word means", {
57+
...promptOptions,
58+
maxTokens: 40
59+
});
60+
61+
const diffMeterState = chatSession.sequence.tokenMeter.diff(initialMeterState);
62+
expect(res2).to.toMatchInlineSnapshot(`
63+
"
64+
65+
The word "secret" means something that is hidden or kept from others. It can also refer to a secret knowledge, a secret weapon, or a secret place."
66+
`);
67+
expect(diffMeterState.usedInputTokens).toMatchInlineSnapshot("73");
68+
expect(diffMeterState.usedInputTokens).to.be.lessThanOrEqual(80);
69+
expect(chatSession.sequence.lastCheckpointIndex).toMatchInlineSnapshot("414");
70+
expect(chatSession.sequence.nextTokenIndex).toMatchInlineSnapshot("452");
71+
});
72+
});
73+
});

test/utils/modelFiles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const supportedModels = {
2121
"Llama-3.2-3B-Instruct.Q4_K_M.gguf": "https://huggingface.co/mradermacher/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct.Q4_K_M.gguf?download=true",
2222
"nomic-embed-text-v1.5.Q4_K_M.gguf": "https://huggingface.co/nomic-ai/nomic-embed-text-v1.5-GGUF/resolve/main/nomic-embed-text-v1.5.Q4_K_M.gguf?download=true",
2323
"bge-reranker-v2-m3-Q8_0.gguf": "https://huggingface.co/gpustack/bge-reranker-v2-m3-GGUF/resolve/main/bge-reranker-v2-m3-Q8_0.gguf?download=true",
24-
"Qwen3-0.6B-Q8_0.gguf": "https://huggingface.co/Qwen/Qwen3-0.6B-GGUF/resolve/main/Qwen3-0.6B-Q8_0.gguf?download=true"
24+
"Qwen3-0.6B-Q8_0.gguf": "https://huggingface.co/Qwen/Qwen3-0.6B-GGUF/resolve/main/Qwen3-0.6B-Q8_0.gguf?download=true",
25+
"Qwen3.5-0.8B-Q8_0.gguf": "https://huggingface.co/unsloth/Qwen3.5-0.8B-GGUF/resolve/main/Qwen3.5-0.8B-Q8_0.gguf?download=true"
2526
} as const;
2627

2728
export async function getModelFile(modelName: keyof typeof supportedModels) {

0 commit comments

Comments
 (0)