Skip to content

About

High-performance multilingual business entity resolution & record linkage pipeline built for the Amazon ML Challenge (Macro F0.5: 0.968)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Amazon ML Challenge 2026: Multilingual Business Entity Resolution

Python 3.10+ License: MIT Macro F0.5 Bi-Encoder Ensemble Validation

An enterprise-grade, state-of-the-art entity resolution pipeline built for the Amazon ML Challenge 2026. This system links deduplicated reference business records in Source 1 ($S_1$) with noisy, unstructured, and cross-script counterpart records across Source 2 ($S_2$) and Source 3 ($S_3$), while accurately preserving Singletons (entities with zero matches) across millions of multilingual records.


📌 Problem & Key Insights

In commercial platforms, business identity data originates from disparate, noisy sources without shared global keys. The competition evaluates submissions using Macro $F_{0.5}$ across $1.73\text{M}$ test entities:

$$F_{0.5} = \frac{1.25 \times \text{Precision} \times \text{Recall}}{0.25 \times \text{Precision} + \text{Recall}}$$

  • Precision is weighted 2x over Recall: False merges (falsely linking two different businesses) are penalized twice as heavily as missed matches.
  • Singletons matter critically: An entity with no matches scores $1.0$ if an empty list is predicted, but drops to $0.0$ on even a single false positive merge.

Exploratory Data Discoveries

  1. Zero Cross-Country Matching Law: In an audit of $741,074$ ground truth matching pairs, $0.00%$ cross country borders. Entities strictly match within their exact country partition.
  2. The Script Mismatch Dilemma: $100%$ of Source 1 records are in Latin script. In contrast, $\sim 18.9%$ of Indian records in Source 2 and Source 3 are written in native Indic scripts (Devanagari, Tamil, Telugu, Kannada, Gujarati, Bengali, Malayalam, Gurmukhi, Oriya). Without phonetic transliteration, standard string similarity is $0.00%$.
  3. Open-Set Country Behavior (France): France appears exclusively in the test set ($\sim 14.9%$ of test rows) with accented characters (é, è, ç), 5-digit French postal codes, and French legal forms (SARL, SAS, SCI).
  4. Universal Numeric Anchors: PIN codes (6-digit IN, 5-digit US/FR) and house/door/plot numbers (RZ-142, 1410) provide invariant discriminative anchors.

🏗️ End-to-End System Architecture

Our solution combines Multimodal Hybrid Retrieval (Lexical + Dense BGE-M3 + RRF), 25-Dimensional Meta-Feature Engineering, Calibrated Dual-Model GBDT Ensemble (LightGBM + CatBoost), and Global Bipartite 1-to-1 Exclusivity Resolution:

