Skip to content

About

Composable curation pipeline for vision-language training datasets: image filtering, text cleaning, deduplication, CLIP scoring

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

25 Commits

Folders and files

Repository files navigation

VL-Data-Engine

What Composable pipeline for cleaning and filtering vision-language training datasets
Why Raw web-scraped VL data is noisy — uninformative captions, broken images, near-duplicates
Status 🟡 Active development
Stack Python, PyTorch, HuggingFace Datasets, open_clip
License BSD-3-Clause

TL;DR

pip install -e .
python scripts/run_pipeline.py data.jsonl --config configs/default.yaml --output ./filtered

Why This Exists

Building a good VL dataset is 90% garbage collection. LAION-scale scrapes contain images that are too small, aspect ratios that are unusable, captions that just say "photo" or "image 1", and near-duplicate texts that inflate the apparent dataset size while hurting training.

This pipeline chains composable filter and scorer stages into a single streaming pass over a JSONL dataset. It's fast, memory-efficient (lazy streaming, no loading everything at once), and easy to extend.

Stages

Filters (remove samples):

Stage Class What it does
Image quality ImageQualityFilter Min size, aspect ratio, valid format
Text length TextLengthFilter Word count, char length, uninformative caption blacklist
Language LanguageFilter langdetect — keep English (or other specified languages)
Deduplication DuplicateRemover Exact hash or MinHash near-duplicate removal

Scorers (add metadata, optionally filter):

Stage Class What it does
CLIP alignment CLIPAlignmentScorer Image-text cosine similarity via CLIP (filter by threshold)
Aesthetics AestheticsScorer LAION-style aesthetic quality score (CLIP + MLP)

Usage

Python API

from vl_data_engine import DataPipeline
from vl_data_engine.filters import (
    ImageQualityFilter, TextLengthFilter, LanguageFilter, DuplicateRemover
)
from vl_data_engine.scorers import CLIPAlignmentScorer

pipeline = DataPipeline([
    ImageQualityFilter(min_size=224, max_aspect_ratio=4.0),
    TextLengthFilter(min_words=3, max_words=200),
    LanguageFilter(allowed=["en"]),
    DuplicateRemover(method="minhash"),
    CLIPAlignmentScorer(threshold=0.25, device="cuda"),
])

stats = pipeline.run("laion-subset.jsonl", output_dir="./clean")
print(stats)
# {"total_out": 84230, "elapsed_sec": 412.3, "throughput_per_sec": 204.3, ...}

Config-based CLI

# configs/default.yaml
image_filter:
  enabled: true
  min_size: 224
text_filter:
  enabled: true
  min_words: 3
dedup:
  enabled: true
  method: minhash
python scripts/run_pipeline.py data.jsonl --config configs/default.yaml --output ./out

Input Format

JSONL, one sample per line:

{"image": "/path/to/img.jpg", "text": "A dog sitting in a park"}
{"url": "https://example.com/img.jpg", "text": "Portrait of a woman"}

Supports image (file path or PIL object), url (HTTP), caption, alt_text, text.

Output

Filtered JSONL shards in the output directory + pipeline_stats.json:

filtered_output/
  shard_00000.jsonl
  shard_00001.jsonl
  ...
  pipeline_stats.json

Running Tests

pytest tests/ -v

Part of my ongoing work on data-centric approaches to VLM training. Inspired by datasets like LAION, DataComp, and MMC4.


Tested on DataComp-1B subset and CC12M. Average retention rate: ~60-70% depending on thresholds.

About

Composable curation pipeline for vision-language training datasets: image filtering, text cleaning, deduplication, CLIP scoring

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages