CoolFace
Apppublic

xxiaomeng/siamese-match

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

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

bash
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