Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
(2): Normalize()
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2import util # Optional for cosine_sim if not using model.similarity
3
4# 1. Load the model
5model = SentenceTransformer("surazbhandari/all-MiniLM-L6-v2-ProductMatching")
6
7# 2. Define product pairs
8product_a = "Apple iPhone 15 Pro Max 256GB Titanium"
9product_b = "iPhone 15 Pro Max - Blue Titanium - 256 GB"
10unrelated_product = "Logitech MX Master 3S Wireless Mouse"
11
12# 3. Encode product titles
13embeddings = model.encode([product_a, product_b, unrelated_product])
14
15# 4. Calculate Cosine Similarity
16similarity_score = model.similarity(embeddings[0], embeddings[1])
17print(f"Similarity (Product A & B): {similarity_score.item():.4f}")
18# Expected: ~0.60 (Strong match for varied titles)
19
20diff_similarity = model.similarity(embeddings[0], embeddings[2])
21print(f"Similarity (Unrelated): {diff_similarity.item():.4f}")
22# Expected: < 0.10 (Clear distinction)all-MiniLM-L6-v2 model across various product matching scenarios.| Scenario | Type | Fine-Tuned (This Model) | Base Model | Decision |
|---|---|---|---|---|
| iPhone 15 Pro Max 256GB vs Var. Title | Match | 0.6088 | 0.9077 | Base Higher |
| Logitech MX Master 3S vs Var. Title | Match | 0.8250 | 0.9374 | Base Higher |
| Galaxy S23 Ultra vs Var. Title | Match | 0.8725 | 0.7825 | ✅ FT Higher |
| Sony XM5 vs Sony XM4 | Hard Negative | 0.6404 | 0.7573 | ✅ FT Lower (Better) |
| MacBook Pro 14 vs MacBook Pro 16 | Hard Negative | 0.9293 | 0.8965 | Base Lower |
| Nike vs Adidas (Running Shoes) | Similar Category | 0.5643 | 0.7720 | ✅ FT Lower (Better) |
| Stand Mixer vs Printer | Random Negative | -0.0814 | 0.0533 | ✅ FT Lower (Better) |
all-MiniLM-L6-v2 architecture, maintaining fast inference speeds while significantly improving domain-specific accuracy.