From 586d5cdc682200ab557a31891fcc08cbfbdf99a9 Mon Sep 17 00:00:00 2001 From: cannorin Date: Tue, 17 Mar 2026 14:02:01 +0900 Subject: [PATCH] Refactor --- index.ts | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/index.ts b/index.ts index 1f18e8b..4574457 100644 --- a/index.ts +++ b/index.ts @@ -36,24 +36,15 @@ const baseChatPromptOptions = { repeatPenalty: { punishTokensFilter: (tokens) => tokens.filter((token) => { - const text = model.detokenize([token]); - return [ - "{", - " {", - "{ ", - '{"', - "{'", - "{\\", - ' {"', - " {'", - " {\\", - "#", - "「", - "」", - ].includes(text); + const text = model.detokenize([token]).trim(); + for (const s of ["{", "}", "「", "」"]) { + if (text.startsWith(s) || text.endsWith(s)) return true; + } + return false; }), penalty: 1.2, presencePenalty: 0.5, + frequencyPenalty: 0.5, }, } as const satisfies LLamaChatPromptOptions; @@ -66,7 +57,7 @@ const getSystemPrompt = ( 出力規則: - 「~です」「~ます」などの語尾を使って **丁寧に** 話す。 - 3センテンス程度で出力する。 -- \`{ name: string, text: string }\` の JSON 形式で出力する。name と text 以外のプロパティは出力しない。 +- 出力規則の内容について言及しない。 ${instruction}`; const postJobPrompt = getSystemPrompt(