piper_picking_tests / helper_scripts /lerobotv3_format_explanation.md
charithmunasinghe's picture
clean up raw dataset
8221873

LeRobot v3.0 Format Complete Knowledge Base

Table of Contents

  1. Overview
  2. Critical Requirements
  3. Dataset Structure
  4. Two Valid Task Approaches
  5. Chunking Strategy
  6. Episode-to-File Mapping
  7. Configuration Parameters
  8. Best Practices
  9. v2.1 vs v3.0 Changes
  10. Our Dataset Strategy

Overview

LeRobot v3.0 introduces a consolidated file format for improved scalability, efficiency, and standardization. Instead of one file per episode (v2.1), v3.0 groups multiple episodes into larger Parquet data files and MP4 video files.

Key Benefits:

  • Scalability: Handle massive datasets (1M+ episodes)
  • Efficiency: Fewer, larger files = faster I/O
  • Standardization: Parquet for all metadata
  • Flexibility: Configurable chunking strategies

Source: Verified against Phospho.ai documentation and real datasets (SVLA, LIBERO)


Critical Requirements

1. Language Instructions are MANDATORY for VLA

All Vision-Language-Action (VLA) models require natural language task descriptions:

  • SmolVLA: Processes language through tokenizer, conditions actions on language embeddings
  • Pi0/Pi0.5: Uses Paligemma (vision-language model), requires task descriptions
  • XVLA: Uses Florence-2 backbone with language tokenizer

Quality Requirements:

  • Full sentences: "Pick up the red cube from the left side"
  • Not labels: "red_cube" or "pickup"
  • Specific & descriptive: Include object details, spatial context
  • Natural language: How a human would describe the task
  • Goal-oriented: Describe what to achieve, not just object names

Example (from LIBERO dataset):

"put the white mug on the left plate and put the yellow and white mug on the right plate"
"put the yellow and white mug in the microwave and close it"
"turn on the stove and put the moka pot on it"

2. Proper HDF5 Paths (if converting from HDF5)

Correct structure:

  • observation/state (singular, not observations/state)
  • action (singular, not actions)
  • timestamp (singular, not timestamps)

Dataset Structure

Complete v3.0 Directory Layout

dataset_name/
├── meta/
│   ├── info.json                        # Dataset configuration
│   ├── stats.json                       # Aggregated statistics
│   ├── tasks.parquet                    # Task definitions (optional, see approaches below)
│   └── episodes/
│       ├── chunk-000/
│       │   ├── file-000.parquet         # Episodes 0-999 metadata
│       │   └── file-001.parquet         # Episodes 1000-1999 metadata (if >1000 episodes)
│       └── chunk-001/                   # If >1000 episode metadata files
│           └── file-000.parquet
├── data/
│   ├── chunk-000/
│   │   ├── file-000.parquet             # Frame data for episodes 0-14
│   │   ├── file-001.parquet             # Frame data for episodes 15-29
│   │   └── ...                          # More files based on data_files_size_in_mb
│   └── chunk-001/                       # If >1000 data files
│       └── file-000.parquet
└── videos/
    ├── observation.images.camera1/
    │   ├── chunk-000/
    │   │   ├── file-000.mp4             # Video(s) for episodes 0-N
    │   │   ├── file-001.mp4
    │   │   └── ...                      # Number depends on strategy
    │   └── chunk-001/                   # If >1000 video files
    │       └── file-000.mp4
    └── observation.images.camera2/
        └── chunk-000/
            └── ...

File Schemas

meta/info.json

{
    "codebase_version": "v3.0",
    "robot_type": "piper",
    "total_episodes": 13,
    "total_frames": 5016,
    "total_tasks": 12,
    "total_videos": 26,
    "total_chunks": 1,
    "chunks_size": 1000,
    "data_files_size_in_mb": 50,
    "video_files_size_in_mb": 200,
    "fps": 30,
    "features": {
        "observation.state": {
            "dtype": "float32",
            "shape": [7],
            "names": {"motors": ["joint_1", ..., "joint_7"]},
            "fps": 30.0
        },
        "action": {
            "dtype": "float32",
            "shape": [7],
            "names": {"motors": ["joint_1", ..., "joint_7"]},
            "fps": 30.0
        },
        "observation.images.table_cam": {
            "dtype": "video",
            "shape": [720, 800, 3],
            "video_info": {
                "video.fps": 30.0,
                "video.codec": "av1",
                "video.pix_fmt": "yuv420p"
            }
        }
        // ... other features
    }
}

