BTGenBot: Behavior Tree Generation for Robotic Tasks with Lightweight LLMs

Riccardo Andrea Izzo, Gianluca Bardaro, Matteo Matteucci

Introduction

In the field of robotics, task planning—the process of translating high-level human objectives into executable action sequences—is a critical challenge. Traditionally, Behavior Trees (BTs) have served as the industry standard for representing these plans due to their modularity, reactivity, and human-readable structure. While large-scale Large Language Models (LLMs) like GPT-4 have demonstrated remarkable proficiency in generating BTs from natural language, their deployment in robotics is often hindered by high latency, significant computational requirements, and the necessity of persistent cloud connectivity.

BTGenBot introduces a framework designed to bridge this gap by enabling lightweight, 7-billion-parameter LLMs to generate complex, syntactically correct Behavior Trees. By specializing compact models through domain-specific fine-tuning, the researchers demonstrate that local, on-robot task planning is feasible without sacrificing the sophisticated reasoning capabilities of larger models.

Methodology

The BTGenBot framework utilizes a multi-stage pipeline to adapt general-purpose lightweight models for the specific constraints of robotic behavior generation. The research focused on three primary 7B-parameter models: Llama-2-7b, Llama-2-7b-chat, and CodeLlama-7b-Instruct.

Two-Stage Fine-Tuning

To transform these models into effective task planners, the authors employed a sequential fine-tuning strategy:

  1. Instruction Following: Models were first trained on the Alpaca dataset to establish general instruction-following capabilities.
  2. Domain Specialization: The models underwent Low-Rank Adaptation (LoRA), a parameter-efficient fine-tuning technique, using a specialized robotics dataset. This stage focused on teaching the models the specific XML syntax and logical hierarchies required for Behavior Trees.

Validation Pipeline

Generated trees were subjected to a rigorous three-tier validation process to ensure reliability:

  • Static Syntactical Analysis: Automated scripts checked the output for XML validity and structural integrity.
  • Semantic Evaluation: Human experts reviewed the logic to ensure the generated tree accurately reflected the user's prompt.
  • Physical Deployment: Validated trees were tested in both simulated environments (TurtleBot3) and on physical hardware (Agile Scout) to confirm real-world executability.

Dataset Development

A primary contribution of this work is the creation of a specialized instruction-following dataset consisting of 600 behavior trees. Unlike synthetic "toy" examples, these trees were harvested from real-world, open-source robotics projects. To create the necessary training pairs, the researchers used GPT-3.5 to generate natural language descriptions for each tree, resulting in a robust "instruction-output" dataset. Evaluation was conducted across nine benchmark tasks, ranging from basic navigation to complex "active vision and picking" routines.

Key Insights and Results

The study yielded several critical insights into the performance of lightweight models in specialized domains:

  • Efficiency of Specialization: Fine-tuned 7B models were found to outperform non-specialized 13B models, suggesting that domain-specific training is more impactful than raw parameter count for task-specific applications.
  • Syntactic Correctness: The inclusion of "one-shot" prompting—providing a single example within the prompt—dramatically improved performance. Fine-tuned models achieved between 86% and 100% syntactic correctness in initial testing phases.
  • Competitive Performance: In comparative benchmarks, the fine-tuned 7B models proved competitive with state-of-the-art "heavyweight" models like GPT-4o and Gemini across various navigation and manipulation tasks.
  • Hardware Feasibility: The researchers successfully performed inference on an NVIDIA Jetson AGX Orin. This demonstrates that BTGenBot can generate executable plans directly on robot hardware in a timeframe ranging from seconds to a few minutes, depending on the complexity of the task.

Discussion and Future Work

While BTGenBot represents a significant step toward autonomous, local robotic planning, several limitations remain. CodeLlama, for instance, occasionally hit token limits when generating overly verbose trees for complex tasks. Additionally, while the models excel at linear sequences, they still face challenges with complex "fallback" logic, such as multi-stage error recovery.

Future research will focus on implementing a closed-loop validation system. This would involve an auxiliary LLM acting as a "critic" to automatically identify and correct errors in the generated trees. Furthermore, the authors aim to incorporate dynamic "milestones" to allow robots to validate progress mid-task, moving beyond static pre-task planning toward more adaptive, real-time behavior generation.

Summary updated

BibTeX
@inproceedings{izzo2024btgenbot,
  author = {Riccardo Andrea Izzo and Gianluca Bardaro and Matteo Matteucci},
  title = {{BTGenBot: Behavior Tree Generation for Robotic Tasks with Lightweight LLMs}},
  booktitle = {IEEE/RSJ International Conference on Intelligent Robots and Systems},
  year = {2024},
  doi = {10.1109/iros58592.2024.10802304},
}
Figure