BTGenBot-2: Efficient Behavior Tree Generation with Small Language Models

Riccardo Andrea Izzo, Gianluca Bardaro, Matteo MatteucciarXiv 2026

TL;DR

BTGenBot-2 is a 1B-parameter open-source Small Language Model (SLM) that directly converts natural language descriptions into executable, ROS2-compatible Behavior Trees (BTs). Designed to run locally on resource-constrained robots, it features novel inference and runtime error-recovery mechanisms and outperforms massive proprietary models like GPT-5 and Claude Opus 4.1 in both accuracy and speed.

What Problem Does This Paper Address?

Deploying Large Language Models (LLMs) for robotic task planning faces two major hurdles: high computational demands and a lack of standardized execution formats. Most state-of-the-art approaches rely on closed-source, cloud-based APIs (like OpenAI's GPT series). This makes them impractical for real-world robots operating in offline, low-latency, or resource-constrained environments. Furthermore, translating loose natural language into rigid, executable robot code often leads to syntax errors or "hallucinated" actions that the robot cannot physically perform.

The authors tackle this by focusing on Behavior Trees (BTs)—a highly modular and reactive framework widely used in the Robot Operating System (ROS2) ecosystem. They address the challenge of generating valid, safe, and structurally sound BTs directly on edge devices without cloud dependencies.

Methods

BTGenBot-2 is built upon Llama-3.2-1B-Instruct, a lightweight, open-source base model. To make it a specialist in robotics planning, the authors implemented several key techniques:

  1. Parameter-Efficient Fine-Tuning (PEFT): They utilized QLoRA (Quantized Low-Rank Adaptation) to fine-tune the model. By targeting both attention and MLP layers, they achieved high training accuracy (>95%) while keeping the model small enough to run on consumer-grade hardware.
  2. Inference Time Validator: To prevent hallucinations, a validation layer constrains the model's decoding process. It forces the output into a valid XML schema and restricts the vocabulary strictly to predefined robot action primitives defined in a YAML configuration file.
  3. Runtime Validator & Subtree Regeneration: If a robot encounters an unexpected failure during execution that local recovery behaviors (like Fallback or Retry loops) cannot fix, an inline C++ logger captures the error state. The system then queries the local SLM to regenerate only the failing subtree rather than replanning the entire task from scratch.
Fig. 1. We present BTGenBot-2, a 1B-parameter open-source small language model (SLM), trained on 5k natural language instructions and behavior tree pairs from a synthetic instruction-following dataset. BTGenBot-2 achieves state-of-the-art performance in generating directly executable behavior trees. We open-source our synthetic dataset, model weights, codebase, and the BT Benchmark to support dissemination and reproducibility.

Datasets

The authors introduced two major contributions to the robotics community:

  • Synthetic Instruction-Following Dataset: Starting with 594 real-world validated BTs from the open-source TSE dataset, the authors used an evolutionary generation process with gpt-4o-mini to expand the corpus into 5,204 pairs of executable BTs and natural language descriptions.
  • Standardized BT Benchmark: To evaluate performance, they created a comprehensive benchmark consisting of 52 tasks spanning navigation and manipulation, implemented in NVIDIA Isaac Sim. The tasks are categorized into Easy, Medium, and Hard difficulties, with the hard tasks intentionally designed to be out-of-distribution to test the model's generalization limits.
Fig. 2. Dataset generation. Starting with the TSE dataset, a new instruction- following dataset is created through four key steps: (1) cleanse the raw XML data, (2) for each original BT, use gpt-4o-mini to generate three variants, (3) repeat step 2 with the new dataset, (4) merge all resulting datasets while producing a natural-language description for each BT.

Key Insights and Ideas

  • Small Specialists Can Beat Generalist Giants: A 1B-parameter model, when properly fine-tuned on domain-specific structured data, can outperform frontier models like GPT-5 and Claude Opus 4.1 at generating specialized code (XML Behavior Trees).
  • Constrained Decoding is Essential for Safety: By embedding a grammar/vocabulary check directly into the inference pipeline, the authors eliminated the risk of the robot attempting unprogrammed actions.
  • Local Reactivity via Subtrees: Instead of traditional full-plan invalidation, treating plans as trees allows the robot to surgically repair broken execution paths at runtime, drastically increasing robustness.

Key Results

  • Success Rates: In zero-shot settings, BTGenBot-2 achieved an average success rate of 84.61%, which jumped to 90.38% when utilizing the Error Recovery (ER) module. In one-shot settings, the error-recovery version reached a staggering 98.07% success rate.
  • Comparison to Baselines: BTGenBot-2-ER outperformed GPT-5 Thinking (71.15% zero-shot) and Claude Opus 4.1 (65.38% zero-shot).
  • Inference Speed: BTGenBot-2 generates a complete tree in approximately 11 seconds on an NVIDIA GTX 1080 GPU—making it up to 3× faster than proprietary reasoning models and 16× faster than its 7B-parameter predecessor, BTGenBot.
  • Real-World Validation: The pipeline was successfully validated on physical hardware, including an AgileX Scout mobile robot and an SO-ARM 101 manipulator, achieving a 18/18 success rate on easy tasks with error recovery.

Limitations and Future Work

While BTGenBot-2 excels at generating trees within a known action space, it still struggles with highly complex, out-of-distribution "Hard" tasks in zero-shot scenarios without error recovery. Additionally, the model relies on a closed vocabulary of action primitives. The authors suggest that future work could explore open-vocabulary planning or dynamic primitive discovery, allowing the model to adapt to entirely new robot capabilities on the fly.

Summary updated

BibTeX
@misc{izzo2026btgenbot,
  author = {Riccardo Andrea Izzo and Gianluca Bardaro and Matteo Matteucci},
  title = {{BTGenBot-2: Efficient Behavior Tree Generation with Small Language Models}},
  year = {2026},
  eprint = {2602.01870},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.01870},
}
Figure