lab/ab-llm.mjs vergleicht zwei LLMs ueber reanalyze-llm (ohne Neu-Diarisierung), mit snapshot/restore der Originalanalysen und einem Report aus Tabelle plus Volltext-Vergleich. tools/rkllm-qwen35/ konvertiert Qwen3.5-4B auf dem PC mit rkllm-toolkit 1.3.0 (muss zur Board-Runtime passen), Parameter identisch zum produktiven Modell: w8a8_g128, 3 NPU-Kerne, max_context 16384. Doku: Changelog 2026-09-29 (2) mit Recherchestand, Sicherung und GOTCHAs, plus neuer Abschnitt "Modellwechsel und A/B-Tests" in Kapitel 05 samt Mermaid-Ablauf. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Baut aus echten deutschen Gespraechstranskripten einen Kalibrier-Datensatz
|
|
fuer die rkllm-Quantisierung. Laeuft AUF DEM BOARD (python3 + mysql client).
|
|
|
|
Format laut rkllm-toolkit 1.3.0: [{"input": "...", "target": "..."}, ...]
|
|
"""
|
|
import json, subprocess, random
|
|
|
|
SQL = (
|
|
"select id, transcript from recordings "
|
|
"where transcript is not null and char_length(transcript) > 2000 "
|
|
"and deleted_at is null order by id desc limit 24;"
|
|
)
|
|
|
|
out = subprocess.run(
|
|
['mysql', '-ucallrec', '-pcallrec123', 'callrec', '-N', '-B', '-e', SQL],
|
|
capture_output=True)
|
|
rows = out.stdout.decode('utf-8', 'replace').splitlines()
|
|
|
|
random.seed(29)
|
|
samples = []
|
|
for row in rows:
|
|
parts = row.split('\t', 1)
|
|
if len(parts) != 2:
|
|
continue
|
|
rid, text = parts
|
|
# mysql -B escapt Zeilenumbrueche als \n
|
|
text = text.replace('\\n', '\n').replace('\\t', '\t')
|
|
text = ' '.join(text.split())
|
|
if len(text) < 2000:
|
|
continue
|
|
# drei Ausschnitte je Aufnahme: Anfang, Mitte, zufaellig
|
|
starts = [0, max(0, len(text) // 2 - 600)]
|
|
if len(text) > 6000:
|
|
starts.append(random.randint(1000, len(text) - 2000))
|
|
for st in starts:
|
|
chunk = text[st:st + 1400].strip()
|
|
if len(chunk) > 800:
|
|
samples.append({"input": chunk, "target": ""})
|
|
|
|
random.shuffle(samples)
|
|
samples = samples[:64]
|
|
with open('/tmp/calib-de.json', 'w', encoding='utf-8') as f:
|
|
json.dump(samples, f, ensure_ascii=False, indent=1)
|
|
|
|
print('Samples: %d' % len(samples))
|
|
print('Zeichen gesamt: %d' % sum(len(s['input']) for s in samples))
|
|
print('Durchschnitt: %d' % (sum(len(s['input']) for s in samples) // max(1, len(samples))))
|