This model is a fine-tuned version of distilbert/distilbert-base-uncased designed to classify text into two categories: Food or Not Food.
It achieves excellent performance on the evaluation set, making it highly effective for filtering, content moderation, or categorization tasks related to culinary text.
Model Description
Model type: Transformer-based text classifier (DistilBERT)
Language(s): English
License: Apache 2.0
Finetuned from model:distilbert-base-uncased
This model was trained to analyze short texts, sentences, or paragraphs and determine whether the primary subject matter is related to food/cooking or something else entirely. By leveraging DistilBERT, it remains lightweight and fast while maintaining high accuracy.
Intended Uses & Limitations
Intended Uses:
Content Filtering: Automatically tagging or filtering user-generated content in recipe apps or forums.
Diet/Nutrition Apps: Classifying user inputs to determine if they are logging a food item.
Data Organization: Sorting mixed datasets into food-related and non-food-related piles.
Limitations:
The model may occasionally struggle with metaphors or idioms (e.g., "It was a piece of cake" might be misclassified as Food).
It is optimized for English text. Performance on non-English text is not guaranteed.
Training and Evaluation Data
The model was fine-tuned on a custom dataset consisting of 250 short descriptive texts and image captions. The dataset is perfectly balanced, containing 125 food descriptions (e.g., "Creamy cauliflower curry with garlic naan...") and 125 not_food descriptions (e.g., "A yellow tractor driving over the hill").
Data Splits:
Train: 200 examples
Test/Evaluation: 50 examples
How to Use
You can easily use this model in your own Python projects using the Hugging Face pipeline:
python
1from transformers import pipeline
23# Load the classifier4classifier = pipeline("text-classification", model="suhailaelbehairy/learn_hf_food_not_food_text_classifier-distilbert-base-uncased")56# Test it out!7result = classifier("I had a delicious slice of pepperoni pizza for dinner.")8print(result)9# Expected output: [{'label': 'FOOD', 'score': 0.99}]
Training hyperparameters
The following hyperparameters were used during training:
learning_rate: 0.0001
train_batch_size: 32
eval_batch_size: 32
seed: 42
optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments