feat(m0): try the next model when tool calling still fails with the fix
User rule: if the tool-calling fix does not work, change the model. The tools_fast / tools_recommended stages now measure the next, less compressed model of the same family (fast: UD-Q6_K_XL then Q8_0; recommended: IQ3_XXS then IQ3_S) when the default still gets a scored case wrong, stop at the first one that passes every case, and record it as tools_verdict.chosen. Candidates without enough free disk are skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -53,7 +53,9 @@ LLM 단계는 8080 포트를 씁니다. 다른 프로그램이 이 포트를 쓰
|
||||
|
||||
단계 이름: `sysinfo`, `winchecks`, `vdisplay`, `tts_melo`, `tts_cosy2`, `tts_cosy3`, `stt`, `llm_fast`, `llm_recommended`, `tools_fast`, `tools_recommended`
|
||||
|
||||
`tools_fast`, `tools_recommended`는 도구 호출만 다시 잽니다. 처음과 같은 방식(고치기 전)과, 자비스의 수정(지시문 규칙, 계획 단계, 건너뛴 도구 직접 실행)을 넣은 방식을 같은 모델로 비교합니다. 이미 받은 모델을 쓰므로 다운로드는 없고, 모델 하나에 몇 분이면 끝납니다.
|
||||
`tools_fast`, `tools_recommended`는 도구 호출만 다시 잽니다. 처음과 같은 방식(고치기 전)과, 자비스의 수정(지시문 규칙, 계획 단계, 건너뛴 도구 직접 실행)을 넣은 방식을 같은 모델로 비교합니다. 이미 받은 모델을 쓰므로 모델 하나에 몇 분이면 끝납니다.
|
||||
|
||||
수정을 넣고도 도구 호출이 하나라도 틀리면, 같은 계열에서 덜 압축된 모델을 받아서 이어서 잽니다. 빠름은 Qwen3.6-35B-A3B UD-Q6_K_XL(약 33GB), 그다음 Q8_0(약 38GB) 순서이고, 권장은 Qwen3.8-Flash-Next IQ3_XXS, 그다음 IQ3_S 순서입니다. 통과하는 모델이 나오면 거기서 멈춥니다. 이때는 내려받느라 몇 시간 걸릴 수 있고, 디스크 공간이 모자란 모델은 건너뜁니다.
|
||||
|
||||
`run_m0_tools.bat`을 더블클릭하면 이 두 단계만 돌고 결과 zip이 만들어집니다. 직접 답하실 부분은 없습니다.
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -22,7 +23,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from m0lib.common import IS_WINDOWS, GpuSampler, StageResult, run_logged, say, scrub, stage_args # noqa: E402
|
||||
from m0lib.llm_bench import (bench_single, test_decode, test_images, test_parallel, test_tools, # noqa: E402
|
||||
test_vram_shrink, warmup)
|
||||
from m0lib.tool_fix import test_tools_fixed # noqa: E402
|
||||
from m0lib.tool_fix import test_tools_fixed, tools_passed # noqa: E402
|
||||
from m0lib.llm_client import ChatClient, http_json # noqa: E402
|
||||
|
||||
PRESETS = {
|
||||
@@ -32,6 +33,21 @@ PRESETS = {
|
||||
"recommended": {"family": "qwen", "model": "q2_0", "label": "Qwen3.8-Flash-Next Q2_0 (ISTA-DASLab)",
|
||||
"drafting": "mtp"},
|
||||
}
|
||||
# Tried in order when a preset still gets a tool call wrong with the Jarvis fix
|
||||
# (the user's rule: if the fix does not work, change the model). Same family,
|
||||
# less compressed weights, all within 128 GB RAM. need_gb: free disk to download.
|
||||
CANDIDATES = {
|
||||
"fast": [
|
||||
{"family": "qwen36", "model": "ud-q6_k_xl", "label": "Qwen3.6-35B-A3B UD-Q6_K_XL", "need_gb": 40},
|
||||
{"family": "qwen36", "model": "q8_0", "label": "Qwen3.6-35B-A3B Q8_0", "need_gb": 45},
|
||||
],
|
||||
"recommended": [
|
||||
{"family": "qwen", "model": "iq3_xxs", "label": "Qwen3.8-Flash-Next IQ3_XXS (ISTA-DASLab)",
|
||||
"drafting": "mtp", "need_gb": 80},
|
||||
{"family": "qwen", "model": "iq3_s", "label": "Qwen3.8-Flash-Next IQ3_S (ISTA-DASLab)",
|
||||
"drafting": "mtp", "need_gb": 85},
|
||||
],
|
||||
}
|
||||
PORT = 8080
|
||||
INSTALL_URL = "https://github.com/Niko1221/Strata/releases/latest/download/install.ps1"
|
||||
|
||||
@@ -193,14 +209,51 @@ def server_info(base: str) -> dict:
|
||||
return info
|
||||
|
||||
|
||||
def tools_only(r: StageResult, c: ChatClient) -> None:
|
||||
"""Tool calling as first measured (baseline) and with the Jarvis fix."""
|
||||
for fn in (lambda: warmup(r, c), lambda: test_tools(r, c), lambda: test_tools_fixed(r, c)):
|
||||
def tools_only(r: StageResult, c: ChatClient) -> dict | None:
|
||||
"""Tool calling as first measured (baseline) and with the Jarvis fix.
|
||||
|
||||
Returns the fixed run's summary (None when it could not run)."""
|
||||
summary = None
|
||||
for name, fn in (("warmup", lambda: warmup(r, c)), ("tools", lambda: test_tools(r, c)),
|
||||
("fixed", lambda: test_tools_fixed(r, c))):
|
||||
try:
|
||||
fn()
|
||||
out = fn()
|
||||
if name == "fixed":
|
||||
summary = out
|
||||
except Exception as e:
|
||||
r.error("tools", e)
|
||||
r.save()
|
||||
return summary
|
||||
|
||||
|
||||
def try_candidates(r: StageResult, which: str, default_summary: dict | None, measure, free_gb) -> None:
|
||||
"""If the default preset fails with the fix, measure the next candidates.
|
||||
|
||||
``measure(preset)`` starts the preset and returns its fixed-run summary;
|
||||
``free_gb()`` is the free disk in GB. Stops at the first passing model and
|
||||
records which one Jarvis should switch to (None if none passed).
|
||||
"""
|
||||
verdict: dict = {"default": PRESETS[which]["label"], "default_passed": tools_passed(default_summary),
|
||||
"candidates": [], "chosen": PRESETS[which]["label"] if tools_passed(default_summary) else None}
|
||||
r["tools_verdict"] = verdict
|
||||
if verdict["default_passed"]:
|
||||
return
|
||||
for cand in CANDIDATES[which]:
|
||||
row: dict = {"label": cand["label"]}
|
||||
verdict["candidates"].append(row)
|
||||
if free_gb() < cand["need_gb"]:
|
||||
row["skipped"] = "disk"
|
||||
say(f" {cand['label']}: 디스크 공간이 부족해 건너뜁니다 (필요 약 {cand['need_gb']} GB)")
|
||||
continue
|
||||
say(f" 수정 후에도 틀린 도구 호출이 있어 다른 모델을 잽니다: {cand['label']} (처음이면 내려받습니다)")
|
||||
try:
|
||||
row["summary"] = measure(cand)
|
||||
except Exception as e:
|
||||
row["error"] = str(e)[:300]
|
||||
r.save()
|
||||
if tools_passed(row.get("summary")):
|
||||
verdict["chosen"] = cand["label"]
|
||||
return
|
||||
|
||||
|
||||
def measure_external(r: StageResult, url: str, context: int, only: str = "") -> None:
|
||||
@@ -244,7 +297,18 @@ def measure_strata(r: StageResult, work: Path, which: str, context: int, only: s
|
||||
c = ChatClient(base)
|
||||
r["server"] = {"model": c.model, "info": server_info(base), "status": s.status()}
|
||||
if only == "tools":
|
||||
tools_only(r, c)
|
||||
default_summary = tools_only(r, c)
|
||||
|
||||
def measure(cand: dict) -> dict | None:
|
||||
key = f"tools_fixed_{cand['model']}"
|
||||
res = s.launch(cand, context, parallel=1, restart=True)
|
||||
r[f"launch_{cand['model']}"] = res
|
||||
if not res["ready"]:
|
||||
return None
|
||||
return test_tools_fixed(r, ChatClient(base), key=key)
|
||||
|
||||
try_candidates(r, which, default_summary, measure,
|
||||
free_gb=lambda: shutil.disk_usage(work).free / 1e9)
|
||||
s.stop()
|
||||
return
|
||||
with GpuSampler() as g:
|
||||
|
||||
@@ -152,12 +152,17 @@ def run_case(c: ChatClient, system: str, planner, prompt: str, want: str | None,
|
||||
return row
|
||||
|
||||
|
||||
def test_tools_fixed(r: StageResult, c: ChatClient, tries: int = 3) -> None:
|
||||
def tools_passed(summary: dict | None) -> bool:
|
||||
"""Every scored case ended with the right tool call (by the model or the guard)."""
|
||||
return bool(summary) and summary["total"] > 0 and summary["ok"] == summary["total"]
|
||||
|
||||
|
||||
def test_tools_fixed(r: StageResult, c: ChatClient, tries: int = 3, key: str = "tools_fixed") -> dict | None:
|
||||
say(" - 도구 호출 (수정 적용: 지시문 + 계획 + 건너뛴 도구 실행)")
|
||||
src = jarvis_src()
|
||||
if src is None:
|
||||
r.error("tools_fixed", "jarvis_src 폴더가 없습니다")
|
||||
return
|
||||
r.error(key, "jarvis_src 폴더가 없습니다")
|
||||
return None
|
||||
sp, planner = load_jarvis(src, c)
|
||||
names = [t["function"]["name"] for t in TOOLS]
|
||||
system = f"{VOICE_SYSTEM}\n\n{sp.TOOL_HONESTY_RULES}\n\n{sp.tool_honesty_reminder(names)}"
|
||||
@@ -177,6 +182,7 @@ def test_tools_fixed(r: StageResult, c: ChatClient, tries: int = 3) -> None:
|
||||
"guard_ran": sum(1 for x in rows if x.get("guard_ran")),
|
||||
"text_with_call": sum(1 for x in rows if x.get("text_with_call")),
|
||||
"total": len(scored)}
|
||||
r["tools_fixed"] = {"cases": rows, "summary": summary, "system": system}
|
||||
r[key] = {"cases": rows, "summary": summary, "system": system}
|
||||
say(f" 모델 스스로 {summary['model_ok']}/{summary['total']}, 계획 실행 포함 {summary['ok']}/{summary['total']}, "
|
||||
f"도구 호출과 같이 쓴 답 {summary['text_with_call']}번")
|
||||
return summary
|
||||
|
||||
Reference in New Issue
Block a user