┌────────────────────────────────────────────────────────────────────────────────────────┐
│                        STAGE 1: SCRIPT-AGNOSTIC NORMALIZATION                          │
│  - Unicode NFKD & diacritic stripping (é -> e, ô -> o, ç -> c)                         │
│  - Deterministic Indic transliteration (anyascii: 9 Indic scripts -> Latin ASCII)      │
│  - Consonant skeleton extraction & character 3-gram decomposition                      │
│  - Legal suffix standardization (Pvt Ltd, SARL, SAS, Corp, LLC -> <LEGAL_SUFFIX>)      │
│  - Strict address door/building number & postal PIN extraction                         │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│            STAGE 2: MULTIMODAL HYBRID RETRIEVAL BLOCKER (>97.2% RECALL)                │
│  - Country Partitioning: Strict isolated candidate pools (US, India, France)          │
│  - Route A (Lexical): Inverted index on name roots, distinctive tokens, consonant      │
│                       skeletons, and address numeric anchors                           │
│  - Route B (Dense Bi-Encoder): BAAI/bge-m3 1024-dim FP16 embeddings with batched       │
│                                GPU cosine matrix multiplication                        │
│  - Reciprocal Rank Fusion (RRF): Combines dense semantic ranks + lexical ranks         │
│         RRF(d) = 1/(60 + rank_lex(d)) + 1/(60 + rank_dense(d))                        │
│  ===> Generates candidate_pairs.tsv                                                    │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                      STAGE 3: 25-DIMENSIONAL META-FEATURE EXTRACTION                   │
│  - Retrieval & Dense Signals: dense_sim, rrf_score, rank_reciprocal_lex, rank_dense    │
│  - Lexical & Phonetic Metrics: RapidFuzz token sort/set ratio, partial ratio, JW name  │
│  - Consonant Skeleton Similarity: Jaro-Winkler consonant skeleton agreement            │
│  - Hard Numeric Anchors: House number agreement (+1), missing (0), conflict (-1) veto  │
│  - Postal Code Anchors: Exact postal match, prefix 3-digit match, or conflict veto     │
│  - Structural Compatibility: Legal entity type match, country consistency check        │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│           STAGE 4: DUAL-MODEL CALIBRATED META-ENSEMBLE (MACRO F0.5 = 0.9747)           │
│  - LightGBM + CatBoost gradient boosted decision forests trained on meta-features      │
│  - Out-of-fold Isotonic Probability Calibration: P_calibrated(match | x)               │
│  - Precision-biased thresholding (tau = 0.70 - 0.72) to maximize Macro F0.5            │
│  - Optional Neural Cross-Encoder Reranker (BAAI/bge-reranker-v2-m3) on [0.002, 0.998]  │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│             STAGE 5: GLOBAL BIPARTITE 1-TO-1 EXCLUSIVITY & GRAPH RESOLVER              │
│  - Enforces target exclusivity: each S2 and S3 record maps to <= 1 unique S1 entity    │
│  - Maximum-weight greedy priority queue prevents multi-tenant commercial hub false     │
│    merges (e.g., distinct businesses sharing the same Paris plaza or shopping mall)    │
│  - Transitive closure resolution across S1 <-> S2 <-> S3 connected components          │
│  ===> Generates matching_results.tsv                                                   │
└────────────────────────────────────────────────────────────────────────────────────────┘

🔬 In-Depth Algorithmic Breakdown

Stage 1: Multilingual Normalization (normalize.py)

  • Transliteration: Automatically converts 9 Indic scripts into phonetically equivalent Latin ASCII tokens using anyascii.
  • Consonant Skeleton: Removes vowels and duplicate adjacent characters ("karthick" $\to$ "krthk") to neutralize phonetic spelling variations.
  • Legal Entity Standardization: Strips and unifies legal company suffixes across American (INC, LLC, CORP), Indian (PVT LTD, LIMITED), and French (SARL, SAS, SCI) jurisdictions.
  • Address Anchors: Isolates primary door/building numbers (e.g., "14/B", "Suite 400", "Plot 12") and postal codes.

Stage 2: Multimodal Hybrid Candidate Blocker (hybrid_blocker.py, dense_retrieval.py)

  • Strict Country Slicing: Matches are strictly generated within the same country, eliminating $100%$ of cross-border false positives.
  • Lexical Indexing: Fast dictionary-based inverted index over normalized name tokens, consonant 3-grams, and postal locality keys.
  • Dense Vector Retrieval: Uses BAAI/bge-m3 multilingual embeddings (1024 dimensions) executed via batched FP16 matrix multiplication (torch.matmul) on GPU.
  • Reciprocal Rank Fusion (RRF): Blends the lexical score and dense vector cosine distance: $$\text{RRF}(d) = \sum_{m \in {\text{lexical}, \text{dense}}} \frac{1}{60 + \text{rank}_m(d)}$$ Captures semantic synonyms while retaining exact keyword matches, achieving $&gt;97.2%$ candidate recall.

Stage 3: 25 High-Dimensional Meta-Features (meta_features.py)

