|
--- |
|
language: en |
|
tags: |
|
- bge |
|
- food |
|
- reranking |
|
- sequence-classification |
|
- sentence-similarity |
|
library_name: transformers |
|
pipeline_tag: text-classification |
|
license: mit |
|
--- |
|
|
|
# Food Re-ranker Model |
|
|
|
This is a fine-tuned BGE (BAAI General Embedding) model trained for binary classification of food description pairs. The model determines whether two food descriptions refer to the same item, enabling accurate re-ranking of search results. |
|
|
|
## Model Details |
|
|
|
### Model Description |
|
- **Base Model**: BAAI/bge-base-en-v1.5 |
|
- **Model Type**: bert |
|
- **Task**: Binary classification (food description matching) |
|
- **Output**: Binary classification scores (0 = different foods, 1 = same food) |
|
|
|
### Architecture |
|
The model uses the BGE architecture with the following specifications: |
|
- **Hidden Size**: 768 |
|
- **Number of Layers**: 12 |
|
- **Number of Attention Heads**: 12 |
|
- **Intermediate Size**: 3072 |
|
- **Maximum Position Embeddings**: 512 |
|
- **Vocabulary Size**: 30522 |
|
- **Hidden Act**: gelu |
|
|
|
### Performance Metrics |
|
Key evaluation metrics on the test set: |
|
|
|
|
|
## Use Case |
|
|
|
Designed for improving food search accuracy by re-ranking initial search results, this model: |
|
- Takes pairs of food descriptions as input |
|
- Determines if they refer to the same food item |
|
- Enables more accurate matching of food descriptions |
|
- Helps surface the most relevant matches in search results |
|
|
|
## Training Configuration |
|
- **Batch Size**: 32 |
|
- **Learning Rate**: 2e-05 |
|
- **Number of Epochs**: 10 |
|
- **Warmup Steps**: 0 |
|
- **Weight Decay**: 0.01 |
|
- **Dropout**: 0.1 |
|
- **Attention Dropout**: 0.1 |
|
- **Layer Norm Eps**: 1e-12 |
|
|
|
## Example Usage |
|
|
|
```python |
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification |
|
|
|
# Load model |
|
tokenizer = AutoTokenizer.from_pretrained("jonny9f/food_reranker2") |
|
model = AutoModelForSequenceClassification.from_pretrained("jonny9f/food_reranker2") |
|
|
|
# Prepare input |
|
query = "chicken breast" |
|
candidate = "grilled chicken breast" |
|
inputs = tokenizer(query, candidate, padding=True, truncation=True, return_tensors="pt") |
|
|
|
# Get prediction |
|
outputs = model(**inputs) |
|
score = outputs.logits.softmax(dim=1)[0][1].item() # Score for positive class |
|
``` |
|
|