Open main menu

Humanoid Robots Wiki β

Changes

Created page with "= Robotic Control via Embodied Chain-of-Thought Reasoning = The codebase is built on top of OpenVLA. We refer to it for the detailed documentation of the code and dependencie..."
= Robotic Control via Embodied Chain-of-Thought Reasoning =

The codebase is built on top of OpenVLA. We refer to it for the detailed documentation of the code and dependencies.

== Quickstart ==
We provide a Colab notebook containing code for loading up our ECoT policy and using it to generate reasoning and actions in response to an observation. Loading the model for inference is easy:
<code>
from transformers import AutoModelForVision2Seq, AutoProcessor

device = "cuda"
path_to_hf = "Embodied-CoT/ecot-openvla-7b-bridge"
processor = AutoProcessor.from_pretrained(path_to_hf, trust_remote_code=True)
vla = AutoModelForVision2Seq.from_pretrained(path_to_hf, torch_dtype=torch.bfloat16).to(device)

observation = &lt;ROBOT IMAGE OBSERVATION HERE&gt;
instruction = &lt;YOUR INSTRUCTION HERE&gt;
prompt = "A chat between a curious user and an artificial intelligence assistant. " + \
"The assistant gives helpful, detailed, and polite answers to the user's questions. " + \
f"USER: What action should the robot take to {instruction.lower()}? ASSISTANT: TASK:"

inputs = processor(prompt, image).to(device, dtype=torch.bfloat16)
action, generated_ids = vla.predict_action(**inputs, unnorm_key="bridge_orig", max_new_tokens=1024)
generated_text = processor.batch_decode(generated_ids)[0]
</code>
The standard model in torch.bfloat16 requires 16 GB of GPU memory, but using bitsandbytes and 4-bit quantization lowers memory usage to around 5 GB. See the Colab for more details.

== Training and Evaluation ==
To train the models from scratch, use the following command:
<code>
torchrun --standalone --nnodes 1 --nproc-per-node 8 vla-scripts/train.py \
--vla.type "prism-dinosiglip-224px+mx-bridge" \
--data_root_dir &lt;path to training data root&gt; \
--run_root_dir &lt;path to checkpoint saving directory&gt; \
--wandb_project &lt;wandb project name&gt; \
--wandb_entity &lt;wandb user name&gt;
</code>
To evaluate the model on the WidowX robot:
<code>
python3 experiments/bridge/eval_model_in_bridge_env.py
--model.type prism-dinosiglip-224px+7b
--pretrained_checkpoint &lt;path to checkpoint&gt;
--host_ip &lt;robot interface IP&gt;
--port &lt;robot interface port&gt;
</code>

== Pretrained models ==
We release two ECoT models trained as part of our work, and the dataset of reasonings, available on our HuggingFace page:
* '''ecot-openvla-7b-bridge''': The main model that we used for most of our experiments. It was trained on the Bridge dataset annotated with the reasoning for 80k steps.
* '''ecot-openvla-7b-oxe''': A policy that was initially trained on the Open-X-Embodiment dataset actions, fine-tuned on the mixture of OXE action-only data and our reasonings for Bridge for another 20k steps.
* '''embodied_features_bridge''': A dataset of the embodied features and reasonings collected for Bridge demonstrations.

=== Explicit Notes on Model Licensing & Commercial Use ===
While all code in this repository is released under an MIT License, our pretrained models may inherit restrictions from the underlying base models we use. Specifically, both the above models are derived from Llama-2, and as such are subject to the Llama Community License.

== Installation ==
See the original OpenVLA repository for detailed installation instructions.

== Repository Structure ==
High-level overview of repository/project file-tree:
* '''prismatic''': Package source; provides core utilities for model loading, training, data preprocessing, etc.
* '''experiments''': Code for evaluating the policies on a WidowX robot.
* '''vla-scripts/''': Core scripts for training, fine-tuning, and deploying VLAs.
* '''LICENSE''': All code is made available under the MIT License; happy hacking!
* '''Makefile''': Top-level Makefile (by default, supports linting - checking & auto-fix); extend as needed.
* '''pyproject.toml''': Full project configuration details (including dependencies), as well as tool configurations.
* '''README.md''': You are here!

== Citation ==
If you find our code or models useful in your work, please cite our paper:
<code>
@article{Zawalski24-ecot,
title={Robotic Control via Embodied Chain-of-Thought Reasoning},
author={Michał Zawalski and William Chen and Karl Pertsch and Oier Mees and Chelsea Finn and Sergey Levine},
journal={arXiv preprint arXiv:2407.08693},
year={2024}
}
</code>