Datasets:
Render full SVG diagrams for image search and previews
#3
by tsmithv11 - opened
- .gitattributes +1 -0
- README.md +5 -3
- lance/images.lance/_transactions/1-d0926691-1ac6-483e-9838-8d5be02f6a64.txn +0 -0
- lance/images.lance/_versions/18446744073709551613.manifest +0 -0
- lance/images.lance/_versions/latest_version_hint.json +1 -1
- lance/images.lance/data/110011101100001011100110a68def4bc7a58569104317b300.lance +3 -0
- release-info.json +97 -1
- viewer/assets.parquet +2 -2
.gitattributes
CHANGED
|
@@ -61,3 +61,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 61 |
lance/images.lance/data/010111101000110000100000958cff42fab9d4b7bb99e94d17.lance filter=lfs diff=lfs merge=lfs -text
|
| 62 |
lance/original-files.lance/data/011101111110100011000100d4537b458d83bbb20f10655bfe.lance filter=lfs diff=lfs merge=lfs -text
|
| 63 |
lance/test.lance/data/001100100100001111101110a1be354261bd5affe9c08ded24.lance filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 61 |
lance/images.lance/data/010111101000110000100000958cff42fab9d4b7bb99e94d17.lance filter=lfs diff=lfs merge=lfs -text
|
| 62 |
lance/original-files.lance/data/011101111110100011000100d4537b458d83bbb20f10655bfe.lance filter=lfs diff=lfs merge=lfs -text
|
| 63 |
lance/test.lance/data/001100100100001111101110a1be354261bd5affe9c08ded24.lance filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
lance/images.lance/data/110011101100001011100110a68def4bc7a58569104317b300.lance filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -33,11 +33,11 @@ The Hugging Face LLM Course uses these diagrams, screenshots, illustrations, and
|
|
| 33 |
| `viewer/test.parquet` | 2 | Original Hub viewer Parquet |
|
| 34 |
| `viewer/assets.parquet` | 132 | Thumbnails for browsing the full image collection |
|
| 35 |
|
| 36 |
-
The ["catalog" preview](https://huggingface.co/datasets/lance-format/documentation-images-lance/viewer/catalog/assets) uses SVG renders and the first frame of each GIF. The files table retains the original SVGs, complete animations, and exact source bytes. [Source tree inventory](source/inventory.jsonl) · [Release metadata](release-info.json)
|
| 37 |
|
| 38 |
## Search images with text
|
| 39 |
|
| 40 |
-
The release generates 1,152-dimensional float32 image embeddings with the visual encoder of Google SigLIP 2 `google/siglip2-so400m-patch16-384` at revision `dd658faac399427308559e2c3ac1e99cbe43845d`. Images were composited onto white where transparent. SVGs
|
| 41 |
|
| 42 |
Install the dependencies with `python -m pip install "pylance==14.0.3" "transformers==5.23.0" torch pillow huggingface_hub`.
|
| 43 |
|
|
@@ -58,7 +58,7 @@ model_revision = "dd658faac399427308559e2c3ac1e99cbe43845d"
|
|
| 58 |
encoder = AutoModel.from_pretrained(checkpoint, revision=model_revision).eval()
|
| 59 |
processor = AutoProcessor.from_pretrained(checkpoint, revision=model_revision)
|
| 60 |
query = "a diagram of a transformer model with an encoder and a decoder"
|
| 61 |
-
inputs = processor(text=[query], padding="max_length", truncation=True, return_tensors="pt")
|
| 62 |
with torch.inference_mode():
|
| 63 |
pooled = encoder.get_text_features(**inputs).pooler_output
|
| 64 |
vector = torch.nn.functional.normalize(pooled.float(), dim=-1)[0].numpy()
|
|
@@ -71,6 +71,8 @@ for hit in hits:
|
|
| 71 |
print(f"{1 - hit['_distance']:.4f} {hit['source_path']} {hit['content_type']}")
|
| 72 |
```
|
| 73 |
|
|
|
|
|
|
|
| 74 |
## Retrieve an original asset
|
| 75 |
|
| 76 |
```python
|
|
|
|
| 33 |
| `viewer/test.parquet` | 2 | Original Hub viewer Parquet |
|
| 34 |
| `viewer/assets.parquet` | 132 | Thumbnails for browsing the full image collection |
|
| 35 |
|
| 36 |
+
The ["catalog" preview](https://huggingface.co/datasets/lance-format/documentation-images-lance/viewer/catalog/assets) uses full, proportionally scaled SVG renders and the first frame of each GIF. The files table retains the original SVGs, complete animations, and exact source bytes. [Source tree inventory](source/inventory.jsonl) · [Release metadata](release-info.json)
|
| 37 |
|
| 38 |
## Search images with text
|
| 39 |
|
| 40 |
+
The release generates 1,152-dimensional float32 image embeddings with the visual encoder of Google SigLIP 2 `google/siglip2-so400m-patch16-384` at revision `dd658faac399427308559e2c3ac1e99cbe43845d`. Images were composited onto white where transparent. Sharp and librsvg render the full SVG viewport at its original aspect ratio. SVGs are centered on a white 384 × 384 canvas for encoding. GIFs use their first frame. The example uses the model's paired text encoder, normalizes both modalities to unit length, and prints five source paths with cosine similarity, calculated as one minus Lance's cosine distance. [Pinned SigLIP 2 checkpoint](https://huggingface.co/google/siglip2-so400m-patch16-384/tree/dd658faac399427308559e2c3ac1e99cbe43845d)
|
| 41 |
|
| 42 |
Install the dependencies with `python -m pip install "pylance==14.0.3" "transformers==5.23.0" torch pillow huggingface_hub`.
|
| 43 |
|
|
|
|
| 58 |
encoder = AutoModel.from_pretrained(checkpoint, revision=model_revision).eval()
|
| 59 |
processor = AutoProcessor.from_pretrained(checkpoint, revision=model_revision)
|
| 60 |
query = "a diagram of a transformer model with an encoder and a decoder"
|
| 61 |
+
inputs = processor(text=[query.lower()], padding="max_length", max_length=64, truncation=True, return_tensors="pt")
|
| 62 |
with torch.inference_mode():
|
| 63 |
pooled = encoder.get_text_features(**inputs).pooler_output
|
| 64 |
vector = torch.nn.functional.normalize(pooled.float(), dim=-1)[0].numpy()
|
|
|
|
| 71 |
print(f"{1 - hit['_distance']:.4f} {hit['source_path']} {hit['content_type']}")
|
| 72 |
```
|
| 73 |
|
| 74 |
+
In a small check on 16 queries with known target images, the full SVG renders moved two more targets into the top five, from 11 to 13. The score shown for each result is raw cosine similarity. [Query check and preprocessing details](release-info.json)
|
| 75 |
+
|
| 76 |
## Retrieve an original asset
|
| 77 |
|
| 78 |
```python
|
lance/images.lance/_transactions/1-d0926691-1ac6-483e-9838-8d5be02f6a64.txn
ADDED
|
Binary file (463 Bytes). View file
|
|
|
lance/images.lance/_versions/18446744073709551613.manifest
ADDED
|
Binary file (1 kB). View file
|
|
|
lance/images.lance/_versions/latest_version_hint.json
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"version":
|
|
|
|
| 1 |
+
{"version":2}
|
lance/images.lance/data/110011101100001011100110a68def4bc7a58569104317b300.lance
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bfcb7b052de72e80f3c7212b8fde80786105e1aa5b74c5760225e57ed938355c
|
| 3 |
+
size 637159
|
release-info.json
CHANGED
|
@@ -20,5 +20,101 @@
|
|
| 20 |
"model": "google/siglip2-so400m-patch16-384",
|
| 21 |
"model_revision": "dd658faac399427308559e2c3ac1e99cbe43845d",
|
| 22 |
"dimensions": 1152,
|
| 23 |
-
"similarity": "cosine"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
|
|
|
| 20 |
"model": "google/siglip2-so400m-patch16-384",
|
| 21 |
"model_revision": "dd658faac399427308559e2c3ac1e99cbe43845d",
|
| 22 |
"dimensions": 1152,
|
| 23 |
+
"similarity": "cosine",
|
| 24 |
+
"svg_preprocessing": {
|
| 25 |
+
"source_images": 51,
|
| 26 |
+
"renderer": "Sharp 0.35.5 with librsvg 2.63.2",
|
| 27 |
+
"render": "Full declared SVG viewport scaled to fit within 560 \u00d7 560, with aspect ratio preserved",
|
| 28 |
+
"embedding_input": "Composite onto white and fit within a white 384 \u00d7 384 canvas",
|
| 29 |
+
"thumbnail": "Proportional JPEG fitting within 480 \u00d7 480"
|
| 30 |
+
},
|
| 31 |
+
"svg_search_check": {
|
| 32 |
+
"labeled_queries": 16,
|
| 33 |
+
"target_in_top_5_before": 11,
|
| 34 |
+
"target_in_top_5_after": 13,
|
| 35 |
+
"top1_before": 8,
|
| 36 |
+
"top1_after": 8,
|
| 37 |
+
"queries": [
|
| 38 |
+
{
|
| 39 |
+
"query": "a diagram of a transformer model with an encoder and a decoder",
|
| 40 |
+
"rank_before": 1,
|
| 41 |
+
"rank_after": 1
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"query": "a detailed transformer architecture comparing BERT encoder and GPT decoder",
|
| 45 |
+
"rank_before": 1,
|
| 46 |
+
"rank_after": 1
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"query": "a diagram of how byte pair encoding splits a word into subwords",
|
| 50 |
+
"rank_before": 42,
|
| 51 |
+
"rank_after": 42
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"query": "a diagram of how word based tokenization splits a sentence",
|
| 55 |
+
"rank_before": 27,
|
| 56 |
+
"rank_after": 2
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"query": "the architecture of the Whisper speech recognition model",
|
| 60 |
+
"rank_before": 1,
|
| 61 |
+
"rank_after": 1
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"query": "a diagram showing which tokens a masked language model predicts",
|
| 65 |
+
"rank_before": 1,
|
| 66 |
+
"rank_after": 1
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"query": "what a causal language model sees when predicting the next word",
|
| 70 |
+
"rank_before": 22,
|
| 71 |
+
"rank_after": 11
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"query": "the T5 text to text transformer architecture used for translation",
|
| 75 |
+
"rank_before": 17,
|
| 76 |
+
"rank_after": 2
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"query": "how inside and outside labels mark named entities with IOB tagging",
|
| 80 |
+
"rank_before": 27,
|
| 81 |
+
"rank_after": 70
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"query": "a screenshot from Argilla with highlighted spans in an annotated dataset",
|
| 85 |
+
"rank_before": 3,
|
| 86 |
+
"rank_after": 3
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"query": "image inpainting with a mask to replace only part of a picture",
|
| 90 |
+
"rank_before": 3,
|
| 91 |
+
"rank_after": 3
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"query": "the U-Net network diagram for Stable Diffusion",
|
| 95 |
+
"rank_before": 1,
|
| 96 |
+
"rank_after": 1
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"query": "handwritten digit generation conditioned on a class",
|
| 100 |
+
"rank_before": 1,
|
| 101 |
+
"rank_after": 1
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"query": "a screenshot of an interactive Gradio demo for testing a model",
|
| 105 |
+
"rank_before": 4,
|
| 106 |
+
"rank_after": 2
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"query": "a screenshot showing a Python exception and stack trace",
|
| 110 |
+
"rank_before": 1,
|
| 111 |
+
"rank_after": 1
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"query": "a plot showing the distribution of movie review lengths",
|
| 115 |
+
"rank_before": 1,
|
| 116 |
+
"rank_after": 1
|
| 117 |
+
}
|
| 118 |
+
]
|
| 119 |
+
}
|
| 120 |
}
|
viewer/assets.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f70508f235c180d8c6424e85437d874eb4f705bd293039fdafaa1c2dc63d1749
|
| 3 |
+
size 1791426
|