From 7dc2af59c32bd63d68754dd456aa1ac4410c32f4 Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 14 Apr 2026 06:35:31 +0300 Subject: [PATCH] Benchmark: stripThinking poistaa gemma4-ajattelutagit vastauksista --- network-poc/tests/model-benchmark.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/network-poc/tests/model-benchmark.mjs b/network-poc/tests/model-benchmark.mjs index 528ce85..f8bca0d 100644 --- a/network-poc/tests/model-benchmark.mjs +++ b/network-poc/tests/model-benchmark.mjs @@ -26,6 +26,11 @@ const SCENARIO_FILTER = arg('scenarios', 'default'); const OUTPUT_DIR = arg('output', '/tmp/kipina-benchmark'); const MAX_FIX_ROUNDS = 2; +// === Ajattelutagien siivous (gemma4 ym.) === +function stripThinking(text) { + return text.replace(/<\|channel>thought[\s\S]*?/g, '').trim(); +} + // === Ollama / Hub -client === async function ollamaChat(model, prompt, systemPrompt, maxTokens = 2048) { const start = Date.now(); @@ -42,7 +47,7 @@ async function ollamaChat(model, prompt, systemPrompt, maxTokens = 2048) { const data = await resp.json(); const elapsed = Date.now() - start; return { - text: (data.response || '').trim(), + text: stripThinking((data.response || '').trim()), tokens: data.tokens_generated || 0, durationMs: elapsed, tokPerSec: data.tokens_per_sec || (data.tokens_generated || 0) / (elapsed / 1000), @@ -67,7 +72,7 @@ async function ollamaChat(model, prompt, systemPrompt, maxTokens = 2048) { if (!resp.ok) throw new Error(`Ollama HTTP ${resp.status}: ${await resp.text()}`); const data = await resp.json(); const elapsed = Date.now() - start; - const text = (data.message?.content || '').trim(); + const text = stripThinking((data.message?.content || '').trim()); const evalCount = data.eval_count || 0; const evalDurationNs = data.eval_duration || 1; const tokPerSec = evalCount / (evalDurationNs / 1e9);