data/chunk-000/file-000.parquet

Frame-level data:

{
    'observation.state': [7],          # Robot state
    'action': [7],                     # Robot action
    'timestamp': float,                # Frame timestamp
    'frame_index': int,                # Frame within episode
    'episode_index': int,              # Which episode
    'index': int,                      # Global frame index
    'task_index': int,                 # Maps to tasks.parquet (LIBERO approach)
    'next.done': bool                  # True on last frame of episode
}

meta/episodes/chunk-000/file-000.parquet

Episode-level metadata:

{
    'episode_index': 0,
    'length': 324,                                    # Number of frames
    
    # Data file location
    'data/chunk_index': 0,                            # Which data chunk
    'data/file_index': 0,                             # Which file in that chunk
    'dataset_from_index': 0,                          # Start frame in that file
    'dataset_to_index': 324,                          # End frame in that file
    
    # Video file locations (per camera)
    'videos/observation.images.table_cam/chunk_index': 0,
    'videos/observation.images.table_cam/file_index': 0,
    'videos/observation.images.table_cam/from_timestamp': 0.0,
    'videos/observation.images.table_cam/to_timestamp': 10.8,
    
    'videos/observation.images.wrist_cam/chunk_index': 0,
    'videos/observation.images.wrist_cam/file_index': 0,
    'videos/observation.images.wrist_cam/from_timestamp': 0.0,
    'videos/observation.images.wrist_cam/to_timestamp': 10.8,
    
    # Per-episode statistics
    'stats/action/min': [7],
    'stats/action/max': [7],
    'stats/action/mean': [7],
    'stats/action/std': [7],
    'stats/observation.state/min': [7],
    'stats/observation.state/max': [7],
    // ... other stats
    
    # Task information (optional, depends on approach)
    'tasks': ["Pick up the screwdriver from the table."],  # SVLA approach
    'task_index': 7                                         # LIBERO approach
}

meta/tasks.parquet (LIBERO approach)

# Task descriptions are the INDEX of the DataFrame!
index (task description)                              | task_index
------------------------------------------------------|------------
"put the white mug on the left plate and..."         | 0
"put the white mug on the plate and put..."          | 1
"pick up the screwdriver from the table."            | 7

meta/stats.json

Aggregated statistics for normalization:

{
    "observation.state": {
        "mean": [7 values],
        "std": [7 values],
        "min": [7 values],
        "max": [7 values]
    },
    "action": {
        "mean": [7 values],
        "std": [7 values],
        "min": [7 values],
        "max": [7 values]
    }
}

Two Valid Task Approaches

Approach 1: Tasks in Episode Metadata (SVLA Style)

Use when:

  • Single task repeated across all episodes
  • Per-episode task variations needed
  • Episodes can have multiple task descriptions

Structure:

# meta/episodes/chunk-000/file-000.parquet
{
    'episode_index': 0,
    'tasks': ['Put the red cube on top of the blue cube.'],  # List of strings
    'length': 447,
    // ... other metadata
}

Example Dataset: svla_so100_stacking

  • 56 episodes, 1 task
  • All episodes do same task
  • Task stored in each episode's metadata

Pros:

  • Simple for single-task datasets
  • Allows per-episode task variations
  • Tasks directly in episode metadata

Cons:

  • Redundant for multi-task datasets
  • Harder to manage many distinct tasks

Approach 2: Separate tasks.parquet (LIBERO Style) ✅

Use when:

  • Multiple distinct tasks in dataset
  • Each episode demonstrates one task
  • Want centralized task management

Structure:

# meta/tasks.parquet (task descriptions are INDEX!)
index="Pick up the screwdriver..." | task_index=7

# data/chunk-000/file-000.parquet (each frame)
{
    'observation.state': [...],
    'action': [...],
    'task_index': 7,  # Maps to tasks.parquet!
    'episode_index': 0,
    // ... other frame data
}

# meta/episodes/chunk-000/file-000.parquet
{
    'episode_index': 0,
    'length': 214,
    # NO tasks field!
    // ... video metadata, data indices
}

Example Dataset: LIBERO

  • 1,693 episodes, 40 tasks
  • Each episode has one task type
  • tasks.parquet centralizes task definitions

