Cactus Needle: A 26M Parameter Function Calling Model

Cactus Needle: A 26M Parameter Function Calling Model

Overview

Cactus Needle 是一個僅有 2600 萬參數的開源函數調用(function calling)模型,旨在單次調用(single-shot)工具時表現優於規模大得多的模型。它針對邊緣端部署進行了優化,在消費級硬體上可以達到每秒 6,000 個 token 的 prefill 速度和每秒 1,200 個 token 的生成速度。

Architecture: The Simple Attention Network

Needle 利用了一種「簡單注意力網絡」(simple attention network),與標準的 Transformer 架構有根本的不同,它移除了所有的多層感知器(MLPs)和密集層(dense layers)。

Removal of Knowledge Stores

在典型的 Transformer 中,前饋網絡(FFN)層被認為是模型的知識儲存庫,事實和世界知識都保留在其中。Cactus Needle 完全移除了這些層,僅依靠注意力機制(attention)和門控機制(gating)進行運作。這種設計選擇是基於一個前提:工具調用在本質上是一個檢索與組裝的任務——將查詢與工具名稱進行匹配並提取參數——而不是一個需要深度推理或廣泛內部知識的任務。

Technical Specifications

  • Structure: A 12-encoder stack utilizing self-attention with Group Query Attention (GQA).
  • Design: An encoder-decoder architecture rather than a decoder-only GPT style.
  • Training: The model was pre-trained on 200 billion tokens using 16 TPUs for 27 hours, followed by post-training on 2 billion tokens of synthetic function calling data across 15 tool categories.
  • Optimization: The team employed quantization-aware training to ensure the model remains performant when compressed for edge devices.

Performance and Benchmarks

Cactus Needle 是為單次函數調用設計的。據報導,在此特定領域,它的表現優於規模大 10 倍到 20 倍的模型,包括 Function Gemma, IBM Granite, LFM, 和 Qwen 600M。

然而,該模型並不打算取代大型語言模型(LLMs)來處理複雜任務。它在以下方面可能會遇到困難:

  • 並行函數調用(Parallel function calling)。
  • 需要對多個工具進行複雜推理的任務。
  • 涉及漸進式揭露(progressive disclosure)的「技能」。

Practical Application and Deployment

由於其極小的佔用空間,Needle 可以部署在低功耗硬體上,例如行動裝置、Raspberry Pis 或嵌入式系統(例如:智慧家電)。

Zero-Shot and Fine-Tuning Capabilities

當提供工具的 JSON 定義時,Needle 展示了強大的零樣本(zero-shot)能力。即使是對於它沒有經過明確訓練的函數——例如由 Claude 生成的智慧家庭控制——該模型也能準確地將用戶意圖映射到正確的函數並提取參數。

對於專門的使用案例,該模型可以在 CPU 上進行微調(fine-tuning),而不需要 GPU。提供的 GitHub 儲存庫包含 JAX 代碼(使用 Flax 和 Optax)以促進此過程。

The Cascade Architecture Strategy

Cactus 提倡一種「級聯架構」(cascade architecture),即由小型、專業化的模型處理特定的工具集。在此系統中,一個小型模型可以充當路由(router),決定查詢屬於哪組工具集,然後將任務委派給另電一個專業的小型模型,或者在需要複雜推理時退回到較大的雲端模型。

Sources