The user wants an entity reconciliation design for products, brands, categories, and attributes.
Entity reconciliation (also known as entity resolution or deduplication) is the process of determining if two or more records refer to the same real-world entity.
I need to structure this response as a comprehensive system design or a detailed process flow.
Scope:
- Entities: Products (SKUs, items), Brands (manufacturers), Categories (taxonomy), Attributes (specs like color, weight).
- Goal: Clean, canonical master data from messy, multi-source data.
Key Components of the Design:
- Data Ingestion & Normalization: Preparing the data before matching.
- Blocking/Canopying: Reducing the search space (don't compare everything to everything).
- Matching/Scoring: Algorithms to calculate similarity.
- Clustering/Consolidation: Grouping matches and creating a "Golden Record".
- Human-in-the-Loop (HITL): Handling low-confidence matches.
Specific Strategies by Entity:
Step-by-Step Design:
-
Pre-processing (The "Sanity Check"):
- Lowercasing, removing special chars.
- Extracting identifiers (UPC, EAN, ASIN, MPN).
-
The Pipeline (Cascading Reconciliation):
- Phase 1: Brand Resolution. You can't match products without knowing the brand.
- Phase 2: Category Resolution. Helps narrow down blocking.
- Phase 3: Attribute Extraction & Normalization.
- Phase 4: Product Resolution. The final showdown.
-
Algorithm Details:
- Blocking: Locality Sensitive Hashing (LSH) or Standard blocking (e.g., by Brand + first 3 chars of name).
- Similarity:
- String: Jaro-Winkler, Levenshtein, TF-IDF.
- Semantic: Word2Vec/BERT embeddings (overkill? maybe, but good for titles).
- Hard IDs: Exact match on GTIN is a "certain" match.
-
The Data Model (Schema):
- Source Table -> Staging -> Match Pairs -> Clusters -> Golden Record.
-
Handling Edge Cases:
- Variants (T-shirt in Red vs. T-shirt in Blue).
- Multipacks.
Drafting the Response Structure:
- Introduction: Define the goal (creating a "Golden Record").
- Architecture Overview: The flow diagram (text-based).
- Phase 1: Pre-processing & Feature Extraction: Cleaning and extracting the "atoms" of data.
- Phase 2: Strategy by Entity Type:
- Brands: Dictionary lookups + Fuzzy matching.
- Categories: Taxonomy mapping.
- Attributes: Unit normalization + Key extraction.
- Products: Multi-dimensional scoring (Title + Attributes + IDs).
- Phase 3: The Matching Logic (Blocking & Scoring): How to compute the score.
- Phase 4: Golden Record Creation: Survivability rules.
- Phase 5: Human-in-the-Loop (HITL): Review queue.
Refining the "Product" logic:
This is the hardest part. I should emphasize using Hard IDs (GTIN/MPN) as the "truth anchor" and Fuzzy Title Matching + Attribute Matching as the secondary anchor.
Self-Correction during thought process: I initially thought about doing Products first. But that's wrong. You need to reconcile Brands first because "Dove" (soap) vs "Dove" (chocolate) might look similar, but the brand differentiation (Unilever vs Mars) or Category differentiation is what separates them. Actually, context matters.
Let's stick to a dependency graph: Brand -> Category -> Attribute -> Product.
Wait, usually, Brand is a parent of Product. But Category is often independent.
So, 1. Resolve Reference Data (Brands, Categories, Units). 2. Extract Attributes. 3. Resolve Products using 1 and 2.
Let's organize the response into:
- System Architecture
- Dependency Graph (Order of Operations)
- Detailed Logic per Entity
- The Reconciliation Algorithm (Scoring)
- Storage & Output
Let's flesh out the "Attributes" part. Attributes are often unstructured text in product feeds. We need to parse "Screen Size: 15 inches" into {"key": "screen_size", "value": 15, "unit": "inches"}. This allows for unit conversion (38.1 cm) matching.
Final Polish: Ensure the distinction between Deduplication (within one source) and Record Linkage (across multiple sources) is covered by the general term "Reconciliation".
Let's write this out clearly.
Structure:
- Conceptual Model: Dependency hierarchy.
- Pre-processing: Standardization.
- Entity-Specific Strategies:
- Brands (The Parent).
- Categories (The Context).
- Attributes (The Differentiator).
- Products (The Composite).
- The Matching Engine: Blocking -> Scoring -> Clustering.
- Golden Record Rules: Conflict resolution.
- Human Review.
This looks solid. I will generate the response following this structure.
Designing an entity reconciliation (also known as Entity Resolution or Deduplication) system for e-commerce requires a hierarchical approach. You cannot reconcile products without first reconciling the entities that define them (Brands, Categories, Attributes).
Here is a comprehensive design for the system, broken down by architecture, entity-specific logic, and matching algorithms.
1. System Architecture: The "Funnel" Approach
The system should function as a pipeline. Do not attempt to reconcile everything at once; resolve the independent entities first to reduce the search space for the dependent ones.
The Hierarchy of Reconciliation:
- Reference Data (Brands, Categories): Reconcile these first. A product cannot be matched correctly if one source calls the brand "Apple" and another calls it "Apple Inc."
- Structural Data (Attributes): Normalize attribute keys (e.g., "Screen Size" vs. "Display Diagonal") to create a common schema.
- Transactional Data (Products): Use the reconciled Brand and Attribute data to match the final product SKUs.
The Pipeline Stages
- Data Standardization: Cleaning noise (HTML tags, encoding errors).
- Blocking: Grouping records into "buckets" to avoid comparing every record against every other record (O(N²) problem).
- Matching/Scoring: Comparing records within blocks using weighted rules.
- Clustering: Grouping records that scored above the threshold into a single "Golden Record" ID.
- Survivorship: Deciding which value wins (e.g., use the Price from Source A, but the Description from Source B).
2. Entity-Specific Logic
A. Brand Reconciliation
Brands are high-impact but low-volume. Errors here propagate down to products (e.g., merging "Polo" by Ralph Lauren with "Polo" a generic car part brand).
- Blocking Strategy:
- Phonetic Blocking: Group by Soundex or Metaphone (e.g., "Coca-Cola" and "Coca Cola").
- Truncation: Group by the first 3-4 letters.
- Matching Logic:
- Fuzzy String Matching: Use Jaro-Winkler distance (prioritizes prefix matches) or Levenshtein distance.
- Alias List: Maintain a manual dictionary of known mappings (e.g.,
KFC → Kentucky Fried Chicken, DJI → Da-Jiang Innovations).
- Hard Exclusion: If website domains differ (extracted from the brand name or source URL), do not match.
B. Category Reconciliation
Categories are hierarchical (e.g., Electronics > Computers > Laptops). The goal is to map source categories to a target taxonomy (like Google Taxonomy or Amazon Taxonomy).
- Blocking: Group by the "Leaf" node (the deepest category name).
- Matching Logic:
- Path Similarity: Compare the entire path string.
- Semantic Search (Embeddings): Use a transformer model (e.g., BERT or Sentence-Transformers) to vectorize the category path. Compare vectors using Cosine Similarity.
- Heuristic: If a source category maps to a target category with >90% confidence in previous runs, auto-map it.
C. Attribute Reconciliation (The "Schema" Problem)
This is the hardest part. You must map disparate keys to a canonical key and normalize values.
- Step 1: Key Normalization (The Dictionary)
- Input: "Wattage", "Power", "W", "Energy Consumption".
- Canonical Key:
power_consumption_watts.
- Technique: Synonym lookup tables or vector similarity on the key names.
- Step 2: Value Normalization (Unit Conversion)
- Extract numbers and units using Regex.
- Convert to standard unit (e.g., convert "1 kg" and "1000 g" to
1000 with unit g).
- Boolean normalization: "Yes", "True", "1", "Y" →
True.
D. Product Reconciliation
Now you match the actual items (SKUs) using the clean data from above.
- Blocking Strategy (Crucial for Performance):
- Brand Block: Only compare products that share the same (reconciled) Brand ID.
- Category Block: Only compare products within the same Category Cluster.
- Token Block: (Standard approach) Group by first 3 characters of the title.
- Matching Features:
- Identifiers: GTIN/EAN/UPC/ISBN. Note: These are often missing or incorrect.
- MPN (Manufacturer Part Number): Strong signal, but requires exact cleaning (remove hyphens/spaces).
- Image Hash: Compare product images using Perceptual Hashing (pHash). If images match, products are likely the same.
- Title Similarity: TF-IDF or Cosine Similarity on vectorized titles.
- Attribute Overlap: Jaccard similarity of the key-value attribute pairs.
3. The Reconciliation Algorithm (Scoring)
Define a weighted scoring model. If the total score exceeds a threshold (e.g., 0.85), it is a match.
Example Scoring Matrix:
| Feature | Weight | Logic |
|---|
| GTIN / UPC | 100% | Exact Match = Auto-Link. |
| MPN + Brand | 90% | Exact Match on MPN + Matched Brand ID. |
| Image pHash | 40% | Hamming distance < 10. |
| Title | 30% | Soft-TFIDF similarity > 0.8. |
| Specs/Attributes | 20% | Overlap of normalized attributes. |
| Price | 5% | Price difference < 10%. (Low weight because prices change). |
The Formula:
Score=∑(FeatureWeight×Featur
4. Workflow Implementation
Here is a sequence of events for processing a new batch of data:
Phase 1: Pre-processing
- Clean text (remove HTML, lowercase, normalize unicode).
- Extract potential identifiers (GTIN, MPN) from description or title using Regex.
Phase 2: Resolve Reference Entities
- Run Brand deduplication. Link all input products to
canonical_brand_id.
- Run Category mapping. Link all input products to
canonical_category_id.
Phase 3: Product Blocking
- Create "Blocks".
- Block A: Brand = "Nike", Category = "Shoes".
- Block B: Brand = "Sony", Category = "TVs".
- This reduces comparisons from millions to thousands.
Phase 4: Pairwise Comparison
- For every product in Block A, compare it against every other product in Block A.
- Calculate the weighted score.
- If Score > 0.95: Auto-Link.
- If 0.70 < Score < 0.95: Send to Human Review Queue.
- If Score < 0.70: Create New Entity.
Phase 5: Clustering & Golden Record
- If Product A matches Product B, and Product B matches Product C, group A, B, and C into a Cluster.
- Assign a Cluster ID (The Master ID).
- Survivorship: Create the view for the frontend.
- Title: Pick the longest, most descriptive title.
- Description: Pick the one with the best HTML formatting.
- Attributes: Union all attributes, preferring the value from the source with the highest historical accuracy.
5. Technology Stack Recommendation
- Language: Python (standard for Data Science).
- Blocking/Indexing: Splink (fast probabilistic linkage), Dedupe.io library, or Locality Sensitive Hashing (LSH) via
datasketch.
- String Similarity:
Jellyfish (for Levenshtein/Jaro-Winkler), FuzzyWuzzy.
- Vector Search (for semantic matching):
FAISS (Facebook AI Similarity Search) or Milvus for category/title embeddings.
- Database: PostgreSQL (for relational integrity) + Elasticsearch/Opensearch (for fuzzy searching and blocking).
6. Handling Edge Cases
- Variants (Color/Size): A "Blue Shirt" and a "Red Shirt" are variants, not duplicates.
- Solution: Reconcile at the "Model" level (Parent ID) first, then split by specific attribute values (Color/Size).
- Multipacks: "iPhone 12" vs "iPhone 12 (Pack of 2)".
- Solution: Regex extraction of "Pack of X" or "Count". If count differs, they are distinct entities.