从零实现 Mini-VLA,深入理解 RT-2/OpenVLA/Octo 架构,掌握 Action Tokenization 与多模态输入编码。
VLA (Vision-Language-Action) 是机器人学习和自动驾驶的前沿方向。它将视觉感知、语言理解和行为决策统一到一个模型中。本章从零实现 VLA 的核心组件。
学完本章你将获得:
- VLA 三阶段架构的完整理解
- Action Tokenization 的实践能力
- RT-2 / OpenVLA 设计的工程直觉
VLA 模型将机器人/自动驾驶任务建模为序列预测问题:
输入: 图像序列 + 语言指令
输出: 动作序列
这与 LLM 的 "文本输入 → 文本输出" 完全同构,只是输出变成了动作 token。
传统方法的问题:
1. 感知-规划-控制 三阶段分离,误差累积
2. 规则系统无法处理复杂长尾场景
3. 不同模块独立优化,缺乏全局一致性
VLA 的优势:
1. 端到端学习,直接优化最终驾驶质量
2. 利用 LLM 的常识推理能力
3. 语言条件化,支持自然语言指令
LLM 天然处理离散 token。要将连续动作送入 LLM,需要离散化:
action_continuous ∈ [-1, 1]
→ B bins → action_discrete ∈ {0, 1, ..., B-1}
bin_width = (max - min) / num_bins
discrete = round((continuous - min) / bin_width)
continuous_recovered = (discrete + 0.5) * bin_width + min
量化误差 = bin_width / 2。256 bins 提供约 0.4% 的精度,对大多数机器人任务足够。
RT-2 (Robotics Transformer 2) 的核心洞察:
- 预训练的 VLM 已经具备世界知识和推理能力
- 将动作表示为文本 token,可以直接复用 VLM
- Co-finetuning 让 VLM 学会输出动作 token
RT-2 将机器人动作编码为文本:
"x=128 y=64 z=32 r=90 p=0 y=45 gripper=1"
每个数字被分解为 1-3 位数的 token(如 "128" → "1", "2", "8")。
OpenVLA 对 RT-2 的改进:
1. 专用 Action Tokenizer(不混入文本 token)
2. Action Detokenizer(小型 Transformer decoder)
3. LoRA 微调 LLM(高效适应新任务)
LLM Hidden States → Memory Projection → Decoder Memory
↓
Action Queries → [Transformer Decoder] → Action Tokens
action_dim = 4:
- steering (方向盘角度, [-1, 1])
- throttle (油门, [0, 1])
- brake (刹车, [0, 1])
- target_speed (目标速度, [0, 30] m/s)
- "Turn left at the next intersection"
- "Change to the right lane"
- "Follow the white car ahead"
- "Stop at the red light"
1. 安全关键: 需要极低延迟和高确定性
2. 长尾场景: 少见情况需要 LLM 常识推理
3. 实时性: 完整 VLA 推理 < 100ms
4. 闭环稳定: 预测误差不能随时间长距离累积
本章项目地址: vla_learn/chapter14_vla_architecture/
预计学习时间: 1-2 天