Downloads · 30 days
118
100% of all-time downloads
fastyBOOM/recipe-ner
recipe-ner is a token classification model from fastyBOOM. Use it when you need labels on individual words, such as names. It is set up for transformers.
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.
Downloads · 30 days
118
100% of all-time downloads
All-time downloads
118
Public
Parameters
941K
3.8 MB on disk
Likes
5
Public
Click a slice to open those files.
.safetensors3.8 MB · 96%
From the Hugging Face model README
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.
NAME: ingredient nameQTY: quantityUNIT: unit of measureCOMMENT: preparation/state commentRANGE_END: upper end of a rangeINDEX: rare source-dataset labelThe source label OTHER is normalized to the standard outside label O.
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 |
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.
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.
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.