Skip to main content

large-scale-entity-matching

A Python library for scalable entity matching on large tabular datasets — built for datasets where brute-force comparison is not an option.

Benchmark

Dataset Left rows Right rows Runtime Candidates found
US voter records 15,000,000 10,000,000 ~1.5 hours ~1,500,000

How it works

Instead of comparing all record pairs (O(n²)), this library uses a three-stage pipeline to make large-scale matching tractable:

  1. Blocking — groups records by token to reduce the candidate space
  2. ANN candidate generation — uses FAISS + sentence embeddings to find approximate nearest neighbors within each block
  3. Fuzzy scoring — ranks candidates using Monge-Elkan similarity and keeps the best matches

This combination allows matching datasets with tens of millions of rows on standard hardware.


Installation

pip install large-scale-entity-matching

Quick Start

import large_scale_entity_matching as lsem

config = lsem.MatchingConfig(
    group_strategy="last_token",
    top_k=10,
    threshold=0.88,
    num_candidate_partitions=16,
)

result = lsem.run_pipeline(
    left_input_file="left.parquet",
    right_input_file="right.parquet",
    left_id_col="id",
    right_id_col="id",
    left_key_cols=["first_name", "last_name", "city"],
    right_key_cols=["first_name", "last_name", "city"],
    work_dir="work",
    config=config,
)

print(result["final_output_parquet"])
print(result["score_info"])

Pipeline Overview

Raw input (CSV / Excel / Parquet)
        ↓
   Parquet conversion
        ↓
   Key construction
        ↓
   Blocking (token-based grouping)
        ↓
   Exact matching
        ↓
   ANN candidate generation (FAISS + embeddings)
        ↓
   Candidate partitioning
        ↓
   Fuzzy scoring (Monge-Elkan)
        ↓
   Best-match selection + merge
        ↓
   Final output (Parquet / CSV)

Input Requirements

Each dataset must have:

  • one ID column
  • one or more columns used to build a matching key

Supported formats: CSV, Excel (.xls, .xlsx), Parquet


Configuration

All parameters are controlled via lsem.MatchingConfig:

config = lsem.MatchingConfig(
    group_strategy="last_token",       # blocking strategy: "last_token" | "first_token" | "none"
    model_name="sentence-transformers/all-MiniLM-L6-v2",  # embedding model
    top_k=20,                          # ANN neighbors per record
    threshold=0.88,                    # minimum similarity score
    num_candidate_partitions=256,      # parallelism for fuzzy scoring
    prepare_chunk_size=200_000,        # preprocessing chunk size
    device="cpu",                      # "cpu" or "cuda"
)

Key parameters

Parameter Description
group_strategy Blocking strategy. "last_token" works well for names. "none" disables blocking (slow on large data).
top_k Number of ANN neighbors per record. Higher = more recall, slower.
threshold Minimum Monge-Elkan score to keep a match.
num_candidate_partitions Controls memory usage during fuzzy scoring.
model_name Any sentence-transformers compatible model.

Advanced Usage

Individual pipeline steps can be called separately:

lsem.prepare_input_file(...)
lsem.prepare_blocking_features(...)
lsem.write_exact_matches(...)
lsem.write_candidate_pairs_ann_blocking_by_group(...)
lsem.split_candidates_into_partitions(...)
lsem.score_candidate_partitions(...)
lsem.keep_best_ties_from_parts(...)
lsem.merge_exact_and_fuzzy(...)

Stack

Python · FAISS · DuckDB · sentence-transformers · pandas


License

MIT License. See LICENSE for details.

Metadata

Release files for large-scale-entity-matching 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for large-scale-entity-matching 0.1.0
File Size Uploaded
large_scale_entity_matching-0.1.0.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for large-scale-entity-matching 0.1.0
File Interpreter ABI Platform
large_scale_entity_matching-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.0 kB

Release files / large_scale_entity_matching-0.1.0.tar.gz

Download URL large_scale_entity_matching-0.1.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
23067a067c16d38b5aa325581ce549bb4bd95760fdf61c89bc9f0a1056e791c7
BLAKE2b-256 checksum
How to use checksums
040aafdbd7e656528c5c0e9c439d74e3a178b793d672747cf27ddc6804e17d51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Release files / large_scale_entity_matching-0.1.0-py3-none-any.whl

Download URL large_scale_entity_matching-0.1.0-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be958ca6c518bafce7cc135b98db6e97e884e4d0bc3b085dada549bf1fda724b
BLAKE2b-256 checksum
How to use checksums
03d2e3ed932d07df8b2dc3c2bffe5acf7f734361af1838d73f22fd5417542a36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page