Pros:

  • ✅ Clean task definition management
  • ✅ Define each task once
  • ✅ Easy to add new tasks
  • ✅ Better for multi-task datasets
  • ✅ Explicit task conditioning via task_index

Cons:

  • Extra file to manage
  • Slightly more complex lookup

Both approaches are valid v3.0 and work with VLA models!


Chunking Strategy

Three Types of Chunking

1. Directory Chunks (chunks_size)

Purpose: Limit number of FILES per directory for filesystem performance

Configuration:

{
    "chunks_size": 1000  // Max 1000 files per chunk-XXX directory
}

When it splits:

  • ✅ More than 1000 files → creates chunk-001, chunk-002, etc.
  • ❌ Fewer than 1000 files → everything stays in chunk-000

Example (LIBERO videos):

1,693 video files (one per episode):
- chunk-000/: file-000.mp4 through file-999.mp4 (1000 files)
- chunk-001/: file-000.mp4 through file-692.mp4 (693 files)

Why: File system performance degrades with 1000+ files in one directory

2. Data File Chunks (data_files_size_in_mb)

Purpose: Target parquet file size for efficient I/O

Configuration:

{
    "data_files_size_in_mb": 100  // Target ~100MB per data parquet file
}

How it works:

  • Multiple episodes consolidated into each parquet file
  • System creates new file when size target reached
  • Episode metadata tracks which file contains each episode

Examples:

  • LIBERO: 273,465 frames → 377 files (~730 frames per file, ~100MB each)
  • SVLA: 22,956 frames → 1 file (~20MB total, under target)
  • PIPER: 5,016 frames → 1 file (~0.4MB total, well under target)

Key Insight: Data files often contain MULTIPLE episodes!

3. Video File Strategy (video_files_size_in_mb)

Purpose: Target video file size for streaming/download

Configuration:

{
    "video_files_size_in_mb": 500  // Target ~500MB per video file
}

Two valid strategies:

Strategy A: One video per episode (LIBERO)

  • Each episode = separate MP4 file
  • Good for: Different episode lengths, multi-task, selective loading
  • Example: LIBERO has 1,693 MP4s per camera (one per episode)

Strategy B: Multiple episodes per video (SVLA)

  • Episodes concatenated into fewer large videos
  • Good for: Uniform episodes, sequential access, single-task
  • Example: SVLA has 1 MP4 per camera (all 56 episodes concatenated)

Both are valid v3.0! Choice depends on dataset characteristics.

Comparison: Data vs Video Chunking

Aspect Data Files Video Files
Consolidation Always multiple episodes per file Depends on strategy
File count Few (377 in LIBERO) Can be many (1,693 in LIBERO) or few (1 in SVLA)
When splits Based on data size Based on strategy choice
Directory chunks Rare (377 < 1000) Common if one-per-episode (1693 > 1000)
Episode mapping Via from/to indices Via timestamps or per-file

When to Split into Chunks?

Scenario Data Chunks Video Chunks Directory Chunks
Small dataset (<100 episodes) 1 file in chunk-000 1 file or 1-per-episode in chunk-000 All in chunk-000
Medium dataset (100-1000 episodes) Multiple files in chunk-000 Multiple files in chunk-000 All in chunk-000
Large dataset (1000-10000 episodes) Many files, maybe 2 chunks Many files, likely 2-10 chunks Multiple chunk-XXX dirs
Massive dataset (>10000 episodes) Many files, many chunks Many files, many chunks Many chunk-XXX dirs

Episode-to-File Mapping

How the System Tracks Episodes

Episode metadata includes ALL location information:

{
    'episode_index': 1234,
    
    # Where is the data?
    'data/chunk_index': 0,           # data/chunk-000/
    'data/file_index': 82,            # file-082.parquet
    'dataset_from_index': 123450,     # Starts at global frame 123450
    'dataset_to_index': 123774,       # Ends at global frame 123774 (324 frames)
    
    # Where are the videos?
    'videos/observation.images.camera1/chunk_index': 1,     # videos/.../chunk-001/
    'videos/observation.images.camera1/file_index': 234,    # file-234.mp4
    'videos/observation.images.camera1/from_timestamp': 0.0,
    'videos/observation.images.camera1/to_timestamp': 10.8, # 324 frames @ 30fps
}

Lookup Process

