This commit is contained in:
2026-03-12 16:26:45 +09:00
parent 309698d507
commit 5d7de270f2
4 changed files with 37 additions and 39 deletions

View File

@@ -7,7 +7,6 @@ import {
type LLamaChatPromptOptions,
LlamaChatSession,
type LlamaModel,
TokenBias,
createModelDownloader,
getLlama,
resolveChatWrapper,
@@ -28,15 +27,6 @@ export async function getModel(model: string) {
return await llama.loadModel({ modelPath });
}
export function createBias(model: LlamaModel) {
const customBias = new TokenBias(model.tokenizer);
for (const token of model.iterateAllTokens()) {
const text = model.detokenize([token]);
if (text === "{") customBias.set(token, -0.9); // suppress JSON string
}
return customBias;
}
export const createGrammar = (assistantName: string) =>
llama.createGrammarForJsonSchema({
type: "object",