semhash
Fast Multimodal Semantic Deduplication & Filtering
What it is and what it does
SemHash is a semantic deduplication and filtering library that identifies and removes duplicate or near-duplicate records from datasets by computing embeddings and performing efficient similarity search. It works with text out of the box using fast model2vec embeddings, and supports images, audio, and other modalities through custom encoders. The library handles both single-dataset operations (cleaning a training set in place) and cross-dataset operations (removing records from one dataset that are semantically similar to another, useful for eliminating train/test leakage). It can work with simple lists or complex multi-column datasets, and provides inspection tools to understand deduplication decisions—including the ability to view duplicate clusters, compute statistics like duplicate ratio, and rethreshold results without recomputing embeddings.
Under the hood, SemHash relies on model2vec for fast text embeddings and vicinity for efficient approximate nearest-neighbor search, making it practical for large datasets. The library returns structured result objects that expose both the cleaned data and metadata about what was removed, allowing users to tune thresholds and inspect edge cases. It is lightweight with minimal dependencies and supports Python 3.10 and later.
Use it for:
- Clean training datasets by removing duplicate or near-duplicate text records before model training.
- Detect and remove train/test leakage by deduplicating test data against training data with a configurable similarity threshold.
- Filter outliers from image or text datasets to improve data quality for machine learning pipelines.
- Find representative samples from a large dataset to create a smaller, diverse subset for annotation or analysis.
- Deduplicate multi-column datasets like QA pairs by combining similarity across multiple fields.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SemHash deduplicates, filters outliers from, and finds representative samples in text, image, and multimodal datasets using semantic similarity with fast embeddings and efficient nearest-neighbor search.
Yes. SemHash is actively maintained, has no known vulnerabilities, installs with low friction, and solves a concrete problem—semantic deduplication—with a clean API and inspection tools. It is well-suited for data cleaning workflows in machine learning and is permissively licensed. The main consideration is that it requires Python 3.10+, and custom modalities beyond text require bringing your own encoder.
Install
semhash on PyPI
pip
pip install semhashuv
uv add semhashpoetry
poetry add semhashInstalling semhash
Before you install
Low friction: pure Python wheel with four runtime dependencies (model2vec, vicinity, frozendict, pyversity). Active maintenance with recent commits and 958 repository stars.
License in practice
MIT License permits unrestricted use, modification, and distribution with minimal restrictions—suitable for commercial and open-source projects.
Quickstart
pip install semhash
from semhash import SemHash
texts = ["example text 1", "example text 2"]
semhash = SemHash.from_records(records=texts)
result = semhash.self_deduplicate()
deduplicated = result.selected
Requires Python 3.10 or later. Text embedding uses model2vec; custom modalities require a compatible encoder passed to the model parameter.
Verify before relying
- Performance benchmarks and throughput for large-scale datasets (millions of records) are referenced but not detailed in the excerpt.
- Memory footprint and resource requirements for different dataset sizes and modalities.
- Specific similarity thresholds and their typical effects on deduplication ratios across different data types.
Package facts
| License | MIT License Copyright (c) 2024 The Minish Lab Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — model2vec, vicinity, frozendict, pyversity |
| Maintenance | actively maintained — 206 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 102,699/month — #12,853 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: semhash-0.4.1-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
imagededupFinds exact and near-duplicate images in…
permissive · top 15,000 on PyPI
rensaRensa computes MinHash signatures for fast…
permissive · top 15,000 on PyPI
splinkSplink performs probabilistic record linkage…
permissive · top 5,000 on PyPI
recordlinkageRecordLinkage identifies and matches records…
permissive · top 5,000 on PyPI
simhashComputes Simhash fingerprints for text and…
permissive · top 15,000 on PyPI
clip-benchmarkEvaluates CLIP-like vision-language models on…
permissive · top 15,000 on PyPI
model2vecModel2Vec converts sentence transformers into…
permissive · top 5,000 on PyPI
fiftyone-brainFiftyOne Brain provides AI/ML capabilities for…
permissive · top 15,000 on PyPI
cleanlabCleanlab automatically detects and helps fix…
permissive · top 15,000 on PyPI
lpipsComputes perceptual similarity between image…
permissive · top 5,000 on PyPI