To load episode 1234:

  1. Read meta/episodes/chunk-000/file-XXX.parquet
  2. Find row where episode_index == 1234
  3. For data: Go to data/chunk-000/file-082.parquet, read rows 123450-123774
  4. For video: Go to videos/.../chunk-001/file-234.mp4, decode timestamps 0.0-10.8

Patterns

LIBERO (one video per episode):

video_file_index == episode_index  # Direct mapping!
from_timestamp == 0.0              # Each video starts at 0

SVLA (all episodes in one video):

video_file_index == 0              # All episodes in file-000.mp4
from_timestamp varies              # Use timestamps to locate episode

Configuration Parameters

Complete info.json Configuration

{
    "codebase_version": "v3.0",
    "robot_type": "your_robot",
    "total_episodes": 13,
    "total_frames": 5016,
    "total_tasks": 12,
    "total_videos": 26,
    "total_chunks": 1,
    
    "chunks_size": 1000,                  // Max FILES per directory chunk
    "data_files_size_in_mb": 100,         // Target size for EACH data parquet
    "video_files_size_in_mb": 500,        // Target size for EACH video MP4
    
    "fps": 30,
    "features": { /* ... */ }
}

What Each Parameter Controls

Parameter Controls Example Impact
chunks_size Max files per chunk-XXX dir 1000 1693 files → 2 chunks
data_files_size_in_mb Target data file size 100 Creates new file when reached
video_files_size_in_mb Target video file size 500 Strategy-dependent
fps Frame rate 30 Affects timestamp calculations

Common mistake: Thinking chunks_size controls episodes per chunk Reality: It controls FILES per directory (for filesystem performance)


Best Practices

Language Instructions

  1. Be specific: "Pick up the red cube from the left side" > "pick cube"
  2. Include spatial context: "Put the mug on the left plate"
  3. Describe the goal: Not just object names
  4. Use natural language: How a human would explain it
  5. Consistency: Similar phrasing for similar tasks
  6. Variation: Multiple phrasings help generalization

Dataset Quality for VLA Fine-Tuning

From SmolVLA/Pi0 documentation:

  1. 50+ episodes recommended for good performance
  2. Language diversity: Vary descriptions, include context
  3. Visual variations: Multiple object positions, angles
  4. Multiple camera views: Helps spatial understanding
  5. Consistent frame rate: 30 FPS standard
  6. Quality over quantity: Good demos > many poor demos

Chunking Recommendations

Small datasets (<100 episodes):

{
    "chunks_size": 1000,
    "data_files_size_in_mb": 50,
    "video_files_size_in_mb": 200
}
  • Use LIBERO approach (one video per episode)
  • All in chunk-000
  • 1 data file sufficient

Medium datasets (100-1000 episodes):

{
    "chunks_size": 1000,
    "data_files_size_in_mb": 100,
    "video_files_size_in_mb": 500
}
  • Use LIBERO approach if multi-task
  • May need multiple data files
  • All in chunk-000

Large datasets (>1000 episodes):

{
    "chunks_size": 1000,
    "data_files_size_in_mb": 100,
    "video_files_size_in_mb": 500
}
  • Will need multiple chunks
  • Many data files
  • Consider SVLA consolidation if single-task

v2.1 vs v3.0 Changes

File Organization

v2.1:

dataset/
├── episode_000000.parquet
├── episode_000001.parquet
├── video_000000.mp4
├── video_000001.mp4
└── ...
  • One file per episode
  • Can have 1000s of files
  • Scattered structure

v3.0:

dataset/
├── data/chunk-000/file-000.parquet       # Many episodes
├── videos/.../chunk-000/file-000.mp4     # One or many episodes
└── meta/episodes/chunk-000/file-000.parquet
  • Consolidated files
  • Organized chunks
  • Metadata-driven access

Metadata Format

v2.1:

  • tasks.jsonl (JSON Lines)
  • episodes_stats.jsonl
  • JSON-based metadata

