add README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- robotics
|
| 5 |
+
tags:
|
| 6 |
+
- robotics
|
| 7 |
+
- text-embeddings
|
| 8 |
+
- t5
|
| 9 |
+
- wan2.2
|
| 10 |
+
size_categories:
|
| 11 |
+
- 1M<n<10M
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# RoboTwin 2.0 3D — T5 Text Embedding Cache
|
| 15 |
+
|
| 16 |
+
Precomputed [UMT5-XXL](https://huggingface.co/google/umt5-xxl) text embeddings for the
|
| 17 |
+
**1,039,891 unique task prompts** of the RoboTwin 2.0 3D dataset
|
| 18 |
+
([`flex-pi/robotwin_3d`](https://huggingface.co/datasets/flex-pi/robotwin_3d)), as consumed by
|
| 19 |
+
Wan2.2-TI2V-5B / FastWAM.
|
| 20 |
+
|
| 21 |
+
Precomputing these takes substantial GPU time; this cache lets you skip it.
|
| 22 |
+
|
| 23 |
+
## Contents
|
| 24 |
+
|
| 25 |
+
| Path | Description |
|
| 26 |
+
|---|---|
|
| 27 |
+
| `shards/shard_NNNNN.safetensors` | 520 shards, 2,000 prompts each (last one 1,891), ~2.10 GB per shard |
|
| 28 |
+
| `manifest.txt` | The 1,039,891 prompt hashes, **sorted**, one per line — line `i` is row `i % 2000` of shard `i // 2000` |
|
| 29 |
+
|
| 30 |
+
Each shard holds two tensors, row-aligned:
|
| 31 |
+
|
| 32 |
+
| Tensor | Shape | Dtype |
|
| 33 |
+
|---|---|---|
|
| 34 |
+
| `contexts` | `[N, 128, 4096]` | `bfloat16` |
|
| 35 |
+
| `masks` | `[N, 128]` | `bool` |
|
| 36 |
+
|
| 37 |
+
The shard's `__metadata__["keys"]` is a JSON list of that shard's N hashes, in row order.
|
| 38 |
+
|
| 39 |
+
The key for a prompt is `sha256(prompt.encode("utf-8")).hexdigest()`. Prompts themselves live in
|
| 40 |
+
`meta/tasks.jsonl` of the main dataset.
|
| 41 |
+
|
| 42 |
+
`masks` marks the valid tokens (mean 40.9 of 128). Values beyond the mask are **not** zero — they are
|
| 43 |
+
the raw T5 outputs. Zero them yourself if your model does not apply the mask.
|
| 44 |
+
|
| 45 |
+
## Usage
|
| 46 |
+
|
| 47 |
+
Random access without downloading everything — resolve one prompt to its shard, fetch only that shard:
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
import bisect, hashlib, json
|
| 51 |
+
from huggingface_hub import hf_hub_download
|
| 52 |
+
from safetensors import safe_open
|
| 53 |
+
|
| 54 |
+
REPO = "flex-pi/robotwin_3d_text_embeds_cache"
|
| 55 |
+
SHARD = 2000
|
| 56 |
+
|
| 57 |
+
manifest = hf_hub_download(REPO, "manifest.txt", repo_type="dataset")
|
| 58 |
+
keys = open(manifest).read().split() # sorted
|
| 59 |
+
|
| 60 |
+
def get(prompt):
|
| 61 |
+
h = hashlib.sha256(prompt.encode("utf-8")).hexdigest()
|
| 62 |
+
i = bisect.bisect_left(keys, h)
|
| 63 |
+
if i == len(keys) or keys[i] != h:
|
| 64 |
+
raise KeyError(prompt)
|
| 65 |
+
path = hf_hub_download(REPO, f"shards/shard_{i // SHARD:05d}.safetensors", repo_type="dataset")
|
| 66 |
+
with safe_open(path, framework="pt") as f:
|
| 67 |
+
row = i % SHARD
|
| 68 |
+
return f.get_slice("contexts")[row], f.get_slice("masks")[row]
|
| 69 |
+
|
| 70 |
+
context, mask = get("Lift the medium-sized green bottle ensuring it remains upright.")
|
| 71 |
+
print(context.shape, context.dtype, int(mask.sum())) # (128, 4096) torch.bfloat16 49
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
`safe_open` + `get_slice` reads only the requested row, so this does not load the whole 2 GB shard
|
| 75 |
+
into memory.
|
| 76 |
+
|
| 77 |
+
### Rebuilding the original per-prompt `.pt` layout
|
| 78 |
+
|
| 79 |
+
Some code expects `{cache_dir}/{sha256}.t5_len128.wan22ti2v5b.pt` holding `{"context", "mask"}`:
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
import json, os, torch
|
| 83 |
+
from safetensors import safe_open
|
| 84 |
+
|
| 85 |
+
def unpack(shard_path, out_dir):
|
| 86 |
+
os.makedirs(out_dir, exist_ok=True)
|
| 87 |
+
with safe_open(shard_path, framework="pt") as f:
|
| 88 |
+
ks = json.loads(f.metadata()["keys"])
|
| 89 |
+
C, M = f.get_slice("contexts"), f.get_slice("masks")
|
| 90 |
+
for r, k in enumerate(ks):
|
| 91 |
+
torch.save({"context": C[r], "mask": M[r]},
|
| 92 |
+
os.path.join(out_dir, f"{k}.t5_len128.wan22ti2v5b.pt"))
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
Note this expands to ~1 TB across 1,039,891 files.
|
| 96 |
+
|
| 97 |
+
## Provenance
|
| 98 |
+
|
| 99 |
+
Repacked byte-exactly from the original per-prompt `.pt` cache — tensors are bit-identical, verified
|
| 100 |
+
by round-trip comparison against the source files. Encoder: UMT5-XXL, context length 128.
|