ayushexel commited on
Commit
387397e
·
verified ·
1 Parent(s): 41ffc8d

Add files using upload-large-folder tool

Browse files
Files changed (23) hide show
  1. .gitattributes +7 -0
  2. README.md +148 -0
  3. data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/metadata.lance +0 -0
  4. data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/part_0_docs.lance +0 -0
  5. data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/part_0_invert.lance +3 -0
  6. data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/part_0_tokens.lance +0 -0
  7. data/train.lance/_indices/a1cb5252-7e54-4e30-9c4c-4c69cd053480/auxiliary.idx +3 -0
  8. data/train.lance/_indices/a1cb5252-7e54-4e30-9c4c-4c69cd053480/index.idx +3 -0
  9. data/train.lance/_indices/fb6b87a4-768b-4da7-aa6b-735d9637c186/auxiliary.idx +3 -0
  10. data/train.lance/_indices/fb6b87a4-768b-4da7-aa6b-735d9637c186/index.idx +3 -0
  11. data/train.lance/_indices/fe5a3535-6ea7-47f2-a4ad-c00f4c4c69b7/page_data.lance +3 -0
  12. data/train.lance/_indices/fe5a3535-6ea7-47f2-a4ad-c00f4c4c69b7/page_lookup.lance +0 -0
  13. data/train.lance/_transactions/0-847b0efd-6b40-4c46-9c85-765cf941ce85.txn +0 -0
  14. data/train.lance/_transactions/1-805ba875-2962-4001-89a3-723d27e57965.txn +0 -0
  15. data/train.lance/_transactions/2-33597c13-df53-489f-95cc-17553d23934f.txn +0 -0
  16. data/train.lance/_transactions/3-f6436c59-cd6e-4b73-aead-c300d7066cbe.txn +0 -0
  17. data/train.lance/_transactions/4-c2794e3f-baee-4308-b992-831a0d265c7b.txn +0 -0
  18. data/train.lance/_versions/18446744073709551610.manifest +0 -0
  19. data/train.lance/_versions/18446744073709551611.manifest +0 -0
  20. data/train.lance/_versions/18446744073709551612.manifest +0 -0
  21. data/train.lance/_versions/18446744073709551613.manifest +0 -0
  22. data/train.lance/_versions/18446744073709551614.manifest +0 -0
  23. data/train.lance/data/10000010110000100100000109f1d84463bb4470ce97fd5868.lance +3 -0