v3.0:

  • tasks.parquet (Parquet)
  • meta/episodes/chunk-000/*.parquet
  • Parquet-based metadata

Benefits: Columnar storage, compression, schema evolution

Scalability

v2.1:

  • Works well for <1000 episodes
  • File system struggles with large datasets
  • Slow directory listing

v3.0:

  • Handles millions of episodes
  • Efficient chunk-based organization
  • Fast I/O with larger files

Migration

Automatic conversion available:

python scripts/convert_dataset_v2_to_v3.py

Or create v3.0 directly using LeRobotDataset.create()


Our Dataset Strategy

piper_picking_tests Characteristics

Total Episodes: 13
Total Frames: 5,016
Total Tasks: 12 (one duplicate: scissors/scissors_hidden)
Cameras: 2 (table_cam 800×720, wrist_cam 640×480)
FPS: 30
Robot: 7-DOF arm
State: 7D joint angles
Action: 7D commands

Recommended Structure: LIBERO Multi-Task Style

Why LIBERO approach?

  • ✅ Multi-task dataset (12 distinct tasks)
  • ✅ Each episode = one task type
  • ✅ Easier task management
  • ✅ Better for VLA training
  • ✅ Explicit task conditioning

File Structure:

piper_picking_tests_v3/
├── meta/
│   ├── info.json
│   ├── stats.json
│   ├── tasks.parquet                    # 12 tasks, descriptions as index
│   └── episodes/
│       └── chunk-000/
│           └── file-000.parquet         # 13 episodes (NO tasks field)
├── data/
│   └── chunk-000/
│       └── file-000.parquet             # All 5,016 frames (WITH task_index)
└── videos/
    ├── observation.images.table_cam/
    │   └── chunk-000/
    │       ├── file-000.mp4             # Episode 0 (cleaningcloth)
    │       ├── file-001.mp4             # Episode 1 (fillamentroll)
    │       └── ...                      # 13 files total
    └── observation.images.wrist_cam/
        └── chunk-000/
            └── ...                      # 13 files total

Configuration

{
    "codebase_version": "v3.0",
    "robot_type": "piper",
    "total_episodes": 13,
    "total_frames": 5016,
    "total_tasks": 12,
    "chunks_size": 1000,
    "data_files_size_in_mb": 50,
    "video_files_size_in_mb": 200,
    "fps": 30
}

Task Language Mapping

TASK_LANGUAGE_MAP = {
    0: "Pick up the cleaning cloth from the table.",
    1: "Grasp and pick up the filament roll.",
    2: "Pick up the game controller from the table.",
    3: "Pick up the hex wrench tool.",
    4: "Grasp and pick up the pencil.",
    5: "Pick up the scissors from the table.",
    6: "Find and pick up the scissors that are partially hidden.",
    7: "Pick up the screwdriver from the table.",
    8: "Grasp and pick up the small key.",
    9: "Pick up the small piece of paper.",
    10: "Pick up the small wooden stick.",
    11: "Pick up the thin metal disk.",
}

Expected Sizes

  • Data parquet: ~0.4 MB (5,016 frames × 80 bytes/frame)
  • Videos: ~8 MB per episode per camera (compressed av1)
    • 13 episodes × 2 cameras × 8 MB = ~208 MB total
  • Metadata: <1 MB
  • Total: ~210 MB (vs 6.2 GB current PNG format)

Why This Strategy?

  1. Multi-task structure matches dataset nature
  2. One video per episode enables flexible loading
  3. LIBERO approach provides clean task management
  4. task_index in frames ensures proper VLA conditioning
  5. Single chunk sufficient for 13 episodes
  6. Scalable if we add more episodes later

Verification Checklist

Format Compliance

  • data/ directory with parquet files
  • videos/ directories with MP4 files (av1 codec)
  • meta/info.json with v3.0 schema
  • meta/episodes/ with parquet metadata
  • meta/tasks.parquet (if LIBERO approach)
  • meta/stats.json with aggregated statistics

Data Integrity

  • All episodes present (13)
  • All frames present (5,016)
  • All tasks defined (12)
  • task_index in data frames (LIBERO approach)
  • Episode metadata includes file mappings
  • Videos playable and correct length

VLA Compatibility

  • Language instructions are natural, descriptive
  • task_index maps correctly to language descriptions
  • Can load with LeRobotDataset.load()
  • Test with SmolVLA/Pi0 data loading
  • Language conditioning works in VLA models

Statistics

  • Per-episode stats in episode metadata
  • Aggregated stats in meta/stats.json
  • Reasonable value ranges
  • Mean/std suitable for normalization

References

Document Version: 1.0 (December 2025) Verified Against: LeRobot v3.0, Phospho.ai docs, SVLA, LIBERO datasets