ssslakter/tool-call-eval

0

stars

16

commits

Jupyter Notebook

primary language

May 26, 2026

updated

README

tool-call-eval

Span-level hallucination detection for tool-calling dialogues. Starting from ToolACE, it injects controlled hallucinations into faithful assistant answers, then evaluates baseline detectors on how well they recover the hallucinated spans.

Hallucination types

Three datasets are built from the same base dialogues, one corruption each:

  • contradiction — a concrete fact is changed to contradict the tool output
  • overgeneration — a plausible but unsupported claim is added
  • missing_tool — the answer offers an action requiring an unavailable tool

Each dataset is balanced: every injected dialogue yields a clean (label 0, no spans) and a corrupted (label 1, one span) example in RAGTruth format.

Setup

The project uses uv. It resolves and installs everything (including the project itself) on first run, so no separate install step is needed — just prefix commands with uv run. To sync the environment ahead of time:

uv sync

Also works with pixi: run pixi install once, then swap uv run for pixi run in the commands below.

Dataset building runs the injector through litellm. The default generator is a local Ollama model (INJECT_MODEL / OLLAMA_API_BASE in tool_call_eval/config.py); point --model at any litellm-supported id to use a cloud backend instead.

Running

Step 1 — build the datasets (writes data/{type}.parquet):

uv run tce-build --target 300
  • --target — number of positive (hallucinated) examples per type (default 300)
  • --model — litellm model id used for injection
  • --repo-id — if set, also push each type to this HF dataset repo as its own config, loadable via load_dataset(repo_id, type)
  • --private — create the HF dataset repo as private (used with --repo-id)

Step 2 — evaluate baselines (writes results/baseline_results.json and prints a table):

uv run tce-eval --methods lettucedetect
  • --methods — one or more of lettucedetect, lookbacklens
  • --types — subset of contradiction overgeneration missing_tool (default: all)

Outputs

  • data/*.parquet — the three labeled datasets
  • results/baseline_results.json — per-method, per-type scores

Scoring (tool_call_eval/metrics.py) reports character-level span precision/recall/F1, plus example-level detection F1 and accuracy (any predicted span vs. any gold span).

Contributors

ssslakter

15 commits

JuTonic

1 commits

ssslakter/tool-call-eval

0

stars

16

commits

Jupyter Notebook

primary language

May 26, 2026

updated

README

tool-call-eval

Span-level hallucination detection for tool-calling dialogues. Starting from ToolACE, it injects controlled hallucinations into faithful assistant answers, then evaluates baseline detectors on how well they recover the hallucinated spans.

Hallucination types

Three datasets are built from the same base dialogues, one corruption each:

  • contradiction — a concrete fact is changed to contradict the tool output
  • overgeneration — a plausible but unsupported claim is added
  • missing_tool — the answer offers an action requiring an unavailable tool

Each dataset is balanced: every injected dialogue yields a clean (label 0, no spans) and a corrupted (label 1, one span) example in RAGTruth format.

Setup

The project uses uv. It resolves and installs everything (including the project itself) on first run, so no separate install step is needed — just prefix commands with uv run. To sync the environment ahead of time:

uv sync

Also works with pixi: run pixi install once, then swap uv run for pixi run in the commands below.

Dataset building runs the injector through litellm. The default generator is a local Ollama model (INJECT_MODEL / OLLAMA_API_BASE in tool_call_eval/config.py); point --model at any litellm-supported id to use a cloud backend instead.

Running

Step 1 — build the datasets (writes data/{type}.parquet):

uv run tce-build --target 300
  • --target — number of positive (hallucinated) examples per type (default 300)
  • --model — litellm model id used for injection
  • --repo-id — if set, also push each type to this HF dataset repo as its own config, loadable via load_dataset(repo_id, type)
  • --private — create the HF dataset repo as private (used with --repo-id)

Step 2 — evaluate baselines (writes results/baseline_results.json and prints a table):

uv run tce-eval --methods lettucedetect
  • --methods — one or more of lettucedetect, lookbacklens
  • --types — subset of contradiction overgeneration missing_tool (default: all)

Outputs

  • data/*.parquet — the three labeled datasets
  • results/baseline_results.json — per-method, per-type scores

Scoring (tool_call_eval/metrics.py) reports character-level span precision/recall/F1, plus example-level detection F1 and accuracy (any predicted span vs. any gold span).

Contributors

ssslakter

15 commits

JuTonic

1 commits

Languages

Jupyter Notebook

80.9%

Python

19.1%