Behaviour cloning with transformers

A modified Behavior Transformer (BeT) policy for the PushT manipulation task, trained with Hugging Face LeRobot.

Personal project (July 2025).

Behaviour cloning learns a policy directly from demonstrations: show the robot how a task is done, and train a model to map what it sees to what it should do next. I adapted a Behavior Transformer (BeT) to Hugging Face’s LeRobot framework and trained it on the PushT task, where the agent has to push a T-shaped block into a target pose.

Demonstrations of the same task are multi-modal: you can push the block around the left or the right side, and averaging the two gives a policy that does neither. BeT handles this with action discretisation (k-means bins over the action space) plus a learned offset correction that recovers continuous actions.

BeT policy rollout on PushT
Training and evaluation loss
Left: a rollout of the trained policy on PushT. Right: training and evaluation loss.

Code: behaviour_transformer_policy.

Stack: Python, PyTorch, LeRobot, transformers, imitation learning.