# BFCL v4 Function-Calling Evaluation Playbook
This note recommends practical BFCL v4 subsets for benchmarking function/tool-calling models and explains how to score predictions using the labels shipped in `@data_BFCL`.
## 1. Recommended Subsets
| Priority | File | Scenario | Why Use It | Label Availability |
| --- | --- | --- | --- | --- |
| Core | `BFCL_v4_simple_python.json` | Single-turn, one tool | Baseline correctness on structured JSON schemas with minimal ambiguity. | ✅ `possible_answer/BFCL_v4_simple_python.json` (canonical arguments, allowed variants) |
| Core | `BFCL_v4_multiple.json` | Single-turn, tool selection | Tests intent classification and choosing the right function when several are provided. | ✅ |
| Core | `BFCL_v4_parallel.json`
`BFCL_v4_parallel_multiple.json` | Single-turn, multi-call | Measures decomposition of one instruction into several tool invocations (same or different tool). | ✅ |
| Negative | `BFCL_v4_irrelevance.json` | Refusal detection | Ensures the model withholds calls when documentation is unrelated. | ✅ (`ground_truth` array is empty ⇒ expect “no call”) |
| Live APIs | `BFCL_v4_live_simple.json`
`BFCL_v4_live_multiple.json`
`BFCL_v4_live_parallel.json` | Production-style schemas, multilingual prompts | Validates robustness to realistic parameter naming, enum constraints, and language shifts. | ✅ (see `possible_answer/BFCL_v4_live_*.json`) |
| Advanced | `BFCL_v4_multi_turn_base.json` | Multi-turn agent | Evaluates planning across turns with persistent simulator state. | ✅ (tool sequences per turn) |
| Stress | `BFCL_v4_multi_turn_miss_func.json`
`BFCL_v4_multi_turn_miss_param.json` | Missing docs/arguments | Checks recovery when specs are incomplete. | ✅ |
| Memory | `BFCL_v4_memory.json` + `memory_prereq_conversation/` | Retrieval from persistent memory | Probes stateful recall tasks; useful for agent memory evaluation. | ✅ (text answers + supporting source span) |
| Web | `BFCL_v4_web_search.json` | Multi-hop web reasoning | Tool planning and result aggregation under time-sensitive knowledge. | ✅ (answers and supporting URLs) |
To focus purely on tool selection and argument grounding without simulator overhead, start with the **Core single-turn splits** plus the **Live APIs**. Add **Negative** to check calibration. Introduce **Advanced** and **Stress** once baseline competency is established.
## 2. Understanding the Labels
All recommended splits have corresponding entries in `possible_answer/`. The `ground_truth` field encodes acceptable tool calls or text answers:
* **Single-turn tool calls** (`simple_*`, `multiple`, `parallel`, `live_*`):
```json
{
"id": "parallel_0",
"ground_truth": [
{"spotify.play": {"artist": ["Taylor Swift"], "duration": [20]}},
{"spotify.play": {"artist": ["Maroon 5"], "duration": [15]}}
]
}
```
The evaluator expects the model to emit tool calls whose method names and argument values fall within the allowed lists.
* **Irrelevance**: `ground_truth` is `[]`. Any predicted call counts as an error.
* **Multi-turn**: `ground_truth` is a list of per-turn action sequences:
```json
{
"id": "multi_turn_base_0",
"ground_truth": [
["cd(folder='document')", "mkdir(dir_name='temp')", ...],
["cd(folder='temp')", "grep(...)", ...],
...
]
}
```
Each inner list enumerates the canonical tool calls the agent should make during that turn.
* **Memory & Web Search**: `ground_truth` stores textual answers (with variants) and `source` records the supporting facts/URLs.
## 3. Scoring Strategies
### 3.1 Single-Turn Tool Calling (Core & Live)
1. **Parse model outputs** into a normalized representation (e.g., JSON object `{ "name": ..., "arguments": ... }`).
2. **Compare against `ground_truth`:**
* Match on function name.
* For each argument, allow any value present in the ground truth list (many entries include multiple acceptable spellings, optional defaults, or empty strings).
* For parallel tasks, verify all required calls appear (order-insensitive, but multiplicity matters).
3. **Metrics:**
* `Exact Match` – model emits the full expected set of calls with valid arguments (primary leaderboard metric).
* `Precision / Recall` over calls – useful when you want partial credit for parallel cases.
* `Argument Accuracy` – percentage of correctly filled slots.
The official BFCL harness supplies both an **AST evaluator** (structure-only) and an optional **Executable evaluation** (run synthesized code). With only the JSON data you can mimic the AST check: ensure method names and argument key/value pairs align with any admissible ground truth combination.
### 3.2 Irrelevance Split
* Scoring reduces to a binary check: respond with `no_call` (or a plain-text refusal) to earn credit.
* Report false-positive rate (calls made when `ground_truth` is empty).
### 3.3 Multi-Turn Agent Splits
* Treat each user turn as an evaluation unit.
* Canonical answer lists are sequences of CLI-like strings. Convert the model’s tool invocations into the same textual format (e.g., `mv(source='a', destination='b')`) and compare order-sensitive.
* Metrics:
* `Turn-Level Exact Match`
* `Episode Success` (all turns match)
* `Tool Recall` (how many required tool calls were issued per turn)
* When assessing robustness in `miss_func` / `miss_param`, track whether the agent pauses to ask for missing information before issuing the final call; incorrect premature calls will fail the match.
### 3.4 Memory QA
* Use string match against any acceptable answer in `ground_truth`.
* Optionally compute semantic similarity for free-form responses.
* Secondary metric: cite strings in `source` to encourage grounded answers.
### 3.5 Web Search
* Compare numeric/text outputs with `ground_truth`.
* Evaluate retrieval quality (did the agent call the search tool?) and reasoning depth (count of hops).
* You can reuse the provided `num_hops` as an oracle baseline or to filter tasks by difficulty.
## 4. Suggested Evaluation Pipelines
1. **Offline Baseline (fast loop):**
`simple_python` → `multiple` → `parallel` → `parallel_multiple` → `irrel`.
* Score with AST-style matcher; report overall exact match and per-arg accuracy.
2. **Production Readiness:**
Add `live_simple`, `live_multiple`, `live_parallel`.
* Include multilingual prompts, monitor refusal behavior, and check for schema adherence (enums, defaults).
3. **Agentic Stress Test:**
Evaluate on `multi_turn_base`, then extend to `multi_turn_miss_func` / `miss_param`.
* Measure both episode success and recovery from missing docs.
4. **Memory + Web:**
Use `memory` (with prerequisite transcripts) and `web_search` to test stateful recall and multi-hop reasoning.
* Provide final answer accuracy plus tool-usage diagnostics (e.g., did the agent issue `search_engine_query`?).
## 5. Annotating Model Logs
While scoring, log:
* Parsed tool calls vs. expected `ground_truth`.
* Argument-by-argument diffs (useful for debugging enum mistakes).
* Refusal vs. call decisions on irrelevance data.
* Turn-by-turn traces for multi-turn scenarios (compare to `path` metadata for further analysis).
These diagnostics align with BFCL’s leaderboard metrics and make it easier to spot regressions.
---
Using these subsets and scoring rules, you can replicate the essential BFCL v4 evaluations locally and quantify function-calling proficiency without running the full official harness. When in doubt, refer back to the `possible_answer/` files—they contain the authoritative labels for each recommended dataset.*** End Patch