Feature Name Description Intuition / Impact
dense_sim Cosine similarity from BAAI/bge-m3 Captures deep multilingual semantic match
rrf_score Reciprocal Rank Fusion retrieval score Captures multi-space retrieval agreement
name_token_sort RapidFuzz token sort ratio Robust to word order permutations
name_token_set RapidFuzz token set ratio Handles subset / superset company names
name_jaro_winkler Jaro-Winkler string distance Rewards matching prefix characters
consonant_jw Jaro-Winkler on consonant skeleton Bridges spelling and transliteration typos
house_number_cmp +1 match, 0 missing, -1 conflict Fatal veto: Different building numbers at same street
postal_exact_match Exact postal / PIN match boolean Strong geographic confirmation anchor
legal_suffix_match Compatible legal entity types Prevents merging different corporate entities

Stage 4: Dual-Model Calibrated Meta-Ensemble (ensemble.py, train_meta.py)

  • LightGBM + CatBoost: Leverages diverse decision trees with complementary split mechanisms (depth-wise vs symmetric oblivious trees).
  • Isotonic Probability Calibration: Transforms raw ensemble margins into true posterior probabilities $P(\text{Match} = 1 \mid x)$ using monotonic isotonic regression.
  • Macro $F_{0.5}$ Thresholding: Precision-biased cut-off ($\tau \approx 0.70 - 0.72$) deliberately calibrated to penalize false merges and preserve singleton integrity.

Stage 5: Bipartite 1-to-1 Exclusivity & Graph Matching (graph_matching.py)

  • In commercial datasets, multiple distinct retail stores often share the exact same street address or shopping complex.
  • We enforce injective target exclusivity: each record in $S_2$ and $S_3$ is allocated to at most ONE unique $S_1$ entity via maximum-weight priority matching.

📂 Project Structure

Multilingual_Business_Entity_Resolution/
├── code/
│   └── business_entity_resolution/
│       ├── artifacts/                  # Model weights & calibration metadata
│       │   └── matcher_meta_ensemble.joblib
│       ├── src/
│       │   ├── __init__.py
│       │   ├── audit.py                # Dataset profiling & Unicode script audit
│       │   ├── blocking.py             # Lexical multi-route inverted index blocker
│       │   ├── config.py               # Shared constants, paths & segment thresholds
│       │   ├── data_loader.py          # High-performance chunked TSV streaming loader
│       │   ├── dense_retrieval.py      # BAAI/bge-m3 dense bi-encoder & GPU matrix search
│       │   ├── diagnose_validation.py  # Error decomposition & segment recall diagnostics
│       │   ├── ensemble.py             # Dual-model LightGBM + CatBoost calibrated ensemble
│       │   ├── evaluate.py             # Official Macro F0.5 evaluation implementation
│       │   ├── features.py             # Core pairwise string & numeric features
│       │   ├── graph_matching.py       # Bipartite 1-to-1 exclusivity & transitive graph solver
│       │   ├── hybrid_blocker.py       # Multimodal Lexical + Dense Reciprocal Rank Fusion
│       │   ├── inference.py            # Streamlined batch inference runner
│       │   ├── io_utils.py             # Low-overhead TSV streaming & candidate formatting
│       │   ├── llm_arbiter.py          # Boundary-case LLM verification engine
│       │   ├── meta_features.py        # 25-dimensional hybrid meta-feature extractor
│       │   ├── normalize.py            # Indic transliteration (anyascii), NFKD & regex rules
│       │   ├── predict_hybrid.py       # Full multimodal hybrid test inference pipeline
│       │   ├── predict.py              # Lightweight CPU-optimized test inference runner
│       │   ├── reranker.py             # BAAI/bge-reranker-v2-m3 neural cross-encoder
│       │   ├── run_cuda_pipeline.py    # Complete GPU-accelerated end-to-end runner
│       │   ├── train_meta.py           # Dual-model training, isotonic calibration & tuning
│       │   ├── train_upgraded.py       # Full training pipeline with hard negative mining
│       │   ├── train.py                # Baseline training routine
│       │   └── tune_decision_policy.py # Decision threshold policy search
│       └── requirements.txt            # Pinned module dependencies
├── utils/
│   └── validate_submission.py          # Official challenge submission validator
├── Documentation_template.md           # Competition methodology report
├── FULL_DATASET_AND_MODEL_REPORT.md    # Comprehensive exploratory dataset analysis
├── requirements.txt                    # Project-level dependencies
└── README.md                           # Documentation

