File size: 3,487 Bytes
6c350f8 cf4cb71 6c350f8 864179e cf4cb71 6c350f8 864179e 6c350f8 864179e 6c350f8 8db3b86 6c350f8 864179e 6c350f8 864179e 6c350f8 864179e 6c350f8 864179e 6c350f8 864179e 6c350f8 864179e 6c350f8 864179e 6c350f8 e4a4d74 6c350f8 e4a4d74 864179e 6c350f8 864179e 6c350f8 864179e 6c350f8 864179e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
---
library_name: transformers
tags: []
---
# Model Card for Model ID
This model is designed to identify whether two product titles (including specifications) describe the same product. The model generates a score, where a score greater than 0.5 indicates that the products are likely the same. The threshold value can be used as needed. It is based on the BERT base uncased architecture and has been fine-tuned on a custom dataset derived from real-world examples. The model performs particularly well on longer sequences.
## Model Details
### Model Description
<!-- Provide a longer summary of what this model is. -->
- **Model type:** Binary Classification
- **Language(s) (NLP):** English
- **Finetuned from model:** bert-base-uncased
## Uses
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
### Direct Use
This model can be directly used to determine if two product titles are the same. It is especially useful in e-commerce applications for deduplication, catalog matching, and product comparison.
### Out-of-Scope Use
The model is not suitable for tasks requiring deep contextual understanding beyond product titles or for comparing product descriptions that lack specification details.
## Bias, Risks, and Limitations
- **Bias**: The model may inherit biases present in the dataset, particularly related to product categories with less representation.
- **Limitations**: The model is optimized for product titles and may perform poorly on short, ambiguous titles or non-standardized names.
### Recommendations
It is recommended to use this model for products with clearly defined titles and specifications. Users should also monitor performance on specific product categories to identify and address any biases.
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
## How to Get Started with the Model
```python
import torch
from transformers import BertTokenizer
from huggingface_hub import hf_hub_download
# Step 1: Download model.py
file_path = hf_hub_download(repo_id='Berketarak/Product-Matching-Classifier', filename='model.py')
# Step 2: Add directory containing model.py to the Python path
import sys, os
model_dir = os.path.dirname(file_path)
sys.path.append(model_dir)
# Step 3: Import custom model class
from model import CustomBertModel
# Step 4: Load tokenizer and model
tokenizer = BertTokenizer.from_pretrained('Berketarak/Product-Matching-Classifier')
model = CustomBertModel.from_pretrained('Berketarak/Product-Matching-Classifier')
# Send model to GPU
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model.to(device)
# Define the products
product1 = 'X brand Pegasus Sneakers'
product2 = 'Y brand Shoes'
# Tokenize the input
inputs = tokenizer(product1, product2, padding='max_length', truncation=True, max_length=350, return_tensors='pt')
# Inference
with torch.no_grad():
input_ids = inputs['input_ids'].to(device)
attention_mask = inputs['attention_mask'].to(device)
token_type_ids = inputs['token_type_ids'].to(device)
output = model(input_ids, attention_mask, token_type_ids).item()
# Interpret the output
if output > 0.5:
print(f"The products are likely the SAME. Model output: {output}")
else:
print(f"The products are likely DIFFERENT. Model output: {output}")
|