Datasets:
image imagewidth (px) 1.91k 1.91k |
|---|
Hugging Face Course Documentation Images in Lance
The Hugging Face LLM Course uses these diagrams, screenshots, illustrations, and animations in its lessons. This conversion preserves all 135 files and their original paths, including 132 images. The upstream Hub viewer has one two-image test split, which is preserved in Lance and as the exact original Parquet preview. The added image search table covers the complete asset collection. Original dataset · LLM Course
| Path | Rows | Contents |
|---|---|---|
lance/original-files.lance |
135 | Every original file with bytes, relative path, size, MIME type, and hashes |
lance/images.lance |
132 | Image paths, metadata, and search embeddings |
lance/test.lance |
2 | Original Hub viewer test image rows |
viewer/test.parquet |
2 | Original Hub viewer Parquet |
viewer/assets.parquet |
132 | Thumbnails for browsing the full image collection |
The "catalog" preview 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 · Release metadata
Search images with text
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 use rasterized previews and 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
Install the dependencies with python -m pip install "pylance==14.0.3" "transformers==5.23.0" torch pillow huggingface_hub.
import lance
import torch
from huggingface_hub import HfApi
from transformers import AutoModel, AutoProcessor
repo = "lance-format/documentation-images-lance"
revision = HfApi(token=False).dataset_info(repo, token=False).sha
uri = f"hf://datasets/{repo}/lance"
options = {"hf_revision": revision}
images = lance.dataset(f"{uri}/images.lance", storage_options=options)
checkpoint = "google/siglip2-so400m-patch16-384"
model_revision = "dd658faac399427308559e2c3ac1e99cbe43845d"
encoder = AutoModel.from_pretrained(checkpoint, revision=model_revision).eval()
processor = AutoProcessor.from_pretrained(checkpoint, revision=model_revision)
query = "a diagram of a transformer model with an encoder and a decoder"
inputs = processor(text=[query], padding="max_length", truncation=True, return_tensors="pt")
with torch.inference_mode():
pooled = encoder.get_text_features(**inputs).pooler_output
vector = torch.nn.functional.normalize(pooled.float(), dim=-1)[0].numpy()
hits = images.to_table(
columns=["source_path", "content_type", "_distance"],
nearest={"column": "embedding", "q": vector, "k": 5, "metric": "cosine"},
).to_pylist()
for hit in hits:
print(f"{1 - hit['_distance']:.4f} {hit['source_path']} {hit['content_type']}")
Retrieve an original asset
from pathlib import Path
import lance
from huggingface_hub import HfApi
repo = "lance-format/documentation-images-lance"
revision = HfApi(token=False).dataset_info(repo, token=False).sha
files = lance.dataset(
f"hf://datasets/{repo}/lance/original-files.lance",
storage_options={"hf_revision": revision},
)
asset, = files.to_table(
columns=["original_bytes"],
filter="source_path = 'en/chapter1/transformers_architecture.png'",
limit=1,
).to_pylist()
Path("transformers_architecture.png").write_bytes(asset["original_bytes"])
Source and license
Original assets are credited to Hugging Face and the LLM Course contributors. The dataset card declares Apache 2.0, and the course project includes the Apache 2.0 license. Changes in this release consist of added Lance tables, image embeddings, thumbnails, and file metadata. Image trademarks and other embedded notices remain visible in the originals. Original card · Apache 2.0 license · Course source
Credits for screenshots of published posts
en/chapter8/stack-overflow.pngreproduces an answer by cronoik, posted on March 14, 2021. The embedded answer remains under CC BY-SA 4.0. The Lance files table preserves the exact course screenshot, and the catalog preview displays a resized copy. Original answer · CC BY-SA 4.0 · Stack Overflow licensingen/chapter5/datasets-issues-comment.pngshows yjernite and patrickvonplaten discussing a Common Voice update.en/chapter5/datasets-issues-single.pngshows lewtun's Wikipedia streaming issue.en/chapter5/datasets-issues.pngshows the issue list. Common Voice issue · Wikipedia streaming issue · Hugging Face Datasets issue list
- Downloads last month
- -