Add local-tool-calling module: six small Ollama models scored on one MCP-served tool suite
Four tools served over MCP, twelve prompts, LangChain4j 1.24.0 OllamaChatModel, a scorer that validates each call against the tool's own JSON schema, and scripts to run and summarise the benchmark. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b3obqqePfZ9m2Jk5Ub
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
ae8fe985b4
commit
f4f90b3b30
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the module and writes its runtime classpath to target/cp.txt (sourced by the other scripts).
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mvn -B -q -f ../pom.xml -pl local-tool-calling -am compile dependency:build-classpath \
|
||||
-Dmdep.outputFile=target/cp.txt >/dev/null
|
||||
CP="target/classes:$(cat target/cp.txt)"
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# The real benchmark. Needs a running Ollama with the models pulled (see README) and: pip install mcp
|
||||
# scripts/benchmark.sh # the six models from the post, 3 runs each
|
||||
# MODELS=llama3.2:3b RUNS=1 scripts/benchmark.sh
|
||||
source "$(dirname "$0")/_cp.sh"
|
||||
MODELS="${MODELS:-qwen3:0.6b,qwen3:1.7b,llama3.2:1b,llama3.2:3b,qwen2.5:1.5b,granite3.3:2b}"
|
||||
java -cp "$CP" com.ankurm.lc4j.localtools.Benchmark --models "$MODELS" --runs "${RUNS:-3}" --temp "${TEMPERATURE:-0.3}" \
|
||||
--out results --python "${PYTHON:-python3}" --server mcp/tool_server.py 2>&1 | grep --line-buffered -v -e '^Picked up' -e '^\[main\] INFO'
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# MCP wiring only, no model. Needs: pip install mcp
|
||||
source "$(dirname "$0")/_cp.sh"
|
||||
java -cp "$CP" com.ankurm.lc4j.localtools.McpWiring "${PYTHON:-python3}" mcp/tool_server.py 2>&1 | grep -v -e '^Picked up' -e '^\[main\] INFO'
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
for m in qwen3:0.6b qwen3:1.7b llama3.2:1b llama3.2:3b qwen2.5:1.5b granite3.3:2b; do ollama pull "$m"; done
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
"""ENVEL = the subset of SCHEMA where the real arguments arrive wrapped in an envelope, under a "parameters" or "arguments" key.
|
||||
Reads results/*.jsonl (written by Benchmark) and prints one summary table. Pure counting, no model involved."""
|
||||
import glob, json, collections, sys
|
||||
|
||||
ORDER = ["VALID", "HALLUCINATED_TOOL", "SCHEMA_INVALID", "WRONG_TOOL", "WRONG_VALUE", "PARTIAL", "NO_CALL", "SPURIOUS_CALL"]
|
||||
HEAD = ["VALID", "HALLU", "SCHEMA", "WTOOL", "WVAL", "PART", "NOCALL", "SPUR"]
|
||||
args = [x for x in sys.argv[1:] if not x.startswith("--")]
|
||||
files = sorted(glob.glob((args[0] if args else "results") + "/*.jsonl"))
|
||||
print(f"{'model':<14} {'n':>3} " + " ".join(f"{h:>6}" for h in HEAD) + f" {'ENVEL':>6} {'JSONtx':>6} {'s/call':>7}")
|
||||
for f in files:
|
||||
rows = [json.loads(l) for l in open(f)]
|
||||
c = collections.Counter(r["outcome"] for r in rows)
|
||||
env = sum(1 for r in rows if r["outcome"] == "SCHEMA_INVALID" and any("unknown argument 'parameters'" in n or "unknown argument 'arguments'" in n for n in r["notes"]))
|
||||
jt = sum(1 for r in rows if r["jsonInText"])
|
||||
sec = sum(r["ms"] for r in rows) / len(rows) / 1000
|
||||
print(f"{rows[0]['model']:<14} {len(rows):>3} " + " ".join(f"{c.get(o, 0):>6}" for o in ORDER) + f" {env:>6} {jt:>6} {sec:>7.1f}")
|
||||
|
||||
# Per-case view: how many of the runs were VALID for each prompt.
|
||||
if "--cases" in sys.argv:
|
||||
by = collections.defaultdict(collections.Counter)
|
||||
models = []
|
||||
for f in files:
|
||||
rows = [json.loads(l) for l in open(f)]
|
||||
models.append(rows[0]["model"])
|
||||
for r in rows:
|
||||
by[r["case"]][(r["model"], "n")] += 1
|
||||
by[r["case"]][(r["model"], "ok")] += r["outcome"] == "VALID"
|
||||
print()
|
||||
print(f"{'case':<24} " + " ".join(f"{m:>13}" for m in models))
|
||||
for case in sorted(by):
|
||||
print(f"{case:<24} " + " ".join(f"{str(by[case][(m, 'ok')]) + '/' + str(by[case][(m, 'n')]):>13}" for m in models))
|
||||
Reference in New Issue
Block a user