Towards Flexible Inference in Sequential Decision Problems via Bidirectional Transformers

Micah Carroll, Jessy Lin, Orr Paradise, Raluca Georgescu, Mingfei Sun, David Bignell, Stephanie Milani, Katja Hofmann, Matthew Hausknecht, Anca Dragan, Sam Devlin · DOI

TL;DR

This paper introduces FlexiBiT, a novel framework that unifies various sequential decision-making tasks (like behavior cloning and offline RL) under a single bidirectional Transformer model by treating them as different "masking schemes" of state-action-reward sequences. They demonstrate that a single FlexiBiT model, pre-trained with random masking, can perform multiple tasks effectively, often outperforming specialized models, and can be further improved with fine-tuning.

What Problem Does This Paper Address?

Traditional approaches to sequential decision-making tasks often involve training specialized models for each specific problem (e.g., one model for behavior cloning, another for inverse dynamics). This leads to a proliferation of models and a lack of generalization. The authors observe that many of these diverse tasks can be framed as predicting missing parts of a sequence of states, actions, and rewards. The challenge is to develop a unified framework that can handle this variety of inference tasks with a single model, leveraging the power of bidirectional Transformers, similar to how BERT revolutionized NLP.

Methods

The core innovation is the FlexiBiT framework, which treats sequential decision-making problems as sequence modeling tasks. Trajectories are represented as sequences of states ($s$), actions ($a$), and return-to-go ($R$). The key idea is to define different masking schemes for these sequences. A masking scheme dictates which parts of the input sequence are fed to the model and which parts the model is trained to predict.

  • Unified Task Formulation: Tasks like Behavioral Cloning (predicting the next action), Goal-Conditioned Imitation (predicting actions to reach a goal), Reward-Conditioned Imitation (offline RL, predicting actions for a target reward), and Inverse Dynamics (predicting past states given current state and action) are all formulated as specific masking patterns.
  • Bidirectional Transformers: The authors leverage bidirectional Transformer architectures (similar to BERT) which can attend to both past and future context in the sequence.
  • Random Masking Training: A crucial training strategy is random masking. Instead of training on specific task masks, the model is trained by randomly masking tokens in the input sequence with a certain probability. This forces the model to learn a general representation that can be adapted to various inference tasks.
  • Fine-tuning: After multi-task pre-training, the model can be further fine-tuned on a specific task to achieve even better performance.

Datasets

The experiments were conducted on a custom DoorKey minigrid environment. This environment is a 4x4 grid where an agent needs to pick up a key to open a locked door and reach a goal. The environment dynamics are deterministic, and trajectories were generated by a "noisy-rational" agent. The paper also mentions using different dataset sizes (50, 500, and 1000 trajectories) for training and evaluation.

Key Insights and Ideas

  • Masking as a Universal Language: The paper elegantly demonstrates that a wide range of sequential decision-making tasks can be unified under the concept of sequence masking, providing a powerful abstraction.
  • Random Masking for Generalization: Training with random masking, rather than specific task masks, leads to a more generalizable model that can perform multiple tasks "out-of-the-box" without task-specific heads. This suggests that learning to predict arbitrary missing parts of a trajectory is a strong self-supervised objective.
  • Bidirectional Transformers are Key: The bidirectional nature of Transformers is essential for effectively modeling the dependencies across the entire sequence, enabling tasks like inverse dynamics (predicting the past).
  • Multi-task Pre-training Boosts Single-task Performance: Even when the ultimate goal is a single task, pre-training with a diverse set of masked tasks (especially random masking) can lead to better performance than training a specialized model from scratch.

Key Results

  • A single FlexiBiT model trained with random masking achieved performance comparable to or better than specialized models on various tasks (Behavioral Cloning, Goal-Conditioned, Reward-Conditioned, Waypoint-Conditioned, Past Inference, Future Inference) in the minigrid environment, even before fine-tuning.
  • Fine-tuning the general FlexiBiT model on specific tasks further improved performance, often leading to the best results across the board.
  • The random masking approach showed a notable advantage over training on a pre-specified set of tasks (ALL), especially when considering a wider range of evaluation tasks.
  • The paper presents detailed validation loss heatmaps showing these comparative performances across different training regimes and dataset sizes.

Limitations and Future Work

  • Environment Complexity: The current results are limited to a simple minigrid domain. Scaling to more complex environments is a key direction for future work.
  • Property Conditioning: The framework can be extended to condition on or infer other properties of the trajectory beyond states, actions, and returns-to-go.
  • Short Context Lengths: The experiments used relatively short context lengths due to the quadratic complexity of self-attention. Future work could explore efficient Transformer variants.
  • Bayes Networks and Multi-Agent Settings: The authors suggest exploring whether the benefits of random masking extend to Bayes Networks and multi-agent scenarios.

Summary updated

BibTeX
@misc{carroll2022towards,
  author = {Micah Carroll and Jessy Lin and Orr Paradise and Raluca Georgescu and Mingfei Sun and David Bignell and Stephanie Milani and Katja Hofmann and Matthew Hausknecht and Anca Dragan and Sam Devlin},
  title = {{Towards Flexible Inference in Sequential Decision Problems via Bidirectional Transformers}},
  year = {2022},
  eprint = {2204.13326},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.13326},
}
Figure