Model Card for Food Cuisine Classification

A fine-tuned DistilBERT model for classifying food descriptions into five cuisine categories: American, Chinese, Italian, Mexican, and Thai.

Model Details

Model Description

This model is a fine-tuned version of DistilBERT-base-uncased for multi-class text classification of food descriptions. It classifies food items and dishes into one of five major cuisine categories based on textual descriptions of ingredients, preparation methods, and dish characteristics.

  • Developed by: [Your Name/Institution]
  • Model type: Text Classification (Multi-class)
  • Language(s) (NLP): English
  • License: MIT
  • Finetuned from model: distilbert-base-uncased

Model Sources

Uses

Direct Use

This model can be used to automatically classify food descriptions into cuisine categories for applications such as:

  • Restaurant menu categorization
  • Recipe recommendation systems
  • Food delivery app organization
  • Culinary analysis and research
  • Educational tools for learning about different cuisines

Downstream Use

The model could be fine-tuned further for:

  • More granular cuisine classification (regional subcategories)
  • Restaurant review sentiment analysis by cuisine type
  • Dietary restriction classification
  • Recipe difficulty assessment

Out-of-Scope Use

This model should not be used for:

  • Medical or nutritional advice
  • Allergen detection or safety assessments
  • Cultural sensitivity or authenticity judgments
  • Commercial food safety compliance
  • Classification of cuisines not represented in the training data

Bias, Risks, and Limitations

Dataset Limitations:

  • Trained on a relatively small dataset of food descriptions
  • May not represent the full diversity within each cuisine category
  • Potential bias toward Western interpretations of international cuisines
  • Limited representation of fusion cuisines or modern interpretations

Model Limitations:

  • Performance may degrade on food descriptions significantly different from training data
  • May struggle with fusion dishes that combine elements from multiple cuisines
  • Limited to five broad cuisine categories
  • Dependent on text quality and descriptiveness

Cultural Considerations:

  • Cuisine classification can be culturally sensitive and subjective
  • Model may reflect biases present in the training data
  • Regional variations within cuisines are not captured

Recommendations

Users should be aware of the model's limitations and validate outputs, especially for applications involving cultural representation. The model should be used as a tool to assist human judgment rather than replace it in sensitive contexts.

How to Get Started with the Model

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

# Load model and tokenizer
model_name = "maryzhang/24679-text-distilbert-food-cuisine-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

# Example prediction
text = "Spicy red curry with coconut milk and basil served with rice"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)

with torch.no_grad():
    outputs = model(**inputs)
    predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
    predicted_class = torch.argmax(predictions, dim=-1)

# Get cuisine prediction
cuisines = ["American", "Chinese", "Italian", "Mexican", "Thai"]
predicted_cuisine = cuisines[predicted_class.item()]
confidence = predictions[0][predicted_class].item()

print(f"Predicted cuisine: {predicted_cuisine} (confidence: {confidence:.3f})")

Training Details

Training Data

The model was trained on the scottymcgee/food-text-dataset, which contains food descriptions for five cuisine categories:

  • Total samples: ~1,100 food descriptions
  • Cuisines: American, Chinese, Italian, Mexican, Thai
  • Description length: ~150-200 characters per sample
  • Data augmentation: Synthetic examples generated using synonym replacement and paraphrasing

Training Procedure

Preprocessing

  • Text tokenization using DistilBERT tokenizer
  • Maximum sequence length: 256 tokens
  • Label encoding: String labels converted to numeric IDs (0-4)

Training Hyperparameters

  • Training regime: Mixed precision (automatic)
  • Learning rate: 2e-5
  • Batch size: 16 (train and eval)
  • Number of epochs: 3
  • Weight decay: 0.01
  • Optimizer: AdamW
  • Learning rate scheduler: Linear decay
  • Evaluation strategy: Every epoch
  • Early stopping: Best model based on accuracy

Speeds, Sizes, Times

  • Training time: ~10-15 minutes on GPU
  • Model size: ~67M parameters (DistilBERT-base)
  • Inference speed: ~50-100 samples/second on GPU

Evaluation

Testing Data, Factors & Metrics

Testing Data

The model was evaluated on a held-out test set (15% of total data) containing food descriptions across all five cuisine categories, maintaining stratified distribution.

Factors

Evaluation was conducted across:

  • All five cuisine categories
  • Various description lengths and styles
  • Different food types (appetizers, mains, desserts, etc.)

Metrics

Primary metrics used for evaluation:

  • Accuracy: Overall classification accuracy
  • F1-Score: Weighted and macro-averaged F1-scores
  • Precision/Recall: Per-class and averaged metrics
  • Confusion Matrix: Cross-cuisine classification patterns

Results

Test Set Performance:

  • Accuracy: [Update with your actual results]
  • Weighted F1: [Update with your actual results]
  • Macro F1: [Update with your actual results]

Per-Class Performance:

Cuisine Precision Recall F1-Score Support
American [Update] [Update] [Update] [Update]
Chinese [Update] [Update] [Update] [Update]
Italian [Update] [Update] [Update] [Update]
Mexican [Update] [Update] [Update] [Update]
Thai [Update] [Update] [Update] [Update]

Summary

The model demonstrates strong performance in distinguishing between the five cuisine categories, with particular strength in identifying dishes with distinctive ingredients and preparation methods. Common confusions occur between cuisines with overlapping ingredients or cooking techniques.

Environmental Impact

Training was conducted efficiently using a fine-tuning approach with a pre-trained model, minimizing computational requirements.

  • Hardware Type: GPU (CUDA-enabled)
  • Hours used: ~0.25 hours
  • Cloud Provider: Google Colab
  • Compute Region: US
  • Carbon Emitted: Minimal due to short training duration and efficient fine-tuning approach

Technical Specifications

Model Architecture and Objective

  • Base Architecture: DistilBERT (6-layer transformer)
  • Task: Multi-class text classification
  • Objective: Cross-entropy loss for 5-class classification
  • Output: Probability distribution over 5 cuisine categories
  • Fine-tuning: Task-specific classification head added

Compute Infrastructure

Hardware

  • Training: GPU-accelerated (CUDA compatible)
  • Memory: Standard Google Colab GPU memory
  • Inference: Compatible with both CPU and GPU

Software

  • Framework: Transformers (Hugging Face)
  • Deep Learning: PyTorch
  • Python: 3.7+
  • Key Dependencies: transformers, torch, datasets, scikit-learn

Citation

BibTeX:

@misc{food_cuisine_classifier_2024,
  title={Fine-tuned DistilBERT for Food Cuisine Classification},
  author={[Your Name]},
  year={2024},
  url={https://huggingface.co/maryzhang/24679-text-distilbert-food-cuisine-classifier}
}

Dataset Citation:

@dataset{scottymcgee_food_dataset_2024,
  title={Food Text Dataset},
  author={Scotty McGee},
  year={2024},
  url={https://huggingface.co/datasets/scottymcgee/food-text-dataset}
}

More Information

This model was developed as part of an educational assignment exploring fine-tuning techniques for text classification. It demonstrates the application of transfer learning from general language understanding to domain-specific classification tasks.

The model serves as an example of practical NLP applications in the food and hospitality industry, showcasing how transformer models can be adapted for specialized classification tasks with relatively small domain-specific datasets.

Model Card Authors

Mary Zhang

Model Card Contact

[email protected]

AI Usage

Claude used to edit functions and debug code

Downloads last month
4
Safetensors
Model size
67M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train maryzhang/24679-text-distilbert-food-cuisine-classifier