--- license: mit pretty_name: Hugging Face Badges in Lance language: - en size_categories: - n<1K tags: - lance - badges - svg - image - text-retrieval thumbnail: https://huggingface.co/datasets/lance-format/hf-badges-lance/resolve/main/source/badges-thumbnail.png configs: - config_name: default default: true data_files: - split: train path: viewer/badges.parquet --- # Hugging Face Badges in Lance Search the official Hugging Face badges by action and retrieve the original artwork by filename. The collection includes badges for sharing a dataset, deploying an app on Spaces, opening a pull request, and using ML Intern. [Original Hugging Face Badges dataset and pinned source revision](https://huggingface.co/datasets/huggingface/badges/tree/05b1d96517868a58a66174409a84b497c413a1bd) ## Data | Lance table | Rows | Contents | | --- | ---: | --- | | `lance/assets.lance` | 149 | All original files, including 146 SVG variants, the thumbnail, source card, and Git attributes. Each row stores the original filename, bytes, byte length, and SHA-256 hash. SVG rows include the theme and any source label, target link, or title. | | `lance/actions.lance` | 23 | One row per badge action, with its label, the text embedded for search, all filenames for that action, and a retrieval vector. | The upstream catalog has no train, validation, or test splits. [Data Studio](https://huggingface.co/datasets/lance-format/hf-badges-lance/viewer/default/train) displays a Parquet preview of all 146 SVG variants rendered as PNGs under its default `train` split. The native Lance assets retain the original SVG bytes. ## Search for badge actions The source provides no embeddings. This release embeds each badge action in English using its source README heading or SVG title and a short description of the intended action, stored in `embedded_text`. Light and dark themes, sizes, and alternate filenames for the same action share one search result. The vectors use the first 256 dimensions of the encoder's Matryoshka representation with L2 normalization. The example uses the same encoder for the query and reports cosine similarity, with higher scores indicating closer matches. [Pinned static retrieval encoder revision](https://huggingface.co/sentence-transformers/static-retrieval-mrl-en-v1/tree/f60985c706f192d45d218078e49e5a8b6f15283a) ```bash pip install pylance==14.0.3 huggingface_hub==2.4.0 sentence-transformers==6.3.0 ``` ```python import lance from huggingface_hub import HfApi from sentence_transformers import SentenceTransformer repo = "lance-format/hf-badges-lance" root = f"hf://datasets/{repo}" revision = HfApi(token=False).dataset_info(repo, token=False).sha storage_options = {"hf_revision": revision} encoder = SentenceTransformer( "sentence-transformers/static-retrieval-mrl-en-v1", revision="f60985c706f192d45d218078e49e5a8b6f15283a", truncate_dim=256, device="cpu", ) query = "Show a badge to deploy my application on Hugging Face Spaces" query_vector = encoder.encode_query(query, normalize_embeddings=True) actions = lance.dataset(f"{root}/lance/actions.lance", storage_options=storage_options) matches = actions.to_table( columns=["action_id", "action", "variant_filenames", "_distance"], nearest={"column": "embedding", "q": query_vector, "k": 5, "metric": "cosine"}, ).to_pylist() for match in matches: score = 1 - match["_distance"] filenames = ", ".join(match["variant_filenames"]) print(f"{score:.4f} {match['action_id']} {match['action']} {filenames}") ``` To save a badge as an original SVG, select a filename from the matches and read its bytes from the assets table. ```python from pathlib import Path filename = matches[0]["variant_filenames"][0] assets = lance.dataset(f"{root}/lance/assets.lance", storage_options=storage_options) asset, = assets.to_table( filter=f"source_path = '{filename}'", columns=["source_bytes"], ).to_pylist() Path(filename).write_bytes(asset["source_bytes"]) ``` ## License and attribution Hugging Face published the original artwork and documentation under the MIT license. This release adds the Lance tables, badge-action search, and PNG previews. [Original dataset card](source/README.md) ยท [MIT license](LICENSE)