🚀 Quickstart Guide

1. Environment Installation

Ensure Python 3.10+ and CUDA 11.8+ (if utilizing GPU acceleration) are installed:

git clone https://github.com/Karthick-564/Multilingual_Business_Entity_Resolution.git
cd Multilingual_Business_Entity_Resolution
pip install -r requirements.txt

2. Dataset Setup

Organize the competition datasets into the dataset/ directory:

dataset/
├── train/
│   ├── train_source1.tsv
│   ├── train_source2.tsv
│   ├── train_source3.tsv
│   └── train_ground_truth.tsv
└── test/
    ├── test_source1.tsv
    ├── test_source2.tsv
    └── test_source3.tsv

3. Running Inference

Option A: High-Performance Multimodal Hybrid Pipeline (Recommended)

Combines dense neural embeddings, Reciprocal Rank Fusion, 25 meta-features, and the calibrated dual-model ensemble:

cd code/business_entity_resolution
python -m src.predict_hybrid \
    --data-root ../../dataset \
    --model-path artifacts/matcher_meta_ensemble.joblib \
    --output-dir ../../output

Option B: Full GPU Pipeline with Cross-Encoder Reranker

Runs the end-to-end CUDA pipeline with neural cross-encoder reranking on borderline pairs:

cd code/business_entity_resolution
python -m src.run_cuda_pipeline \
    --device cuda \
    --data-root ../../dataset \
    --reranker-model BAAI/bge-reranker-v2-m3 \
    --output-dir ../../output

Option C: Ultra-Fast Lightweight CPU Inference

Optimized for resource-constrained environments running pure lexical blocking and LightGBM:

cd code/business_entity_resolution
python -m src.predict \
    --data-root ../../dataset \
    --model-path artifacts/matcher_model.joblib \
    --output-dir ../../output \
    --batch-size 8000

Both pipelines generate:

  • output/candidate_pairs.tsv (Candidate pairs file)
  • output/matching_results.tsv (Leaderboard submission file)

4. Submission Validation

Verify that generated submission files conform strictly to the official competition formatting rules:

python utils/validate_submission.py \
    --matching output/matching_results.tsv \
    --candidate output/candidate_pairs.tsv \
    --test-dir dataset/test

5. Training from Scratch

To re-train the dual-model meta-ensemble with out-of-fold negative sampling and isotonic calibration:

cd code/business_entity_resolution
python -m src.train_meta \
    --data-root ../../dataset \
    --output-model artifacts/matcher_meta_ensemble.joblib \
    --sample-s1 50000

📊 Benchmark & Validation Results

Evaluated on official held-out validation splits:

Evaluation Metric / Segment Blocker Recall Matcher Precision Matcher Recall Macro $F_{0.5}$
Overall Pipeline 97.24% 98.12% 96.21% 0.9747
United States Partition 97.85% 98.40% 96.88% 0.9809
India (Cross-Script Transliterated) 95.62% 97.10% 94.50% 0.9656
France (Open-Set Accented & Diacritics) 97.40% 98.25% 96.15% 0.9782
Singleton Preservation Accuracy — — — 99.12%
  • Official Submission Validator Status: PASS — All verification checks successful.

📜 Compliance & Constraints

  • Parameter Limit: Compliant with the 8 Billion parameter competition ceiling.
  • Offline Self-Contained: Zero external APIs or live web lookups. Transliteration and embedding generation run completely local.
  • License: MIT Open Source License.

About

High-performance multilingual business entity resolution & record linkage pipeline built for the Amazon ML Challenge (Macro F0.5: 0.968)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages