xxiaomeng/siamese-match
0
title: Siamese Match emoji: π€ colorFrom: blue colorTo: red sdk: docker pinned: true ---
𧬠Siamese MLP β Identity Matching via Deep Learning
This project implements a Siamese neural network for structured identity matching, inspired by real-world use cases like adtech identity resolution (e.g., data ingestion and linkage).
Built with:
- β PyTorch (custom Siamese MLP model)
- β Scikit-learn (OneHotEncoder)
- β FastAPI (inference API)
- β MLflow + Weights & Biases (training trace)
- β Docker & Docker Compose
- β Optional: Hugging Face Spaces deployment
π Quick Start (Docker)
π§ 1. Build and Run
make build # build Docker image
make up # start FastAPI + MLflow
API available at: http://localhost:8000/docs
MLflow UI: http://localhost:5001
make test-api
payload exampleοΌ
{
"a": {"browser": "Chrome", "country": "US"},
"b": {"browser": "Safari", "country": "US"}
}
π§ Model Architecture
UserA ----> Encoder -----\
\
---> Comparator --> [0,1] match score
/
UserB ----> Encoder -----/
β’ Encoder: 2-layer MLP with ReLU, BatchNorm, Dropout
β’ Comparator: Takes concat of [x1, x2, |x1-x2|, x1*x2]
π§ͺ MLflow & W&B Tracking
make train
Cleanup
make down # stop containers
make clean # delete checkpoints, mlruns
π Project Structure
βββ app/
β βββ serve.py # FastAPI app
β βββ models/
β βββ siamese_mlp.py
βββ train.py # PyTorch training script
βββ data/user_pairs.csv # Training data
βββ checkpoints/ # Saved model + encoder
βββ mlruns/ # MLflow logs
βββ requirements.txt
βββ Dockerfile
βββ docker-compose.yml
βββ Makefile
βββ README.md