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
@@ -0,0 +1,37 @@
|
||||
# local-tool-calling
|
||||
|
||||
Companion to the ankurm.com post *Tool Calling with Small Local Models: Which Ollama Models Actually Follow Your Schema?*
|
||||
|
||||
The same four tools, the same twelve prompts, run several times against each small Ollama model through
|
||||
LangChain4j, and every response scored: valid call, schema-invalid arguments, wrong value, hallucinated tool,
|
||||
spurious call, no call. The tool definitions come from a small MCP server through `langchain4j-mcp`, so the
|
||||
schema each model sees is what an MCP client hands it.
|
||||
|
||||
| Piece | File |
|
||||
|---|---|
|
||||
| Tool suite, served over MCP (stdio) | `mcp/tool_server.py` |
|
||||
| MCP client wiring | `McpTools.java`, `McpWiring.java` |
|
||||
| The twelve prompts and what a correct answer is | `ToolCase.java` |
|
||||
| Scoring (schema validation + value checks) | `Scorer.java`, tested by `ScorerTest.java` |
|
||||
| The benchmark loop | `Benchmark.java` |
|
||||
|
||||
## Versions (verified on Maven Central, 2026-11-26)
|
||||
|
||||
LangChain4j `langchain4j` and `langchain4j-ollama` **1.24.0** (GA), `langchain4j-mcp` **1.24.0-beta34** (beta only), JDK 25, Python `mcp` 2.x (`MCPServer`; 1.x used `FastMCP`).
|
||||
This module overrides the parent's 1.22.0 BOM, like `advanced-rag` does.
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
export JAVA_HOME=/path/to/jdk-25
|
||||
pip install "mcp>=2"
|
||||
ollama serve & # or the desktop app
|
||||
scripts/pull-models.sh # six models, roughly 7 GB
|
||||
scripts/mcp-wiring.sh # MCP only, no model: lists tools, executes one call
|
||||
scripts/benchmark.sh # writes results/<model>.jsonl, one line per call
|
||||
scripts/summarize.py --cases # one table from results/*.jsonl
|
||||
```
|
||||
|
||||
`MODELS=llama3.2:3b RUNS=1 scripts/benchmark.sh` runs a single model once. `TEMPERATURE` (default 0.3) and `PYTHON` are also read.
|
||||
`mvn test -pl local-tool-calling -am` runs the scorer's unit tests; they use hand-written tool requests, not a model, and
|
||||
say nothing about how any model behaves. Results are machine-specific and are not committed: run it and compare.
|
||||
Reference in New Issue
Block a user