Views
No views yet
transformers ecosystem.transformers and supports Flash Attention 2.1import torch
2from transformers import AutoModel, AutoProcessor
3
4# 1. Load model and processor
5model_path = "XiaomiRobotics/Xiaomi-Robotics-0"
6model = AutoModel.from_pretrained(
7 model_path,
8 trust_remote_code=True,
9 attn_implementation="flash_attention_2",
10 dtype=torch.bfloat16
11).cuda().eval()
12processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True, use_fast=False)
13
14# 2. Construct the prompt with multi-view inputs
15language_instruction = "Pick up the red block."
16instruction = (
17 f"<|im_start|>user
18The following observations are captured from multiple views.
19"
20 f"# Base View
21<|vision_start|><|image_pad|><|vision_end|>
22"
23 f"# Left-Wrist View
24<|vision_start|><|image_pad|><|vision_end|>
25"
26 f"Generate robot actions for the task:
27{language_instruction} /no_cot<|im_end|>
28"
29 f"<|im_start|>assistant
30<cot></cot><|im_end|>
31"
32)
33
34# 3. Prepare inputs
35# Assuming `image_base`, `image_wrist`, and `proprio_state` (numpy array) are already loaded
36inputs = processor(
37 text=[instruction],
38 images=[image_base, image_wrist], # [PIL.Image, PIL.Image]
39 videos=None,
40 padding=True,
41 return_tensors="pt",
42).to(model.device)
43
44# Add proprioceptive state and action mask
45robot_type = "libero" # Select based on your robot/env configuration
46inputs["state"] = torch.from_numpy(proprio_state).to(model.device, model.dtype).view(1, 1, -1)
47inputs["action_mask"] = processor.get_action_mask(robot_type).to(model.device, model.dtype)
48
49# 4. Generate action
50with torch.no_grad():
51 outputs = model(**inputs)
52
53# Decode raw outputs into actionable control commands
54action_chunk = processor.decode_action(outputs.actions, robot_type=robot_type)
55print(f"Generated Action Chunk Shape: {action_chunk.shape}")1@misc{robotics2026xiaomi,
2 title = {Xiaomi-Robotics-0: An Open-Sourced Vision-Language-Action Model with Real-Time Execution},
3 author = {Xiaomi Robotics},
4 howpublished={\url{https://xiaomi-robotics-0.github.io}},
5 year = {2026},
6 note={Project Website}
7}