TinyToolUse-Qwen2-0.5B-Calculator

A fine-tuned version of Qwen/Qwen2-0.5B trained for calculator tool usage using the Tiny Tool Use library.

Model Description

This model has been fine-tuned to understand and execute calculator tool calls. It can perform mathematical calculations by generating appropriate tool call syntax.

  • Base Model: Qwen/Qwen2-0.5B
  • Training Method: Supervised Fine-Tuning (SFT)
  • Training Library: Tiny Tool Use
  • Tool: Calculator (mathematical expressions)
  • Parameters: 500M
  • Architecture: 24 layers, 896 hidden dimensions

Training Details

  • Training Data: 4 custom calculator examples
  • Training Steps: 3 steps, 1 epoch
  • Training Time: ~8.5 seconds
  • Hardware: CPU training (RTX 4060 available but CUDA compatibility issues)
  • Precision: float32

Usage

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("your-username/TinyToolUse-Qwen2-0.5B-Calculator")
model = AutoModelForCausalLM.from_pretrained("your-username/TinyToolUse-Qwen2-0.5B-Calculator")

# Example usage
prompt = "Human: What is 15 + 27?\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt")

with torch.no_grad():
    outputs = model.generate(
        inputs.input_ids,
        max_new_tokens=100,
        temperature=0.7,
        do_sample=True,
        pad_token_id=tokenizer.eos_token_id
    )

response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)

Expected Output Format

The model should generate responses in the format:

tool_code: print(calculator(expression='15 + 27'))

Tool Definition

The model was trained with this calculator tool definition:

{
  "name": "calculator",
  "description": "Perform mathematical calculations",
  "type": "function",
  "parameters": {
    "type": "object",
    "properties": {
      "expression": {
        "type": "string",
        "description": "Mathematical expression to evaluate"
      }
    },
    "required": ["expression"]
  }
}

Training Examples

The model was trained on these examples:

  • "What is 2 + 2?" โ†’ tool_code: print(calculator(expression='2 + 2'))
  • "Calculate 10 * 5" โ†’ tool_code: print(calculator(expression='10 * 5'))
  • "What is 100 / 25?" โ†’ tool_code: print(calculator(expression='100 / 25'))
  • "Find the value of 3 to the power of 4." โ†’ tool_code: print(calculator(expression='3 ** 4'))

Limitations

  • Small training dataset (4 examples)
  • CPU-only training due to CUDA compatibility issues
  • Limited to calculator tool only
  • May require additional fine-tuning for production use

Framework

This model was trained using the Tiny Tool Use library, which provides:

  • Multiple training methods (SFT, DPO, Teacher Mode)
  • Flexible data generation strategies
  • Integration with Berkeley Function-Calling Leaderboard
  • Support for various LLM architectures

Citation

@misc{tinytooluse2024,
  title={Tiny Tool Use: Training Open-Source LLMs for Tool Usage},
  author={Bagel Labs},
  year={2024},
  url={https://github.com/bagel-org/bagel-RL}
}

License

MIT License - see the LICENSE file for details.

Downloads last month
10
Safetensors
Model size
494M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for 2reb/TinyToolUse-Qwen2-0.5B-Calculator

Base model

Qwen/Qwen2-0.5B
Finetuned
(103)
this model
Quantizations
1 model