Downloads · 30 days
333
0% of all-time downloads
Dizex/InstaFoodRoBERTa-NER
InstaFoodRoBERTa-NER is a token classification model from Dizex. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as mit.
InstaFoodRoBERTa-NER is a fine-tuned BERT model that is ready to use for Named Entity Recognition of Food entities on social media like informal text (e.g. Instagram, X, Reddit). It has been trained to recognize a sin…
Downloads · 30 days
333
0% of all-time downloads
All-time downloads
219K
Public
Parameters
124M
2 GB on disk
Likes
13
Public
Click a slice to open those files.
.bin496 MB · 50%
How the weights are stored.
F32124M · 100%
From the Hugging Face model README
InstaFoodRoBERTa-NER is a fine-tuned BERT model that is ready to use for Named Entity Recognition of Food entities on social media like informal text (e.g. Instagram, X, Reddit). It has been trained to recognize a single entity: food (FOOD).
Specifically, this model is a roberta-base model that was fine-tuned on a dataset consisting of 400 English Instagram posts related to food. The dataset is open source.
You can use this model with Transformers pipeline for NER.
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("Dizex/InstaFoodRoBERTa-NER")
model = AutoModelForTokenClassification.from_pretrained("Dizex/InstaFoodRoBERTa-NER")
pipe = pipeline("ner", model=model, tokenizer=tokenizer)
example = "Today's meal: Fresh olive poké bowl topped with chia seeds. Very delicious!"
ner_entity_results = pipe(example, aggregation_strategy="simple")
print(ner_entity_results)
To get the extracted food entities as strings you can use the following code:
def convert_entities_to_list(text, entities: list[dict]) -> list[str]:
ents = []
for ent in entities:
e = {"start": ent["start"], "end": ent["end"], "label": ent["entity_group"]}
if ents and -1 <= ent["start"] - ents[-1]["end"] <= 1 and ents[-1]["label"] == e["label"]:
ents[-1]["end"] = e["end"]
continue
ents.append(e)
return [text[e["start"]:e["end"]] for e in ents]
print(convert_entities_to_list(example, ner_entity_results))
This will result in the following output:
['olive poké bowl', 'chia seeds']
| metric | val |
|---|---|
| f1 | 0.91 |
| precision | 0.89 |
| recall | 0.93 |