NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Swarm Behavior Cloning

Jonas Nüßlein, Maximilian Zorn, Philipp Altmann, Claudia Linnhoff-Popien

TL;DR

Swarm Behavior Cloning (SBC) is a novel imitation learning technique that improves ensemble-based agents by encouraging them to align their internal representations. By penalizing disagreements in hidden layer activations during training, SBC prevents the "aggregation trap" where averaging divergent actions leads to poor performance, resulting in significantly more robust agents in complex environments.

What Problem Does This Paper Address?

Behavior Cloning (BC) is the simplest form of Imitation Learning: an agent learns to mimic an expert's actions using supervised learning on a dataset of state-action pairs. While easy to implement and entirely "offline" (requiring no environment interaction), BC suffers from distribution shift—when the agent encounters a state slightly different from the training data, its errors compound, leading it into unfamiliar territory where it fails completely.

Ensemble methods, which average the predictions of multiple BC models, are a common fix to improve robustness. However, the authors identify a critical flaw: in states underrepresented in the training data, ensemble members often predict wildly different actions. When these divergent actions are averaged (aggregated), the resulting "middle-ground" action can be worse than any individual prediction. For example, if one model suggests "dodge left" and another "dodge right," the average might be "stay center," leading to a collision.

This figure visualizes how SBC clusters predicted actions more closely compared to standard ensembles, avoiding suboptimal "middle-ground" actions.

Methods

The authors propose Swarm Behavior Cloning (SBC). Unlike standard ensembles where $N$ policies are trained independently, SBC trains them simultaneously using a joint loss function.

The core innovation is a regularization term added to the standard supervised learning loss. This term penalizes the pairwise squared difference between the hidden layer activations ($h_{ik}$) of all policies in the ensemble for the same input state.

The adjusted loss function looks like this: $$L(s,a) = \sum_{i} (\pi_i(s)-a)^2 + \tau \sum_{k} \sum_{i<j} \|h_{ik}(s)-h_{jk}(s)\|^2$$

  • First term: Standard BC loss (mimic the expert).
  • Second term: Swarm regularization (align internal representations).
  • $\tau$: A hyperparameter that balances expert mimicry with internal alignment.

By forcing the models to "agree" on the internal features of a state, the final output actions become more consistent, even in states the models haven't seen often.

Datasets

The researchers evaluated SBC across eight diverse OpenAI Gym environments, covering both discrete and continuous action spaces:

  • Locomotion: HalfCheetah, Ant, Hopper, Walker2D, BipedalWalker.
  • Classic Control: CartPole, Acrobot, LunarLander-continuous.

Expert demonstrations were generated using state-of-the-art Reinforcement Learning agents (SAC for continuous tasks, PPO for discrete ones). The training datasets were intentionally small, containing only 1 to 8 expert episodes, to highlight how the models handle underrepresented states.

Key Insights and Ideas

  • The Aggregation Trap: Figure 2 in the paper (and the visualization below) demonstrates that in high-variance states, the Q-value (expected reward) of the aggregated action is often lower than that of any individual ensemble member. SBC effectively "shrinks" the spread of these predictions toward a higher-value consensus.
  • Internal vs. External Alignment: Instead of just forcing the outputs to be the same, SBC forces the internal features to align. This preserves some computational diversity while ensuring the models are "looking" at the state in a similar way.
  • Theoretical Mode-Seeking: The authors provide a theoretical proof showing that SBC approximates finding the global mode of the hidden feature distribution. As the ensemble size $N$ grows and the regularization becomes stricter, the ensemble converges on the most probable internal representation based on the training data.
Visualizing the "Mean Action Difference" across an episode. In areas of high disagreement (right heatmaps), the aggregated black dot often falls into lower-value red zones.

Key Results

SBC consistently outperformed both single-model BC and standard Ensemble BC across almost all environments, particularly as the complexity of the task increased.

  • Performance Boost: In the high-dimensional HalfCheetah environment, SBC achieved a scaled return of 0.72 with 8 expert episodes, compared to just 0.17 for standard Ensemble BC.
  • Reduced Divergence: SBC significantly reduced the "Mean Action Difference" (MAD). For instance, in BipedalWalker, the disagreement between models was reduced by 44%, and in Ant, it was reduced by 11%.
  • Robustness to Data Scarcity: SBC showed the most significant gains when training data was extremely limited, proving its utility for real-world scenarios where expert demonstrations are expensive to collect.
Performance curves across 8 environments show SBC (orange) consistently reaching higher returns than standard BC (blue) and Ensemble BC (purple).

Limitations and Future Work

  • Hyperparameter Tuning: The performance of SBC is sensitive to the regularization coefficient $\tau$. While the authors found $\tau = 0.25$ worked well across their tests, different architectures or environments might require specific tuning.
  • Computational Cost: Training $N$ models simultaneously with a pairwise penalty increases memory and computation time linearly with the ensemble size.
  • Architecture Scope: This study focused on Multi-Layer Perceptrons (MLPs). Future research could explore how this "swarm" alignment works with more complex architectures like Convolutional Neural Networks (CNNs) for vision-based tasks or Transformers.

Summary updated

BibTeX
@inproceedings{nulein2025swarm,
  author = {Jonas Nüßlein and Maximilian Zorn and Philipp Altmann and Claudia Linnhoff-Popien},
  title = {{Swarm Behavior Cloning}},
  booktitle = {ICAART},
  year = {2025},
  doi = {10.5220/0013086600003890},
}
Figure