# Needle：将 Gemini 工具调用能力蒸馏为 26M 参数的开源模型

Cactus Compute 团队发布了 **Needle**——一个将 Gemini 3.1 的工具调用（function calling）能力蒸馏为仅 **26M 参数**的"简单注意力网络"（Simple Attention Network），可在本地 Mac/PC 上运行甚至微调。

## 核心架构

- **参数规模**：d=512, 8H/4KV, BPE=8192, tied embeddings
- **网络结构**：Encoder（12 层 self-attention，无 FFN）+ Decoder（8 层 cross-attention）+ 工具调用头
- **生产速度**（在 Cactus 平台上）：Prefill 6000 toks/s，Decode 1200 toks/s
- **训练成本**：
  - 预训练：16 块 TPU v6e 上训练 200B tokens（约 27 小时）
  - 后训练：2B tokens 单次函数调用数据集（约 45 分钟）
- **开源协议**：MIT

## 性能对比

在单次函数调用任务上，Needle 超越了：
- FunctionGemma-270M
- Qwen-0.6B
- Graninte-350M
- LFM2.5-350M

团队也诚实指出，更大模型在多轮对话和通用场景中仍有优势。Needle 专注于**轻量级、可本地部署的工具调用**这一细分场景。

## 使用方式

**快速体验：**
```bash
git clone https://github.com/cactus-compute/needle.git
cd needle && source ./setup
needle playground
```
自动打开 Web UI（http://127.0.0.1:7860），权重自动下载。

**微调：**
```bash
needle finetune data.jsonl
# 或通过 Web UI 的 Playground 交互式微调
```

## 意义

Needle 代表了"大模型蒸馏为小模型"这一趋势的最新进展——将顶级大模型（Gemini 3.1）的特定能力浓缩到可在消费级硬件上运行的小模型中。对于个人 AI 助手、边缘设备、隐私敏感场景具有重要价值。

权重已开源至 HuggingFace：[Cactus-Compute/needle](https://huggingface.co/Cactus-Compute/needle)

---

## 参考链接

- [Needle | GitHub](https://github.com/cactus-compute/needle)
- [Show HN: Needle: We Distilled Gemini Tool Calling into a 26M Model | Hacker News](https://news.ycombinator.com/item?id=48110593)
