sparrow8i8's picture
Upload README.md with huggingface_hub
4f77d2e verified
|
Raw
History Blame Contribute Delete
4.19 kB
---
license: cc-by-4.0
task_categories:
- text-generation
tags:
- agentic
- tool-use
- function-calling
- multi-turn
- error-recovery
size_categories:
- 1K<n<10K
---
# Agentic Tool-Use Recovery (SFT)
Synthetic multi-turn tool-use trajectories that teach **recovery from failed tool results**, **query reformulation**, and **when to go direct vs. recover**. Built to address the failure mode seen when a Qwen2.5-7B model SFT'd on APIGen-MT (happy-path only) was evaluated on TAC: it called tools correctly but, when a search returned empty, it re-issued near-identical queries in a loop instead of adapting, and rarely completed the task.
Each trajectory is a travel-booking agent that must `search_experiences``get_experience_details``check_availability``purchase_tickets`.
**Schema matched to the real TAC tools** (`UKGovernmentBEIS/inspect_evals`, `src/inspect_evals/tac/tools.py`): search's optional filter parameter is `keywords` (not `query`), `check_availability` takes an optional `num_tickets`, results include Tags, and the success/failure return strings mirror TAC's wording, so the model trains on the same observations it will see at eval time. TAC matches `location` by substring of any term, which is why an over-broad term ("Hawaii") fails against an experience filed under "Honolulu, HI" while the city name works. The trajectories reflect that.
## Composition — 3,750 trajectories
Recovery (3,000, ~25% each):
- **broad_to_city** — first search uses a too-broad location → empty → narrow to the city → results → book.
- **two_wrong_then_city** — two over-broad/wrong location strings fail before narrowing to the city.
- **keyword_refine** — city search returns many → use the `keywords` field to narrow to the target.
- **bad_keyword_recover** — an over-narrow/garbled `keywords` returns empty → broaden the keyword → results → book.
Direct success (750, ~20% of the set):
- **direct_success** — the user names a city, the agent searches it directly (sometimes with `keywords`) and books, no failure. This teaches the *discrimination* (go direct when you already have a city) so the model doesn't learn a "fail-first ritual" from an all-recovery set.
## Schema
JSONL, one trajectory per line:
```json
{
"messages": [
{"role": "system", "content": "..."},
{"role": "user", "content": "..."},
{"role": "assistant", "content": "reasoning...", "tool_calls": [{"id": "...", "type": "function", "function": {"name": "search_experiences", "arguments": {"location": "Hawaii"}}}]},
{"role": "tool", "tool_call_id": "...", "name": "search_experiences", "content": "No experiences found in 'Hawaii'. Try a different location or broader keywords."},
{"role": "assistant", "content": "...", "tool_calls": [{"...": "search Honolulu ..."}]},
{"role": "tool", "...": "Found N experience(s) in Honolulu ..."},
"... details -> availability -> purchase ...",
{"role": "assistant", "content": "All set! I booked ..."}
],
"tools": [ /* OpenAI-style function schemas, matched to TAC */ ],
"metadata": {"city": "...", "country": "...", "target_id": "...", "category": "...", "pattern": "...", "num_tickets": 1}
}
```
- `tool_calls[].function.arguments` is a **dict** (Qwen2.5 `apply_chat_template` friendly; `json.dumps` it if your trainer wants a string).
- Apply your chat template with `tools=row["tools"]`; mask loss to assistant turns only.
## Intended use
Mix as roughly **40%** of a small tool-use SFT set, with ~60% APIGen-MT (multi-turn backbone), ~3 epochs. This set teaches recovery + the direct/recover discrimination; it is meant to be combined, not used alone.
## Caveats
- **Synthetic / templated.** Realistic in structure, not scraped; phrasing variety is from template pools.
- **Benign bookings only.** Options are welfare-neutral (hiking, snorkeling reefs, cooking classes, etc.). Targets completion/recovery, not welfare selection; do not expect it to move a welfare metric.
- **Not a benchmark.** Training data only; no held-out eval. Validate the effect on TAC `completion_rate` directly, do not assume.
Generated 2026-07-02, deterministic seed. See `gen_agentic_recovery.py`.