Benchmark: stripThinking poistaa gemma4-ajattelutagit vastauksista
This commit is contained in:
@@ -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]*?<channel\|>/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);
|
||||
|
||||
Reference in New Issue
Block a user