Discrete Actions for Naturalistic Behavior in Embodied Biomechanical Animal Models
Pretrained models for Code2Act, a controller that executes an externally defined discrete behavioral vocabulary on a biomechanical rat in MuJoCo.
NeurIPS 2026 Workshop on Neuro-Symbolic Embodied Intelligence (NEmo), oral.
Paper Β· Project page Β· Code
The pipeline has three stages:
- Stage 1 β MIMIC-MJX imitation VAE (encoder β 16-d intention, decoder β torques).
- Stage 2 β a frozen discrete vocabulary, one code per frame (
best_codes.npz). - Stage 3 β a GRU controller trained with PPO plus a distillation KL to the frozen Stage-1 encoder.
Layout
controllers/ Stage-3 controllers, one folder per vocabulary
stage1_mimic/ Stage-1 imitation VAEs
vocabularies/ Stage-2 code sequences and the tokenizers that produced them
code_priors/ Autoregressive priors over code sequences (GPT-2, Mamba, S5, HMM)
Controllers
| Folder | Vocabulary | K | Step | Training run |
|---|---|---|---|---|
controllers/kpms_k100/ |
Keypoint-MoSeq syllables | 100 | 249 | 260611_073323_750085 |
controllers/kvae_k25/ |
Kinematics VAE + K-means | 25 | 249 | 260603_180852_140475 |
controllers/mlb_k9/ |
Manually labeled behavior Γ direction | 9 | 208 | 260629_212713_669229 |
controllers/mlb_k9_end_of_training/ |
same run, last step | 9 | 499 | 260629_212713_669229 |
The MLB results in the paper use step 208 (controllers/mlb_k9/).
Each folder holds one Orbax step (MoSeqPPONetwork_<step>/ with config/,
policy/, train_state/).
Stage-1 checkpoints
| Folder | Role | Step | Training run |
|---|---|---|---|
stage1_mimic/distillation_target/ |
Distillation target and decoder initialization for all three controllers | 99 | 260413_040706_764936 |
stage1_mimic/expert_reference/ |
"Expert MIMIC-MJX" reference in the KID and gait comparisons | 47 | 260405_235031_234849 |
Vocabularies
| Folder | Codes | Tokenizer |
|---|---|---|
vocabularies/kpms_k100/ |
best_codes.npz |
AR-HMM fit in keypoint_arhmm_states100_seed4/; sweep_results.json ranks the full sweep |
vocabularies/kvae/ |
vae_sweep/kl_0p001/tokenize_k25/best_codes.npz (K=25, used in the paper) |
VAE checkpoints and K-means tokenizers for the full KL Γ K sweep |
vocabularies/mlb_k9/ |
best_codes.npz |
hand-specified segmenter (see the code repository) |
vocabularies/other/ |
designed, heading-aligned KPMS, round-trip and earlier vocabularies | β |
Code priors
Each folder has params.msgpack, meta.json, its Hydra config and training log.
| Vocabulary | GPT-2 | Mamba |
|---|---|---|
| KPMS K=100 | code_priors/kpms_k100/gpt2/ |
code_priors/kpms_k100/mamba/ |
| KVAE K=25 | code_priors/kvae_k25/gpt2/ |
code_priors/kvae_k25/mamba/ |
| MLB K=9 | code_priors/mlb_k9/gpt2/ |
code_priors/mlb_k9/mamba/ |
code_priors/other/<architecture>/<run>/ holds the remaining runs (other
vocabularies, S5 and HMM priors); meta.json in each records its code_source
and num_codes.
Loading
from huggingface_hub import snapshot_download
root = snapshot_download("Kaiwen107/Code2Act")
from c2a.experiments.shared.checkpoint_utils import load_moseq_checkpoint
cfg, normalizer_state, policy_params, ppo_networks = load_moseq_checkpoint(
f"{root}/controllers/kpms_k100"
)
Notes:
- Restoring the Orbax checkpoints requires a GPU.
- The code repository's configs refer to checkpoints by training-run path
(
model_checkpoints/<run>,trained_mimic_ckpts/<run>,outputs/tokenizer/...,outputs/ar_codegen/...). Point those keys at the folders above, using the "Training run" columns to match them. - The
config/metadatastored in each checkpoint records absolute paths from the training machine. Override the code path withcheckpoint.codes_path_overridewhen evaluating elsewhere. - Code version:
code2actate985c36,track-mjxbranchkevin/kpms-decoderat4d4331f,vnl-playgroundv0.0.13. - Reference clips and train/test splits are not part of this repository.