Needle2:14MB端侧Agent模型,面向手机与机器人
Needle2:14MB 端侧 Agent 模型,面向手机与机器人
45M
45M
Params
参数
800+ tok/s
800+ tok/s
Pi5 prefill
Pi5 预填充
500+ tok/s
500+ tok/s
Pi5 decode
Pi5 解码
CQ2-bit
CQ2 位
Compression
压缩
14 MB
14 MB
File size
文件大小
28 MB
28 MB
Session RAM
会话内存
Size–quality frontier: mobile-class and below
大小-质量前沿:移动级及以下
Figure 1. Ordered strict exact match on Mobile-Actions (google/mobile-actions eval split, 961 rows) against total parameters, over the smallest models designed for smart devices, mobile and below. Needle 2 is measured end-to-end through the shipped binary at CQ2-bit deployment precision with tool retrieval on; baselines run the released checkpoints under vLLM, and Apple FM runs on-device.
图 1. 在 Mobile-Actions(google/mobile-actions 评估分割,961 行)上,针对为智能设备、移动设备及以下设计的最小模型,按总参数排序的有序严格精确匹配。Needle 2 通过发布的二进制文件以 CQ2 位部署精度进行端到端测量,并启用工具检索;基线在 vLLM 下运行发布的检查点,Apple FM 在设备上运行。
Our Bet
我们的赌注
Bringing On-Device AI to <$200 Devices: Edge AI has lately meant Macs and PCs, but the edge is mostly cheap hardware: over 21 billion connected IoT devices against roughly 1.5 billion PCs, and in emerging markets most phones ship under $200. Count budget phones, Raspberry Pis, microcontrollers, wearables, small robots like Reachy Mini, and connected home devices, and roughly four in five edge devices cost under $200. That is the hardware Needle targets: no GPU, no NPU, a few hundred MB of RAM.
将设备端 AI 带到 <$200 设备:边缘 AI 近来意味着 Mac 和 PC,但边缘主要是廉价硬件:超过 210 亿个连接的物联网设备,而 PC 大约有 15 亿台,在新兴市场,大多数手机售价低于 200 美元。算上廉价手机、树莓派、微控制器、可穿戴设备、像 Reachy Mini 这样的小型机器人,以及智能家居设备,大约五分之四的边缘设备成本低于 200 美元。这就是 Needle 瞄准的硬件:没有 GPU,没有 NPU,只有几百 MB 的 RAM。
Function Call & Device Use: Turning on a light does not need a frontier model. A watch, a home, a robot: each already exposes its abilities as functions with typed parameters, so the only hard part is mapping a messy sentence onto them: which function, with which values. Framed that way, the problem needs no world knowledge and no open-ended prose, which is why 45M parameters suffice where chat needs billions. That smaller formulation is the bet everything else follows from.
函数调用和设备使用:打开灯不需要前沿模型。手表、家庭、机器人:每个都已经将其能力暴露为带有类型参数的函数,所以唯一困难的部分是将混乱的句子映射到它们上:哪个函数,用哪些值。这样来看,问题不需要世界知识,也不需要开放式散文,这就是为什么 45M 参数就足够了,而聊天需要数十亿。这个更小的表述是其他一切所依赖的赌注。
Extraction & Structured Outputs: The schema is the interface, and the same formulation covers documents: a schema plus a paragraph returns typed fields, an enum field is a classifier, an array field collects a list in one call. We enforce this with a contract, not a convention: every turn is answered with a call envelope, the empty call is the refusal, and a byte-level grammar compiled from the declared schemas constrains every token. The grammar carries the syntax, so all 45M parameters go to choosing functions and grounding arguments in the user's words.
提取和结构化输出:模式是接口,同样的表述也适用于文档:一个模式加上一个段落返回类型化字段,枚举字段是分类器,数组字段在一次调用中收集列表。我们通过契约而非约定来强制执行:每一轮都用调用信封回答,空调用是拒绝,从声明的模式编译的字节级语法约束每个标记。语法承载句法,所以所有 45M 参数都用于选择函数和将参数基于用户的词语。
Edge-Cloud Collaboration: No small model covers everything, so Needle says so instead of guessing: every response carries a learned confidence score, and off-topic requests return the empty call. Above your threshold, act; below it, re-ask or escalate to the cloud. Most device requests are routine control, so escalation stays rare and the default path stays private, instant, and free.
边缘-云协作:没有小模型能覆盖所有内容,所以 Needle 会说出来而不是猜测:每个响应都带有学习到的置信度分数,离题请求返回空调用。高于你的阈值,就行动;低于它,重新询问或升级到云端。大多数设备请求是常规控制,所以升级很少发生,默认路径保持私密、即时和免费。
Lossless 2bit Quantization: Small models break under post-hoc quantization, so we never quantize post-hoc: Needle 2 trains against Cactus Quants from pretrain through post-train, weights, activations, and KV cache alike. The 2bit model you deploy is the model that was trained. That is what fits 45M parameters into 14MB with nothing lost on our battery.
无损2比特量化:小模型在事后量化下会崩溃,因此我们从不进行事后量化:Needle 2从预训练到后训练,对权重、激活和KV缓存都使用Cactus Quants进行训练。你部署的2比特模型就是经过训练的模型。这就是将4500万参数装入14MB且电池零损耗的原因。
Co-designed Model & Inference: Every architectural choice was benchmarked on the target hardware before it earned its parameters, and the deliverable is the pair, not the weights: a single dependency-free C++ binary that probes the CPU at startup and picks its kernels, with the model, tokenizer, and grammar compiler sealed inside. One artifact runs from Cortex-M to x86 to WebAssembly. There is nothing to install and nothing to download.
协同设计的模型与推理:每一个架构选择在获得参数之前都在目标硬件上进行了基准测试,交付的是两者,而不仅仅是权重:一个无依赖的C++二进制文件,在启动时探测CPU并选择内核,模型、分词器和语法编译器封装在其中。一个工件即可从Cortex-M运行到x86再到WebAssembly。无需安装,无需下载。
Fine-tune on your Mac/PC: Every product has its own tool vocabulary, and a 45M model is small enough to retrain where it runs: the repo and python package tune and test on your own computer in minutes to a few hours. Ship a Needle that speaks your device's tools, not a generic assistant.
在Mac/PC上微调:每个产品都有自己的工具词汇表,而4500万参数的模型足够小,可以在运行的地方重新训练:代码库和Python包在几分钟到几小时内即可在您自己的计算机上调整和测试。发布一个能说您设备工具的Needle,而不是一个通用助手。
Production
生产
Needle is production-ready for products that require a minimal RAM footprint, low latency, privacy, and offline reliability. Pebble - the pioneer of the modern wearable industry - runs it locally in the Index 01 app to turn spoken requests into actions without depending on a network connection.
Needle已为需要最小RAM占用、低延迟、隐私和离线可靠性的产品做好生产准备。Pebble——现代可穿戴行业的先驱——在Index 01应用中本地运行它,将语音请求转化为操作,无需依赖网络连接。
“
“
The Pebble Index Ring has no screen. So when you speak to it, the action just has to happen, every time, with or without internet connection. We run Cactus Needle locally in the app, instead of relying on the cloud. The model's footprint is tiny and the performance never lets us down.
Pebble Index Ring没有屏幕。因此,当您对它说话时,操作必须每次都发生,无论有无网络连接。我们在应用中本地运行Cactus Needle,而不是依赖云端。模型占用空间极小,性能从不让我们失望。
Architecture
架构
The Simple Attention Network
简单注意力网络
Figure 2. The Simple Attention Network. Each block carries its update rule. Here x̂ is the RMS-normalised flattening of the four residual streams, H the orthonormal Walsh-Hadamard transform—a fixed matrix, applied in n log n time with no weights to read—(kᵢ, vᵢ) rows gathered from hashed n-gram tables, and P the doubly-stochastic normalisation of the routing logits A, computed by Sinkhorn iteration; a, b, g and all σ-gates are learned and input-dependent. Both attention and MLP residuals are sandwich-normed and gated, the engram sites fire at two layers, and decoding is constrained by a byte-level grammar compiled from the declared schemas.
图2. 简单注意力网络。每个块携带其更新规则。这里x̂是四个残差流的RMS归一化展平,H是正交Walsh-Hadamard变换——一个固定矩阵,以n log n时间应用,无需读取权重——(kᵢ, vᵢ)行从哈希n-gram表中收集,P是路由logits A的双随机归一化,通过Sinkhorn迭代计算;a、b、g和所有σ门都是可学习的且依赖于输入。注意力和MLP残差都经过三明治归一化和门控,记忆位点(engram sites)在两层触发,解码受从声明的模式编译的字节级语法约束。
Needle 2 is pretrained on a proprietary 115B-token corpus and post-trained on 38B tokens with compact reasoning traces and careful dataset distribution design. For scale: LFM2.5-230M was pretrained on 19 trillion tokens, roughly 120× Needle's total, and the evaluation below shows the two trading wins. Each component exists to buy capability without buying bandwidth. The Hadamard MLP replaces the usual dense up-and-down projections with a fixed Walsh transform and learned diagonals, so the channel mixing that dominates a small model's weight reads costs almost no parameters at all. The engram moves world knowledge out of the stack into hashed n-gram tables that are read a few rows per token: capacity that is nearly free at decode time, which matters on devices where every megabyte read from flash is latency and battery. The multi-lane residual streams give a 27-layer, 512-wide network the routing flexibility of a much wider one, at the cost of a few dot products per layer rather than more attention or MLP volume.
Needle 2 在一个专有的 1150 亿 token 语料库上进行预训练,并在 380 亿 token 上进行了后训练,采用了紧凑的推理轨迹和精心设计的数据集分布。作为规模参考,LFM2.5-230M 在 19 万亿 token 上进行了预训练,大约是 Needle 总 token 数的 120 倍,而下面的评估显示两者各有胜负。每个组件都是为了在不增加带宽的情况下获得能力。Hadamard MLP 用固定的 Walsh 变换和学习到的对角矩阵取代了通常的密集上下投影,因此主导小模型权重读取的通道混合几乎不消耗参数。engram 将世界知识从堆栈中移出,放入哈希 n-gram 表中,每个 token 只读取几行:这种容量在解码时几乎免费,这在闪存读取的每一兆字节都意味着延迟和电池消耗的设备上非常重要。多通道残差流为 27 层、512 宽的网络提供了比更宽网络更灵活的路由能力,代价是每层只需几个点积,而不是增加注意力或 MLP 的规模。
The memory system is designed backwards from fixed-RAM devices. Attention uses a 256-token sliding window so the KV cache is bounded no matter how long a session runs, and the system prompt and tool declarations are pinned as permanent sinks so the one thing a tool-calling model must never forget—its tools—is structurally unable to be evicted. The cache itself is trained with QAT, and weights are stored in Cactus Quants at a mixed bits per weight averaging 2bit. The result is that quality decisions and deployment decisions stay decoupled: one trained model, specialized to whatever precision and window a target device can afford.
记忆系统是面向固定 RAM 设备反向设计的。注意力使用 256 token 的滑动窗口,因此无论会话运行多长,KV 缓存都是有界的,并且系统提示和工具声明被固定为永久驻留,因此工具调用模型绝不能忘记的一件事——它的工具——在结构上无法被驱逐。缓存本身使用 QAT 训练,权重以 Cactus Quants 存储,平均每权重混合位数约为 2 位。结果是质量决策和部署决策保持解耦:一个训练好的模型,可以专门适配目标设备所能承受的任何精度和窗口。
The engine earns its speed from what it refuses to compute. Weights never decompress into RAM: the 2-bit codes are expanded inside vector registers, fused into integer dot products, so resident memory stays at blob size and the arithmetic path is int8 end to end—activations, KV cache, and the lane routing tables alike. The grammar is an optimization, not just a guarantee: because the matcher knows which tokens are legal before the logits exist, the engine computes output scores only for candidate rows, skipping up to 98% of the vocabulary projection on structural tokens, and skips it entirely on steps whose output is already forced. One universal binary probes the CPU at startup and self-selects its kernel tier—SDOT, NEON, AVX2, RISC-V vectors, wasm SIMD, or scalar—and the thread pool spins through the short serial sections of a token instead of sleeping, which alone nearly doubled decode. None of this changes a single output: every trick is either exact or validated token-for-token against the reference path.
引擎的速度源于它拒绝计算的内容。权重从不解压到内存中:2位码在向量寄存器内展开,融合为整数点积,因此常驻内存保持为blob大小,算术路径全程为int8——激活、KV缓存和通道路由表均如此。语法是一种优化,而不仅仅是保证:因为匹配器在logits存在之前就知道哪些token是合法的,引擎只计算候选行的输出分数,在结构token上跳过高达98%的词汇投影,并在输出已被强制的步骤上完全跳过。一个通用二进制在启动时探测CPU并自行选择其内核层级——SDOT、NEON、AVX2、RISC-V向量、wasm SIMD或标量——线程池在token的短串行段上旋转而不是休眠,这单独就使解码速度几乎翻倍。这些都不会改变任何输出:每个技巧要么是精确的,要么是逐token对照参考路径验证过的。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力