外观
教程huggingface.co6 天前
LeRobot:微调 SmolVLA 到自己的机器人与任务
> 本文依据以下官方文档整理:huggingface.co/docs/lerobot/smolvla。命令与版本以文档当前版本为准。
前置条件
- 已安装 LeRobot
- 已安装 SmolVLA dependencies
- 拥有自己的 LeRobot dataset,并且 dataset available on the Hub
- 推荐记录 ~50 episodes of your task as a starting point
- 训练 20k steps 约需单张 A100 GPU 上 ~4 hrs
- 评估时建议 logged in to the HuggingFace Hub
1. 安装 SmolVLA 依赖
SmolVLA 是 Hugging Face 的 lightweight foundation model for robotics,面向 LeRobot datasets 做 fine-tuning。先确保 LeRobot 已安装,然后在环境中安装 SmolVLA dependencies:
bash
pip install -e ".[smolvla]"2. 准备自己的任务数据集
SmolVLA is a base model,因此要在自己的数据上微调,才能在你的 setup 中获得 optimal performance。官方建议从记录 ~50 episodes 开始,并确保每个 variation 都有足够 demonstrations,例如 cube pick-place task 中 table 上不同 cube position。
3. 按 variation 组织并上传数据
官方参考数据集是 SVLA SO100 PickPlace:50 episodes 覆盖 5 distinct cube positions,每个 position 采集 10 episodes of pick-and-place interactions。文档明确提到类似的 25 episodes dataset 不够,导致 bad performance;数据可用到 Hub 后即可微调。
4. 启动 SmolVLA 微调训练
使用 smolvla_base,也就是 pretrained 450M model,并通过 --dataset.repo_id 传入你的数据集。训练 20k steps 在单张 A100 GPU 上大约 ~4 hrs,steps 需要根据 performance 和 use-case 调整。
bash
cd lerobot && lerobot-train \
--policy.path=lerobot/smolvla_base \
--dataset.repo_id=${HF_USER}/mydataset \
--batch_size=64 \
--steps=20000 \
--output_dir=outputs/train/my_smolvla \
--job_name=my_smolvla_training \
--policy.device=cuda \
--wandb.enable=true5. 查看微调参数并调整 batch size
Fine-tuning is an art。官方建议可以从较小 batch size 开始,如果 GPU allows it,就 incrementally 增大,只要 loading times remain short。要查看完整 finetuning options,运行:
bash
lerobot-train --help6. 在机器人上运行推理评估
和 recording an episode 类似,评估时建议 logged in to the HuggingFace Hub。登录后,按你的 port、robot id、cameras、task 和 fine-tuned model 更新参数,在 setup 中运行 inference:
bash
lerobot-rollout \
--strategy.type=base \
--robot.type=so101_follower \
--robot.port=/dev/ttyACM0 \ # <- Use your port
--robot.id=my_blue_follower_arm \ # <- Use your robot id
--robot.cameras="{ front: {type: opencv, index_or_path: 8, width: 640, height: 480, fps: 30}}" \ # <- Use your cameras
--task="Grasp a lego block and put it in the bin." \ # <- Use the same task description you used in your dataset recording
# <- RTC optional, use when running on low power hardware \
# --inference.type=rtc \
# --inference.rtc.execution_horizon=10 \
# --inference.rtc.max_guidance_weight=10.0 \
# <- Teleop optional if you want to teleoperate in between episodes \
# --teleop.type=so100_leader \
# --teleop.port=/dev/ttyACM0 \
# --teleop.id=my_red_leader_arm \
# --display_data=true #optional use if you want to see the camera stream \
--policy.path=HF_USER/FINETUNE_MODEL_NAME # <- Use your fine-tuned model验证是否跑通
确认训练命令使用你的 --dataset.repo_id 后完成,并产出到 outputs/train/my_smolvla。随后用 lerobot-rollout 指向 --policy.path=HF_USER/FINETUNE_MODEL_NAME,在你的 setup 中运行 inference;根据 evaluation setup,可配置 duration 和 number of episodes 来记录 evaluation suite。
文档里点名的注意事项
- SmolVLA is a base model,fine-tuning on your own data is required for optimal performance in your setup.
- 推荐记录 ~50 episodes of your task as a starting point,并且每个 variation 要有足够 demonstrations.
- 文档中的参考结构是 50 episodes across 5 distinct cube positions;类似的 25 episodes dataset was not enough,导致 bad performance.
- batch size 可以从小开始增大,但前提是 GPU allows it,且 loading times remain short.
- 训练 steps 需要 based on performance and your use-case 调整.
- 评估命令中的 --task 应使用和 dataset recording 相同的 task description.
- RTC optional, use when running on low power hardware;Teleop optional if you want to teleoperate in between episodes.
相关 SDK 条目
来源
本页事实对应的公开页面,以原文为准。
- huggingface.co/docs/lerobot/smolvla访问 2026-10-22