File size: 2,153 Bytes
eab6132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
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
```