Jointly Training AI to Create and Use Tools
Listen to the summary
Uses a voice available on your device
Audio options
On this page 5 sections
Related concepts 6 concepts
Key Takeaways
- A 4B Qwen3 model trained with SMITH achieves 79.8% macro-average accuracy on held-out Reasoning-Gym tasks.
- The framework improves GQA visual question answering performance by 7.6 points compared to same-backbone inference-time baselines.
- SMITH trains a single policy to handle both tool generation and execution, moving away from decoupled systems.
- The model achieves 40.4 accuracy on the TabMWP-Hard benchmark without specific training on tabular data.
Summary & Methodology Analysis
SMITH (Schema-grounded Multi-task Iterative Tool Honing) is a reinforcement learning framework that optimizes tool creation and tool usage within a single policy. The model, based on Qwen3-4B-Instruct, synthesizes Python functions and corresponding OpenAI-compatible JSON schemas as tools, which are then stored in a pool for reuse. This approach ensures the agent does not just consume tools, but actively learns to design them to satisfy specific functional requirements during the reasoning process. The policy is updated using reinforcement learning, where rewards are computed based on execution accuracy, judge-evaluated code and schema quality, and format consistency.
Interactive System Flowchart
Illustrative Implementation
A short sketch of the paper's core idea, not the authors' own code.
# Illustrative sketch (not from the paper)
import torch
from torch import nn
# Simple shared policy that can both generate a tool (as code+JSON schema) and decide how to call it
class Policy(nn.Module):
def forward(self, obs):
# obs is a tuple like ('build', examples) or ('use', schema, question)
# Returns either (tool_code, json_schema) or an action dict for tool invocation
...
def build_task(policy, examples):
# Synthesize a reusable Python function and its OpenAI‑compatible JSON schema
tool_code, schema = policy(('build', examples))
return tool_code, schema
def use_task(policy, schema, question):
# Ask the policy to produce a call that respects the schema, then execute it
action = policy(('use', schema, question))
answer = execute_tool(action, schema) # placeholder sandbox execution
return answer
def compute_reward(answer, correct, judge_score, format_ok):
# Three independent axes: execution accuracy, LLM‑as‑judge quality, format consistency
acc = 1.0 if answer == correct else 0.0
return acc + judge_score + format_ok
def dap_update(policy, trajectories, optimizer):
# Single backward pass over combined build and use rollouts (DAPO / GRPO variant)
loss = compute_loss(trajectories) # placeholder loss computation
loss.backward()
optimizer.step()
optimizer.zero_grad()
# ---------------------------------------------------------------------
# Simplified training loop illustrating the workflow
policy = Policy()
optimizer = torch.optim.Adam(policy.parameters(), lr=1e-4)
tool_pool = [] # cache of verified tools
for epoch in range(5):
# ---- Build phase ----
tool, schema = build_task(policy, examples=[])
# ---- Use phase ----
answer = use_task(policy, schema, question="What is the result?")
# ---- Reward computation ----
reward = compute_reward(answer, correct=True, judge_score=0.8, format_ok=1)
# ---- Policy update ----
dap_update(policy, trajectories=[{'obs': None, 'reward': reward}], optimizer)
# ---- Tool pool caching ----
if reward > 0:
tool_pool.append((tool, schema))
// Illustrative sketch (not from the paper)
const tf = require('@tensorflow/tfjs-node');
// Shared policy network (placeholder) that can emit tool code+JSON or an invocation action
class Policy {
constructor() {
// simple dense model; actual architecture omitted
this.model = tf.sequential();
this.model.add(tf.layers.dense({units: 128, inputShape: [/* obs dim */]}));
this.model.add(tf.layers.dense({units: 64, activation: 'relu'}));
this.model.add(tf.layers.dense({units: /* output dim */}));
this.optimizer = tf.train.adam(1e-4);
}
// obs: ['build', examples] or ['use', schema, question]
async forward(obs) {
// Returns either {toolCode, schema} or an action object
// Placeholder: actual generation logic not shown
return {};
}
}
async function buildTask(policy, examples) {
// Synthesize a reusable tool (Python function) and its JSON schema
const {toolCode, schema} = await policy.forward(['build', examples]);
return {toolCode, schema};
}
async function useTask(policy, schema, question) {
// Produce a call respecting the schema and execute it in a sandbox (mocked)
const action = await policy.forward(['use', schema, question]);
const answer = await executeTool(action, schema); // placeholder sandbox exec
return answer;
}
function computeReward(answer, correct, judgeScore, formatOk) {
const acc = answer === correct ? 1 : 0;
return acc + judgeScore + formatOk; // three axes summed
}
async function dapUpdate(policy, trajectories) {
// Single backward pass over combined rollouts (DAPO/GRPO variant)
const lossFn = () => computeLoss(trajectories); // placeholder loss
const grads = tf.variableGrads(lossFn);
policy.optimizer.applyGradients(grads.grads);
tf.dispose(grads);
}
// ---------------------------------------------------------------------
(async () => {
const policy = new Policy();
const toolPool = [];
for (let epoch = 0; epoch < 5; epoch++) {
// Build phase
const {toolCode, schema} = await buildTask(policy, []);
// Use phase
const answer = await useTask(policy, schema, 'What is the result?');
// Reward computation
const reward = computeReward(answer, true, 0.8, 1);
// Policy update
await dapUpdate(policy, [{obs: null, reward}]);
// Cache positive tools
if (reward > 0) {
toolPool.push({toolCode, schema});
}
}
})();
Cross-Examination & FAQs
A deeper dive clarifying mechanics, constraints, and baseline evaluations.
Q1. What is the primary goal of the SMITH framework?
SMITH aims to jointly train a single language model policy to both create reusable tools and apply those tools to solve tasks.
Q2. Does this approach require human-designed toolsets?
No, SMITH allows the model to synthesize its own tools expressed as Python functions and JSON schemas.
Q3. Is this framework useful for visual tasks?
Yes, SMITH demonstrated a 7.6 point improvement on GQA visual question answering benchmarks compared to baselines using the same backbone.
Q4. How does the model handle tool execution during training?
The model executes generated Python code at every step inside a sandbox to verify correctness.
Q5. Does SMITH support parallel tool execution?
No, the authors report they never observed the model issue parallel tool calls or generate multiple tools in a single turn.
Q6. What happens if we scale this model to larger sizes?
The paper does not know if these performance gains persist, saturate, or invert at the 70B parameter scale or higher.
Q7. Are there any safety guarantees for the generated tools?
The paper does not formally certify that adversarial prompts cannot induce the creation of unsafe tools.
Q8. What is the primary model architecture used?
The research uses Qwen3-4B-Instruct as the primary model and a 30B parameter model as the quality judge.
Q9. How was the training evaluated?
The model was trained on 13 procedural reasoning tasks from Reasoning-Gym and evaluated on both in-domain tasks and zero-shot transfer to TabMWP-Hard and GQA.