Abstract
TinyAgent is a framework enabling Small Language Models (SLMs) to perform complex function calling and task orchestration locally on edge devices. By leveraging specialized synthetic data and a novel "Tool RAG" retrieval method, a 1.1B parameter model was developed that outperforms GPT-4-Turbo in specialized assistant tasks while maintaining privacy and low latency on consumer hardware.
Introduction
Large Language Models (LLMs) like GPT-4o excel as agents capable of using tools and APIs. However, their size necessitates cloud-based inference, raising concerns regarding privacy, latency, and connectivity. Small Language Models (SLMs) typically lack the emergent reasoning required for complex planning. TinyAgent addresses this by focusing SLM capacity on task reasoning rather than general knowledge, enabling efficient local execution.
Methods
The TinyAgent framework introduces three primary innovations:
- LLMCompiler Integration: Instead of single tool calls, TinyAgent generates a Directed Acyclic Graph (DAG) of tasks, allowing for parallel execution and handling of inter-dependencies.
- Tool RAG via Classification: Replacing standard vector-based RAG, TinyAgent uses a fine-tuned DeBERTa-v3-small model as a multi-label classifier to select the necessary tools from a set of 16 macOS-specific functions. This approach achieved 99.8% recall and reduced prompt length by approximately 2x.
- Quantized Deployment: Models are quantized to 4-bit precision using
llama.cpp, enabling a 1.1B parameter model to run in just 0.68 GB of RAM.
The system was trained on a high-quality synthetic dataset of 80,000 examples generated by GPT-4-Turbo, focusing on realistic macOS assistant queries across 16 functions (Email, Contacts, SMS, etc.).
Results
TinyAgent demonstrates that specialized SLMs can exceed the performance of general-purpose LLMs in specific domains. The 7B model achieved an 85.14% success rate, while the 1.1B model reached 80.35%, both surpassing GPT-4-Turbo's 79.08% on the Mac-assistant benchmark.
On a MacBook Pro M3, the 1.1B model achieved a planning latency of 2.9 seconds. Quantization provided a 30% improvement in latency and a 4x reduction in size with minimal impact on accuracy.
Discussion and Conclusion
Key insights include the effectiveness of treating tool selection as a classification problem and the importance of negative samples during fine-tuning to teach the model to ignore irrelevant tools. While TinyAgent proves the viability of edge-based agents, human oversight remains crucial for safety. Future work will focus on scaling the toolset and mitigating teacher-model biases.
Summary updated