.gitattributes CHANGED
@@ -58,3 +58,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ data/train.lance/_indices/fb6b87a4-768b-4da7-aa6b-735d9637c186/index.idx filter=lfs diff=lfs merge=lfs -text
62
+ data/train.lance/_indices/fe5a3535-6ea7-47f2-a4ad-c00f4c4c69b7/page_data.lance filter=lfs diff=lfs merge=lfs -text
63
+ data/train.lance/_indices/a1cb5252-7e54-4e30-9c4c-4c69cd053480/index.idx filter=lfs diff=lfs merge=lfs -text
64
+ data/train.lance/_indices/fb6b87a4-768b-4da7-aa6b-735d9637c186/auxiliary.idx filter=lfs diff=lfs merge=lfs -text
65
+ data/train.lance/_indices/a1cb5252-7e54-4e30-9c4c-4c69cd053480/auxiliary.idx filter=lfs diff=lfs merge=lfs -text
66
+ data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/part_0_invert.lance filter=lfs diff=lfs merge=lfs -text
67
+ data/train.lance/data/10000010110000100100000109f1d84463bb4470ce97fd5868.lance filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ task_categories:
4
+ - image-to-text
5
+ - image-text-to-text
6
+ - image-feature-extraction
7
+ language:
8
+ - en
9
+ tags:
10
+ - flickr30k
11
+ - image-captioning
12
+ - vision-language
13
+ - lance
14
+ - clip-embeddings
15
+ pretty_name: flickr30k-lance
16
+ size_categories:
17
+ - 10K<n<100K
18
+ ---
19
+ # Flickr30k (Lance Format)
20
+
21
+ Lance-formatted version of [Flickr30k](https://shannon.cs.illinois.edu/DenotationGraph/) (re-distributed via [`lmms-lab/flickr30k`](https://huggingface.co/datasets/lmms-lab/flickr30k)) — **31,783 images, each paired with 5 human-written captions**, with CLIP image **and** text embeddings stored inline and pre-built ANN indices on both.
22
+
23
+ ## Key features
24
+
25
+ - **Inline images** — full JPEG bytes per row.
26
+ - **Pre-computed CLIP embeddings** for both image and caption text — `IVF_PQ` indices on both columns let you do cross-modal retrieval (image→caption or caption→image) without any model at query time.
27
+ - **Full-text inverted index** on the canonical caption.
28
+ - Self-contained: no sidecar files or external image downloads.
29
+
30
+ ## Schema
31
+
32
+ | Column | Type | Notes |
33
+ |---|---|---|
34
+ | `id` | `int64` | Row index |
35
+ | `image` | `large_binary` | Inline JPEG bytes |
36
+ | `image_id` | `string` | Original Flickr image id |
37
+ | `filename` | `string` | Original filename (e.g. `1000092795.jpg`) |
38
+ | `captions` | `list<string>` | All 5 captions for the image |
39
+ | `caption` | `string` | First caption — used as canonical text for FTS / quick browsing |
40
+ | `image_emb` | `fixed_size_list<float32, 512>` | CLIP image embedding (cosine-normalized) |
41
+ | `text_emb` | `fixed_size_list<float32, 512>` | CLIP text embedding of the canonical caption |
42
+
43
+ ## Pre-built indices
44
+
45
+ - `IVF_PQ` on `image_emb` — `metric=cosine`
46
+ - `IVF_PQ` on `text_emb` — `metric=cosine` (cross-modal retrieval works out of the box)
47
+ - `INVERTED` on `caption`
48
+ - `BTREE` on `image_id`
49
+
50
+ ## Splits
51
+
52
+ A single `train.lance` table containing all 31,783 rows (the `lmms-lab/flickr30k` redistribution exposes them as a single split). The original train/val/test labels are not preserved in the source parquet.
53
+
54
+ ## Load with Lance
55
+
56
+ ```python
57
+ import lance
58
+
59
+ ds = lance.dataset("hf://datasets/lance-format/flickr30k-lance/data/train.lance")
60
+ print(ds.count_rows(), ds.schema.names, ds.list_indices())
61
+ ```
62
+
63
+ ## Cross-modal text→image search
64
+
65
+ ```python
66
+ import lance
67
+ import pyarrow as pa
68
+ import open_clip
69
+ import torch
70
+
71
+ # 1. Encode the query text once with the same CLIP model used at conversion.
72
+ model, _, _ = open_clip.create_model_and_transforms("ViT-B-32", pretrained="laion2b_s34b_b79k")
73
+ tokenizer = open_clip.get_tokenizer("ViT-B-32")
74
+ model = model.eval().cuda().half()
75
+ with torch.no_grad():
76
+ q = model.encode_text(tokenizer(["a man surfing at sunset"]).cuda())
77
+ q = (q / q.norm(dim=-1, keepdim=True)).float().cpu().numpy()[0]
78
+
79
+ ds = lance.dataset("hf://datasets/lance-format/flickr30k-lance/data/train.lance")
80
+ emb_field = ds.schema.field("image_emb")
81
+ query = pa.array([q.tolist()], type=emb_field.type)
82
+
83
+ # 2. Nearest-neighbour search against the image embedding index.
84
+ hits = ds.scanner(
85
+ nearest={"column": "image_emb", "q": query[0], "k": 10, "nprobes": 16, "refine_factor": 30},
86
+ columns=["image_id", "caption"],
87
+ ).to_table().to_pylist()
88
+ for h in hits:
89
+ print(h)
90
+ ```
91
+
92
+ ## Image→caption (image-to-text retrieval)
93
+
94
+ ```python
95
+ ds = lance.dataset("hf://datasets/lance-format/flickr30k-lance/data/train.lance")
96
+ ref = ds.take([0], columns=["image_emb", "caption"]).to_pylist()[0]
97
+ emb_field = ds.schema.field("text_emb")
98
+ query = pa.array([ref["image_emb"]], type=emb_field.type)
99
+ neighbors = ds.scanner(
100
+ nearest={"column": "text_emb", "q": query[0], "k": 10},
101
+ columns=["caption"],
102
+ ).to_table().to_pylist()
103
+ ```
104
+
105
+ ## Full-text search on captions
106
+
107
+ ```python
108
+ import lance
109
+ ds = lance.dataset("hf://datasets/lance-format/flickr30k-lance/data/train.lance")
110
+ hits = ds.scanner(
111
+ full_text_query="dog playing in the snow",
112
+ columns=["image_id", "caption"],
113
+ limit=10,
114
+ ).to_table().to_pylist()
115
+ ```
116
+
117
+ ## Working with images
118
+
119
+ ```python
120
+ from pathlib import Path
121
+ import lance
122
+ ds = lance.dataset("hf://datasets/lance-format/flickr30k-lance/data/train.lance")
123
+ row = ds.take([0], columns=["image", "filename"]).to_pylist()[0]
124
+ Path(row["filename"]).write_bytes(row["image"])
125
+ ```
126
+
127
+ ## Why Lance?
128
+
129
+ - One dataset carries images + image embeddings + text embeddings + indices — no sidecar files.
130
+ - On-disk vector and full-text indices live next to the data, so search works on local copies and on the Hub.
131
+ - Schema evolution: add columns (new captions, alternate embeddings, moderation labels) without rewriting the data.
132
+
133
+ ## Source & license
134
+
135
+ Converted from [`lmms-lab/flickr30k`](https://huggingface.co/datasets/lmms-lab/flickr30k), which is itself a parquet redistribution of the [original Flickr30k corpus](https://shannon.cs.illinois.edu/DenotationGraph/). Original images come from Flickr; review the Flickr30k licensing terms before redistribution.
136
+
137
+ ## Citation
138
+
139
+ ```
140
+ @article{young2014image,
141
+ title={From image descriptions to visual denotations: New similarity metrics for semantic inference over event descriptions},
142
+ author={Young, Peter and Lai, Alice and Hodosh, Micah and Hockenmaier, Julia},
143
+ journal={Transactions of the Association for Computational Linguistics},
144
+ volume={2},
145
+ pages={67--78},
146
+ year={2014}
147
+ }
148
+ ```
data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/metadata.lance ADDED
Binary file (733 Bytes). View file
 
data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/part_0_docs.lance ADDED
Binary file (84.5 kB). View file
 
data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/part_0_invert.lance ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2437c50ad7266d13e94fc9feb57f1063426d06d137447f1a780aa73b10538413
3
+ size 1469655
data/train.lance/_indices/2f6828e7-4d8b-4c7d-821c-0221fb8b8fc4/part_0_tokens.lance ADDED
Binary file (49.8 kB). View file
 
data/train.lance/_indices/a1cb5252-7e54-4e30-9c4c-4c69cd053480/auxiliary.idx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a14e7885756de384d6dcdc6b6f540b7f5c91b1a839e0a8d5db8940723b11b8e
3
+ size 2626506
data/train.lance/_indices/a1cb5252-7e54-4e30-9c4c-4c69cd053480/index.idx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe677b9cb37df36784cb7bacb3ca57b176cc410f3b5e970bbbe459a4240a2c8c
3
+ size 131722
data/train.lance/_indices/fb6b87a4-768b-4da7-aa6b-735d9637c186/auxiliary.idx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f365fea79ee039d029c19d278b50b593f81700eb9f0c62c00417ea45b50f5b2b
3
+ size 2626506
data/train.lance/_indices/fb6b87a4-768b-4da7-aa6b-735d9637c186/index.idx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:367f748e184f59aa94c6e6bc9094d98c87f56604a574c26c7a2de0ca3c7946fc
3
+ size 131722
data/train.lance/_indices/fe5a3535-6ea7-47f2-a4ad-c00f4c4c69b7/page_data.lance ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d2c2929ead9706d444a762675098ef1d90854ebdee04ae4e5fb851966c965bd
3
+ size 273059
data/train.lance/_indices/fe5a3535-6ea7-47f2-a4ad-c00f4c4c69b7/page_lookup.lance ADDED
Binary file (1.4 kB). View file
 
data/train.lance/_transactions/0-847b0efd-6b40-4c46-9c85-765cf941ce85.txn ADDED
Binary file (476 Bytes). View file
 
data/train.lance/_transactions/1-805ba875-2962-4001-89a3-723d27e57965.txn ADDED
Binary file (190 Bytes). View file
 
data/train.lance/_transactions/2-33597c13-df53-489f-95cc-17553d23934f.txn ADDED
Binary file (189 Bytes). View file
 
data/train.lance/_transactions/3-f6436c59-cd6e-4b73-aead-c300d7066cbe.txn ADDED
Binary file (284 Bytes). View file
 
data/train.lance/_transactions/4-c2794e3f-baee-4308-b992-831a0d265c7b.txn ADDED
Binary file (196 Bytes). View file
 
data/train.lance/_versions/18446744073709551610.manifest ADDED
Binary file (1.45 kB). View file
 
data/train.lance/_versions/18446744073709551611.manifest ADDED
Binary file (1.38 kB). View file
 
data/train.lance/_versions/18446744073709551612.manifest ADDED
Binary file (1.05 kB). View file
 
data/train.lance/_versions/18446744073709551613.manifest ADDED
Binary file (904 Bytes). View file
 
data/train.lance/_versions/18446744073709551614.manifest ADDED
Binary file (1.04 kB). View file
 
data/train.lance/data/10000010110000100100000109f1d84463bb4470ce97fd5868.lance ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d53b074161a80d0038435c8ee9e394245d8e6bc38f073360e0efe238b690f2ee
3
+ size 2535777772