Command Palette
Search for a command to run...
Nanbeige4.2-3B: Unlocking Agentic Capabilities in a Compact Model
Nanbeige4.2-3B: Unlocking Agentic Capabilities in a Compact Model
One-click Deployment of Nanbeige4.2-3B: A Compact Agent Model
Abstract
We present Nanbeige4.2-3B, a compact general agentic model with 3B nonembedding parameters. It delivers strong performance across code-agent, officeagent, and complex tool-use tasks while maintaining highly competitive reasoning capabilities in mathematics, coding, and science. Nanbeige4.2-3B is pretrained from scratch on 28T tokens with a Looped Transformer that reuses the layer stack to increase capacity without adding parameters. For SFT data and trajectory construction, we expand the diversity of executable environments, task assets, and agentic scaffolds through real-world deployment and large-scale synthesis. Our RL pipeline applies mixed-mode RLHF over Think and Non-Think responses to improve overall model quality and reduce failure cases, length-controlled reasoning RL to balance accuracy and reasoning efficiency, and agentic RL with outcome and process rewards to stabilize long-horizon training. Extensive evaluations show that Nanbeige4.2-3B outperforms larger models, including Qwen3.5-9B and Gemma4-12B, across diverse agentic benchmarks while remaining competitive on reasoning and alignment tasks. Performance with OpenClaw further supports its use as a compact local personal assistant. The model checkpoint is available at https://huggingface.co/Nanbeige/Nanbeige4.2-3B.
One-sentence Summary
Nanbeige LLM Lab and Boss Zhipin introduce Nanbeige4.2-3B, a 3B-parameter agentic model pretrained from scratch on 28T tokens with a parameter-efficient Looped Transformer and refined via mixed-mode RLHF, length-controlled reasoning RL, and outcome-and-process-reward agentic RL, outperforming larger models such as Qwen3.5-9B and Gemma4-12B on code-agent, office-agent, and tool-use benchmarks while remaining competitive in reasoning and alignment.
Key Contributions
- A Looped Transformer architecture is used for pretraining from scratch on 28T tokens, increasing capacity without adding parameters to the 3B non-embedding budget.
- Supervised fine-tuning constructs execution-grounded trajectories across real-world and synthesized environments for code-agent, office-agent, and complex tool-use tasks, with trajectory-level and turn-level filtering via execution signals and rubric-based assessments.
- A multi-stage reinforcement learning pipeline applies mixed-mode RLHF, length-controlled reasoning RL, and agentic RL with outcome and process rewards; Nanbeige4.2-3B outperforms Qwen3.5-9B and Gemma4-12B on diverse agentic benchmarks and remains competitive on reasoning tasks.
Introduction
Building compact language models that can act as general-purpose agents across diverse environments remains an open challenge. Prior work typically produces small models specialized for single domains such as repository-level coding, leaving unclear whether one model can support code, office, and tool-use tasks without sacrificing general reasoning. The authors introduce Nanbeige4.2-3B, a 3B-parameter model that combines a Looped Transformer architecture with large-scale pretraining, execution-grounded supervised fine-tuning across hybrid environments, and a multi-stage reinforcement learning pipeline. The model achieves broad agentic capabilities while retaining competitive reasoning performance, outperforming much larger models on complex tool-use, office-agent, and code-agent benchmarks.
Dataset
The authors construct a multi-phase data pipeline covering pre-training and post-training stages. The dataset composition, processing, and usage are described below.
Pre-training data
- The pre-training corpus contains 28T tokens, surpassing previous work in both scale and quality.
- The data mixture is refined by upweighting mathematics, code, and synthetic QA data, which the authors find especially beneficial for compact models.
- A small proportion of agentic trajectory data is incorporated as an initial step toward agentic pre-training.
Post-training data: overview
- A large-scale, multi-domain post-training corpus is curated and synthesized, spanning Agentic Software Engineering, Complex Tool Use, and Agentic Cowork.
- Task diversity and difficulty are systematically expanded to push compact models toward their performance ceiling.
Agentic Software Engineering data
- Source: Historical GitHub development activities are transformed into executable tasks via a repository-level synthesis pipeline.
- Processing steps:
- Capability-guided code repository collection: Repositories are selected by analyzing model failure modes on seed tasks, targeting systematic weaknesses.
- Executable environment reconstruction: Container images are built from parent commits in isolated sandboxes; patches and grading tests are withheld from the agent.
- Verification and closed-loop task evolution: Tasks are validated with fail-to-pass and pass-to-pass tests. Recurring model failures feed back into repository mining to expand the task space.
- Trajectory synthesis across diverse scaffolds: Multiple agent scaffolds (Claude Code, OpenHands, SWE-agent, Codex-based drivers) solve the same tasks in parallel, producing scaffold-invariant reasoning trajectories.
- Execution-grounded turn-level filtering: Only trajectories whose patches pass target and regression tests are kept. Incorrect tool calls, non-terminating loops, redundant actions, and context truncations are filtered at the turn level.
- Schema: All trajectories are normalized into a unified multi-turn schema of observed assistant messages, tool calls, and environment feedback.
Tool Use data
- Source: Thousands of MCP tool specification documents collected from MCP marketplaces, assessed for composability and grouped into bundles.
- Processing steps:
- Python-based executable environment synthesis: An environment-synthesis agent fetches real-world data and reconstructs tools as callable Python functions.
- Task synthesis in hybrid environments: Three environment types are combined: live online MCP services, local Python-implemented tools, and model-simulated virtual tools.
- Difficulty taxonomy and adaptive task evolution: A predefined taxonomy (tool-use chain depth, information-retrieval difficulty, parameter-inference complexity) guides task generation. A solver agent’s success/failure feedback drives iterative difficulty increases.
- Rapid validation construction: A compact held-out task suite covering representative bundles, environment types, and difficulty levels is built for fast development validation; it is disjoint from training data.
Agentic Cowork data
- Source: Professional artifacts (reports, slide decks, spreadsheets, PDFs, emails) collected from domains such as finance, trade, law, and healthcare.
- Processing steps:
- Artifact repository construction: Materials are gathered with calibrated proportions for broad, realistic coverage.
- Embedding-based domain clustering: Artifacts are parsed, normalized, embedded, and clustered; multi-artifact bundles are sampled within clusters.
- Task, rubric, and trajectory synthesis: A task-synthesis agent manipulates bundles in a sandbox to produce tasks and evaluation rubrics. Difficulty is varied across cross-artifact dependencies, tool-use requirements, workflow length, constraints, and verification demands. Open-source models generate tool-use trajectories and deliverables; an independent judge evaluates fidelity, rubric consistency, and execution quality, retaining only high-quality samples.
- Closed-loop artifact recycling: Validated deliverables are re-ingested into the artifact repository to progressively expand the task distribution.
How the data is used
- Pre-training: The 28T-token mixture is used to train the base model, with adjusted sampling weights for math, code, synthetic QA, and a small agentic-trajectory component.
- Post-training: The synthesized trajectories from all three domains serve as supervision for fine-tuning compact models, aiming to improve agentic capabilities in software engineering, tool use, and office workflows. The rapid validation suite is used for development-stage assessment, not for training.
Method
To improve effective depth and reasoning capacity under a fixed parameter budget, the authors adopt a Looped Transformer architecture. After hidden states pass through the Transformer layers from bottom to top, they are fed through the same layer stack for an additional pass. This increases effective computational depth and model capacity without introducing another set of parameters. The authors find that training the looped architecture from scratch performs significantly better than upcycling a standard transformer, as the model benefits from adapting representations to repeated layer reuse throughout pre-training. A two-pass configuration is selected as it retains approximately 75% of the token efficiency relative to a standard Transformer while providing significant capacity gains. The full loop is retained without KV cache sharing to prioritize model performance.
The pre-training corpus comprises 28T tokens. The authors refine the data mixture by increasing the sampling weights of mathematics, code, and synthetic QA data, which are particularly beneficial for compact models, and incorporate a small proportion of agentic trajectory data as an initial step toward agentic pre-training.
The post-training pipeline combines scalable SFT data and trajectory construction across three domains: Agentic Software Engineering, Complex Tool Use, and Agentic Cowork.
For Agentic Software Engineering, the authors establish a repository-level data synthesis pipeline that transforms historical GitHub development activities into executable tasks. The system leverages model failure feedback to co-evolve task distribution alongside agent capabilities.
The pipeline involves capability-guided code repository collection, executable environment reconstruction in isolated sandboxes, and verification using fail-to-pass and pass-to-pass tests. Trajectory synthesis is conducted across diverse heterogeneous agent scaffolds, followed by execution-grounded turn-level filtering to retain only high-quality trajectories.
For Complex Tool Use, the authors scale trajectory synthesis by constructing hybrid environments that integrate real-world APIs, executable tool interfaces, and model-simulated environmental components.
The framework comprises MCP tool specification collection, Python-based executable environment synthesis, task synthesis in hybrid environments (combining live online MCP services, local Python tools, and model-simulated virtual tools), and a difficulty taxonomy that supports automated labeling and adaptive task evolution.
For Agentic Cowork, the authors develop an artifact-centric curation pipeline to synthesize, evolve, and recycle task artifacts for complex office workflows.
This pipeline includes artifact repository construction across diverse professional domains, embedding-based domain clustering to form multi-artifact bundles, task and trajectory synthesis with iterative difficulty evolution, and closed-loop artifact recycling where validated deliverables are re-ingested for subsequent synthesis rounds.
The training recipe consists of four stages: supervised fine-tuning (SFT), two-stage RLHF for hybrid thinking, reasoning RL with length control, and agentic RL with action-centric rubrics.
Starting from the pretrained checkpoint, the authors conduct SFT with a three-stage curriculum that progressively extends the maximum training context from 64K to 128K and 256K tokens. The distribution of supervised target tokens gradually shifts from STEM-centered reasoning toward long-horizon agentic interaction.
In the 64K stage, the mixture is dominated by reasoning-oriented STEM data. In the 128K stage, it transitions toward longer-context instruction following and tool use. In the 256K stage, the primary objective shifts to agentic capability. To handle incorrect intermediate turns, a binary loss mask mt is assigned to each assistant turn using execution feedback. Unreliable turns are excluded from the SFT loss (mt=0) but retained in the context, allowing the model to learn recovery from mistakes.
Following SFT, a two-stage RLHF procedure is applied to address unstable generation behaviors such as repetitive reasoning and delayed termination. A point-wise reward model evaluates response quality, favoring correct, well-formatted, and properly terminated outputs. The authors find that behavioral regularization from general-purpose RLHF generalizes across tasks and across think and non-think modes.
Next, reasoning RL is conducted to strengthen Think-mode capability while constraining reasoning length. A problem-dependent length-control objective combines a fixed length budget with a continuous, difficulty-aware penalty. For each problem q, the length budget bq is set to the median length of correct historical rollouts. The final reward is shaped as:
ri=ribase−αpq[Lmax−bqLi−bq]01where [x]01=min(max(x,0),1), α>0 bounds the penalty magnitude, and pq is the fraction of fully correct responses in the current rollout group. This penalty is difficulty-aware, encouraging concise reasoning on reliably solved problems while preserving exploration on difficult ones.
Finally, agentic RL is performed using action-centric rubrics to diagnose behavioral deficiencies. These rubrics measure dimensions such as tool-call accuracy and information gain, serving as process-level rewards. The authors restrict agentic RL to relatively easy tasks with short trajectories and higher pass rates to ensure stable optimization.
The training dynamics show that combining outcome and action-centric process rewards suppresses recurrent action errors and improves end-task performance, with the normalized action error rate decreasing by approximately 20% and the overall score improving during training.
Experiment
The pre-training evaluation demonstrates that combining a Looped Transformer architecture with an improved data recipe yields consistent gains over the prior model and outperforms comparable base models on reasoning and knowledge benchmarks. In post-training, an agentic reinforcement learning stage with action-centric rubrics and data selection focused on easier, short-horizon tasks reduces recurrent action errors by about 20% and lifts overall task scores. The full RL pipeline produces a checkpoint that achieves higher accuracy with fewer output tokens across reasoning, coding, alignment, and agentic benchmarks. Comprehensive evaluations show that the resulting 3B-parameter model surpasses larger alternatives on general agent, code agent, and most reasoning tasks, while also outperforming them as a unified local personal assistant across daily, office, and deep research scenarios.
Nanbeige4.2-3B-Base, a 3B non-embedding parameter model, consistently outperforms its predecessor Nanbeige4-3B-Base and other similarly sized base models across both reasoning-oriented and knowledge-oriented benchmarks. The improvements are attributed to combining a Looped Transformer structure with an enhanced pre-training data recipe. Nanbeige4.2-3B-Base achieves the highest scores on all six reported benchmarks compared to Nanbeige4-3B-Base, Qwen3.5-4B-Base, and Gemma4-E4B-Base. The largest relative gains for Nanbeige4.2-3B-Base over its predecessor appear on knowledge-oriented metrics such as MMLU-Pro and SuperGPQA. On reasoning tasks, Nanbeige4.2-3B-Base shows strong performance, notably surpassing Qwen3.5-4B-Base by a wide margin on GSM8K. Gemma4-E4B-Base, despite having the largest total parameter count, records the lowest scores across all benchmarks in this comparison.
Two-stage RLHF progressively reduces failure modes and output length while improving accuracy across alignment, reasoning, and agentic benchmarks. Behavioral regularization from general-purpose RLHF generalizes across tasks and from non-think to think mode, suggesting that structured generation and termination awareness are shared capabilities rather than mode-specific skills. Alignment bad-case rate drops from 17% after SFT to 2% after Non-Think RLHF, while accuracy rises from 50% to 57%. On LiveCodeBench, accuracy improves from 65.45% to 72.10% and the bad-case rate reaches zero after Non-Think RLHF. Average response length shrinks substantially in both alignment and reasoning evaluations, falling by over half after the full RLHF pipeline. Non-Think RLHF, trained primarily on general queries, reduces cyclic reflection and abnormal continuation even in Think-mode generation.
Nanbeige4.2-3B, with only 3B non-embedding parameters, achieves the best results on all reported general-agent and code-agent benchmarks, outperforming larger models such as Qwen3.5-9B and Gemma4-12B. It also leads on five of six reasoning benchmarks while remaining competitive on alignment tasks, demonstrating a strong overall balance across agentic, reasoning, and alignment evaluations under a substantially smaller parameter budget. Nanbeige4.2-3B scores 74.3 on GDPval Rubrics, surpassing Gemma4-12B (68.5) and Qwen3.5-9B (61.9). On AgentIF-Oneday, Nanbeige4.2-3B reaches 67.5, exceeding Qwen3.5-9B (60.4) and Qwen3.5-4B (56.9). Nanbeige4.2-3B achieves 74.7 on PinchBench-V2, outperforming Qwen3.5-9B (68.2) and Gemma4-12B (53.8). For OfficeQA-Pro, Nanbeige4.2-3B obtains 21.1, compared to 15.8 for Qwen3.5-9B and 15.3 for Gemma4-12B. Nanbeige4.2-3B leads on five of six reasoning benchmarks while Gemma4-12B performs better on IF-Bench and Recruit-Bench alignment tasks.
Nanbeige4.2-3B outperforms both Qwen3.5-4B and the larger Qwen3.5-9B across all six local personal assistant benchmarks under the OpenClaw framework, with particularly strong gains in office workflows. The model demonstrates consistent advantages in daily tasks, office productivity, and deep research scenarios despite having fewer parameters than the 9B comparison model. Nanbeige4.2-3B leads all six benchmarks, with the largest margins appearing in office tasks such as GDPval (68.8 vs 38.0 for Qwen3.5-9B) and AgentIF-Oneday (58.9 vs 32.1). On daily task benchmarks, Nanbeige4.2-3B scores 74.7 on Pinch-Bench-V2 and 65.0 on Claw-Gym, surpassing Qwen3.5-9B by over 6 and nearly 9 points respectively. The model achieves the highest scores on both deep research benchmarks while using only 3B non-embedding parameters, compared to the 9B Qwen3.5 alternative.
The first experiment evaluates Nanbeige4.2-3B-Base against its predecessor and other similarly sized base models, showing that architectural changes and improved pre-training data yield consistent gains on both reasoning and knowledge benchmarks. A second study on two-stage RLHF demonstrates that behavioral regularization reduces failure modes and output length while boosting accuracy across alignment, reasoning, and agentic tasks, with benefits transferring from non-think to think-mode generation. Subsequent evaluations of the full Nanbeige4.2-3B model reveal that, despite its 3B non-embedding parameters, it outperforms larger alternatives on general-agent and code-agent benchmarks and leads on most reasoning tasks, maintaining competitive alignment results. Finally, under the OpenClaw framework, Nanbeige4.2-3B surpasses both smaller and larger comparison models on all local personal assistant benchmarks, with especially pronounced advantages in office workflows and deep research scenarios.