Text Classification
Transformers
Safetensors
English
distilbert
food
reranking
sequence-classification
text-embeddings-inference
Instructions to use jonny9f/food_reranker2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jonny9f/food_reranker2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="jonny9f/food_reranker2")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("jonny9f/food_reranker2") model = AutoModelForSequenceClassification.from_pretrained("jonny9f/food_reranker2") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -5,7 +5,6 @@ tags:
|
|
| 5 |
- food
|
| 6 |
- reranking
|
| 7 |
- sequence-classification
|
| 8 |
-
- text-classification
|
| 9 |
library_name: transformers
|
| 10 |
pipeline_tag: text-classification
|
| 11 |
license: mit
|
|
@@ -13,25 +12,41 @@ license: mit
|
|
| 13 |
|
| 14 |
# Food Re-ranker Model
|
| 15 |
|
| 16 |
-
This is a fine-tuned DistilBERT model trained for
|
| 17 |
|
| 18 |
-
## Model
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- **
|
| 22 |
-
- **
|
|
|
|
| 23 |
- **Output**: Binary classification scores (0 = different foods, 1 = same food)
|
| 24 |
|
| 25 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
-
|
| 33 |
-
-
|
| 34 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Example Usage
|
| 37 |
|
|
@@ -50,3 +65,4 @@ inputs = tokenizer(query, candidate, padding=True, truncation=True, return_tenso
|
|
| 50 |
# Get prediction
|
| 51 |
outputs = model(**inputs)
|
| 52 |
score = outputs.logits.softmax(dim=1)[0][1].item() # Score for positive class
|
|
|
|
|
|
| 5 |
- food
|
| 6 |
- reranking
|
| 7 |
- sequence-classification
|
|
|
|
| 8 |
library_name: transformers
|
| 9 |
pipeline_tag: text-classification
|
| 10 |
license: mit
|
|
|
|
| 12 |
|
| 13 |
# Food Re-ranker Model
|
| 14 |
|
| 15 |
+
This is a fine-tuned DistilBERT 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.
|
| 16 |
|
| 17 |
+
## Model Details
|
| 18 |
|
| 19 |
+
### Model Description
|
| 20 |
+
- **Base Model**: distilbert-base-uncased
|
| 21 |
+
- **Model Type**: distilbert
|
| 22 |
+
- **Task**: Binary classification (food description matching)
|
| 23 |
- **Output**: Binary classification scores (0 = different foods, 1 = same food)
|
| 24 |
|
| 25 |
+
### Architecture
|
| 26 |
+
- **Hidden Dimension**: 768
|
| 27 |
+
- **Number of Layers**: 6
|
| 28 |
+
- **Number of Attention Heads**: 12
|
| 29 |
+
- **Intermediate Size**: 3072
|
| 30 |
+
- **Maximum Position Embeddings**: 512
|
| 31 |
+
- **Vocabulary Size**: 30522
|
| 32 |
|
| 33 |
+
## Use Case
|
| 34 |
|
| 35 |
+
Designed for improving food search accuracy by re-ranking initial search results, this model:
|
| 36 |
+
- Takes pairs of food descriptions as input
|
| 37 |
+
- Determines if they refer to the same food item
|
| 38 |
+
- Enables more accurate matching of food descriptions
|
| 39 |
+
- Helps surface the most relevant matches in search results
|
| 40 |
|
| 41 |
+
## Training Configuration
|
| 42 |
+
- **Batch Size**: 32
|
| 43 |
+
- **Learning Rate**: 5e-05
|
| 44 |
+
- **Number of Epochs**: 3
|
| 45 |
+
- **Warmup Steps**: 0
|
| 46 |
+
- **Weight Decay**: 0.0
|
| 47 |
+
- **Dropout**: 0.1
|
| 48 |
+
- **Attention Dropout**: 0.1
|
| 49 |
+
- **Classification Dropout**: 0.2
|
| 50 |
|
| 51 |
## Example Usage
|
| 52 |
|
|
|
|
| 65 |
# Get prediction
|
| 66 |
outputs = model(**inputs)
|
| 67 |
score = outputs.logits.softmax(dim=1)[0][1].item() # Score for positive class
|
| 68 |
+
```
|