Recipe NER

A compact BERT token-classification model trained from scratch on BIO-tagged English recipe ingredient lines. Its WordPiece tokenizer is trained on the same training split, so the repository is self-contained.

Entity labels

  • NAME: ingredient name
  • QTY: quantity
  • UNIT: unit of measure
  • COMMENT: preparation/state comment
  • RANGE_END: upper end of a range
  • INDEX: rare source-dataset label

The source label OTHER is normalized to the standard outside label O.

Test metrics

The split is deterministic: 39,878 train / 4,985 validation / 4,985 test examples (seed 42).

Metric Value
Entity precision 0.8715
Entity recall 0.8820
Entity F1 0.8767
Token accuracy 0.8923

Usage

from transformers import pipeline

ner = pipeline(
    "token-classification",
    model="fastyBOOM/recipe-ner",
    aggregation_strategy="simple",
)

recipe = '3 large eggs, lightly beaten'
entities = ner(recipe)
for entity in entities:
    print(entity["entity_group"], entity["word"], entity["start"], entity["end"], entity["score"])

Example produced during the final smoke test:

[
  {
    "entity_group": "QTY",
    "score": 0.997479,
    "word": "3",
    "start": 0,
    "end": 1
  },
  {
    "entity_group": "COMMENT",
    "score": 0.949855,
    "word": "large",
    "start": 2,
    "end": 7
  },
  {
    "entity_group": "NAME",
    "score": 0.937473,
    "word": "eggs",
    "start": 8,
    "end": 12
  },
  {
    "entity_group": "COMMENT",
    "score": 0.945924,
    "word": ", lightly beaten",
    "start": 12,
    "end": 28
  }
]

The model accepts raw recipe text. start and end offsets can be used to highlight each detected entity in the original input.

Reproducibility

recipe_ner_training.ipynb contains the commented workflow. The standalone train_recipe_ner.py script exposes the same parameters for command-line runs. The exact training settings and label mapping are stored in training_config.json and label_schema.json.

Limitations

The training corpus is English and mostly contains short ingredient lines. Results on Russian text, long cooking instructions, or unrelated domains are not validated. The very rare INDEX and RANGE_END classes have limited support.

Downloads last month
-
Safetensors
Model size
941k params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Space using fastyBOOM/recipe-ner 1