File size: 3,417 Bytes
52eabd7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ---
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](https://huggingface.co/google/umt5-xxl) text embeddings for the
**1,039,891 unique task prompts** of the RoboTwin 2.0 3D dataset
([`flex-pi/robotwin_3d`](https://huggingface.co/datasets/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:
```python
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"}`:
```python
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.
|