ingredient-list-ner
extracting food ingredients from raw OCR text
2 min readupdated
This token-classification model (word-by-word labeling) extracts ingredient lists from text scanned off food packaging via OCR (optical character recognition). Built on the distilbert-base-multilingual-cased base model (a compact multilingual transformer) and trained on Open Food Facts data, it labels each word as either part of the ingredients list or not. It is a solid fit for developers building apps that analyze food composition and flag allergens.
Key features
- Built on the 0.13B-parameter distilbert-base-multilingual-cased model
- Trained on the Open Food Facts dataset of annotated product packaging texts
- Runs word-level text classification to separate ingredient lists from unrelated packaging copy
- Hits a high 0.9894 F1 score on the test split
What you can do
- Plug the model into a text-processing pipeline for food packaging
- Automatically pull ingredient lists out of raw OCR output
- Integrate the classifier into mobile or web apps for ingredient analysis and allergen checks
Example
The model processes individual words (with punctuation separated) and classifies text chunks up to 100 words long. You can run token labeling via the Python transformers library by feeding in pre-split segments of packaging text.
Read more
DetailsMetrics across 556 test documents: Precision 0.9887, Recall 0.9901, F1 0.9894, Accuracy 0.9919.
Training: 2 epochs, learning rate 5e-5, batch size 16, trained on CPU in 77.1 minutes.
Limitations: evaluated at the individual word level; accuracy drops with heavy OCR noise or truncated text, and allergen warnings are handled separately.










Comments