--- license: cc-by-4.0 pretty_name: "LAION-Natural Embeddings" task_categories: - feature-extraction - image-classification - zero-shot-classification - image-to-image language: - en tags: - laion - laion-natural - laion-2b - relaion - embeddings - clip - image-embeddings - natural-images - image-retrieval - photograph-detection - ccn2025 - visual-neuroscience size_categories: - 100M LAION-Natural Embeddings

# LAION-Natural Embeddings: CLIP ViT-H/14 Features for ~500M Natural Photographs (CCN 2025, Roth & Hebart) **LAION-Natural Embeddings** provides pre-computed **CLIP ViT-H/14 embeddings** for ~500 million natural photographs from ReLAION-2B, filtered using the [LAION-Natural](https://huggingface.co/datasets/andropar/relaion2b-natural) naturalness classifier (score > 0.7). > **Also known as:** LAION-Natural Embeddings · ReLAION-Natural Embeddings · LAION-2B-Natural Embeddings > > Part of the LAION-Natural dataset family, introduced in: [*How to sample the world for understanding the visual system*](https://openreview.net/forum?id=T9k6KkZoca) (Roth & Hebart, CCN 2025) ## Quick Start ```python from datasets import load_dataset import numpy as np # Load with streaming (recommended for this size) ds = load_dataset("andropar/relaion2b-natural-embeddings", streaming=True) for row in ds['train']: url = row['url'] embedding = np.array(row['embedding']) # 768-dim CLIP embedding score = row['natural_score'] # 0.7 - 1.0 break ``` ## Overview | | | |---|---| | **Total embeddings** | ~514 million | | **Embedding model** | [CLIP ViT-H/14](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K) | | **Embedding dimensions** | 768 | | **Natural score range** | 0.7 - 1.0 (filtered for natural photographs) | | **Format** | Parquet (Snappy compressed) | | **Total size** | ~711 GB | ## Example Images All images in this dataset have natural scores > 0.7. Examples from different score ranges: **Natural score 0.7 - 0.8:** ![Examples with scores 0.7-0.8](examples/natural_0.7-0.8.png) **Natural score 0.8 - 0.9:** ![Examples with scores 0.8-0.9](examples/natural_0.8-0.9.png) **Natural score 0.9 - 1.0:** ![Examples with scores 0.9-1.0](examples/natural_0.9-1.0.png) *Thumbnails shown solely to illustrate dataset characteristics. Source: ReLAION-2B-en-research-safe (Apache 2.0). Underlying images remain under the copyright of their original creators.* ## Dataset Structure | Column | Type | Description | |--------|------|-------------| | `url` | string | Image URL from ReLAION-2B | | `natural_score` | float32 | Naturalness prediction (0.7 - 1.0) | | `feature_row_id` | int64 | Row index in original LAION-2B embeddings | | `embedding` | float32[768] | CLIP ViT-H/14 image embedding | Files are named `relaion2b_features_*.parquet` (2,298 files total). ## Usage Examples **Load embeddings with PyArrow:** ```python import pyarrow.parquet as pq import numpy as np # Load a single file table = pq.read_table("data/relaion2b_features_00000.parquet") # Convert to numpy embeddings = np.array([e.as_py() for e in table['embedding']]) urls = table['url'].to_pylist() scores = table['natural_score'].to_pylist() print(f"Loaded {len(embeddings)} embeddings, shape: {embeddings.shape}") ``` **Image similarity search:** ```python import numpy as np from sklearn.metrics.pairwise import cosine_similarity # Assuming you have a query embedding from CLIP query_embedding = ... # Your 768-dim CLIP embedding # Find most similar images similarities = cosine_similarity([query_embedding], embeddings)[0] top_k = np.argsort(similarities)[-10:][::-1] for idx in top_k: print(f"Score: {similarities[idx]:.3f}, URL: {urls[idx]}") ``` **Build a FAISS index for fast search:** ```python import faiss import numpy as np # Load embeddings from multiple files all_embeddings = [] for i in range(10): # First 10 files table = pq.read_table(f"data/relaion2b_features_{i:05d}.parquet") embs = np.array([e.as_py() for e in table['embedding']], dtype=np.float32) all_embeddings.append(embs) embeddings = np.vstack(all_embeddings) # Build index index = faiss.IndexFlatIP(768) # Inner product (for normalized vectors) faiss.normalize_L2(embeddings) index.add(embeddings) # Search query = np.random.randn(1, 768).astype(np.float32) faiss.normalize_L2(query) distances, indices = index.search(query, k=10) ``` **Stream with HuggingFace datasets:** ```python from datasets import load_dataset ds = load_dataset("andropar/relaion2b-natural-embeddings", streaming=True) # Process in batches batch = [] for i, row in enumerate(ds['train']): batch.append(row['embedding']) if len(batch) >= 1000: # Process batch embeddings = np.array(batch) # ... your processing ... batch = [] if i >= 10000: break ``` ## Use Cases - **Image similarity search:** Find visually similar images in a large corpus - **Zero-shot classification:** Use CLIP embeddings for classification without training - **Clustering:** Discover visual themes and patterns in natural photographs - **Training data:** Use as features for downstream models - **Research:** Study visual representations at scale ## Related Datasets - **[LAION-Natural (scores)](https://huggingface.co/datasets/andropar/relaion2b-natural)** — Natural scores for all 2.1B ReLAION-2B images, plus the trained naturalness classifier with portable weights and evaluation diagnostics. Use this to get URLs for images with any score threshold. - **[LAION-Natural (alias)](https://huggingface.co/datasets/andropar/laion-natural)** — Alias repository for discoverability ## Attribution - **Source dataset:** [ReLAION-2B-en-research-safe](https://huggingface.co/datasets/laion/relaion2B-en-research-safe) by LAION - **Embedding model:** [CLIP ViT-H/14](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K) trained on LAION-2B ## Licensing / Content This repository contains only **metadata and derived features** (URLs, natural scores, embeddings). No images are distributed. - The underlying images are hosted by third-party websites and remain under their original copyrights and terms of use. - Our additions (embeddings, documentation) are released under **CC-BY 4.0**. - This dataset is based on [ReLAION-2B-en-research-safe](https://huggingface.co/datasets/laion/relaion2B-en-research-safe), which is licensed under **Apache 2.0**. - Please check license compatibility for any commercial usage. ## Citation ```bibtex @inproceedings{ roth2025how, title={How to sample the world for understanding the visual system}, author={Johannes Roth and Martin N Hebart}, booktitle={8th Annual Conference on Cognitive Computational Neuroscience}, year={2025}, url={https://openreview.net/forum?id=T9k6KkZoca} } ``` ## Limitations - Embeddings are from CLIP ViT-H/14, which was trained on web data and may reflect its biases - "Naturalness" is based on a learned classifier - see [relaion2b-natural](https://huggingface.co/datasets/andropar/relaion2b-natural) for methodology - Some URLs may be broken or point to different/removed images over time - Intended for research use --- Questions or issues? Open a discussion!