lastgeyan's picture
add README.md
52eabd7 verified
|
Raw
History Blame
3.42 kB
metadata
license: apache-2.0
task_categories:
  - robotics
tags:
  - robotics
  - text-embeddings
  - t5
  - wan2.2
size_categories:
  - 1M<n<10M

RoboTwin 2.0 3D — T5 Text Embedding Cache

Precomputed UMT5-XXL text embeddings for the 1,039,891 unique task prompts of the RoboTwin 2.0 3D dataset (flex-pi/robotwin_3d), as consumed by Wan2.2-TI2V-5B / FastWAM.

Precomputing these takes substantial GPU time; this cache lets you skip it.

Contents

Path Description
shards/shard_NNNNN.safetensors 520 shards, 2,000 prompts each (last one 1,891), ~2.10 GB per shard
manifest.txt The 1,039,891 prompt hashes, sorted, one per line — line i is row i % 2000 of shard i // 2000

Each shard holds two tensors, row-aligned:

Tensor Shape Dtype
contexts [N, 128, 4096] bfloat16
masks [N, 128] bool

The shard's __metadata__["keys"] is a JSON list of that shard's N hashes, in row order.

The key for a prompt is sha256(prompt.encode("utf-8")).hexdigest(). Prompts themselves live in meta/tasks.jsonl of the main dataset.

masks marks the valid tokens (mean 40.9 of 128). Values beyond the mask are not zero — they are the raw T5 outputs. Zero them yourself if your model does not apply the mask.

Usage

Random access without downloading everything — resolve one prompt to its shard, fetch only that shard:

import bisect, hashlib, json
from huggingface_hub import hf_hub_download
from safetensors import safe_open

REPO = "flex-pi/robotwin_3d_text_embeds_cache"
SHARD = 2000

manifest = hf_hub_download(REPO, "manifest.txt", repo_type="dataset")
keys = open(manifest).read().split()          # sorted

def get(prompt):
    h = hashlib.sha256(prompt.encode("utf-8")).hexdigest()
    i = bisect.bisect_left(keys, h)
    if i == len(keys) or keys[i] != h:
        raise KeyError(prompt)
    path = hf_hub_download(REPO, f"shards/shard_{i // SHARD:05d}.safetensors", repo_type="dataset")
    with safe_open(path, framework="pt") as f:
        row = i % SHARD
        return f.get_slice("contexts")[row], f.get_slice("masks")[row]

context, mask = get("Lift the medium-sized green bottle ensuring it remains upright.")
print(context.shape, context.dtype, int(mask.sum()))   # (128, 4096) torch.bfloat16 49

safe_open + get_slice reads only the requested row, so this does not load the whole 2 GB shard into memory.

Rebuilding the original per-prompt .pt layout

Some code expects {cache_dir}/{sha256}.t5_len128.wan22ti2v5b.pt holding {"context", "mask"}:

import json, os, torch
from safetensors import safe_open

def unpack(shard_path, out_dir):
    os.makedirs(out_dir, exist_ok=True)
    with safe_open(shard_path, framework="pt") as f:
        ks = json.loads(f.metadata()["keys"])
        C, M = f.get_slice("contexts"), f.get_slice("masks")
        for r, k in enumerate(ks):
            torch.save({"context": C[r], "mask": M[r]},
                       os.path.join(out_dir, f"{k}.t5_len128.wan22ti2v5b.pt"))

Note this expands to ~1 TB across 1,039,891 files.

Provenance

Repacked byte-exactly from the original per-prompt .pt cache — tensors are bit-identical, verified by round-trip comparison against the source files. Encoder: UMT5-XXL, context length 128.