HuggingFaceFW/finepdfs
Viewer • Updated • 476M • 59.9k • 860
How to use yusenthebot/distilbert_food_text_artifacts with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="yusenthebot/distilbert_food_text_artifacts") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("yusenthebot/distilbert_food_text_artifacts")
model = AutoModelForSequenceClassification.from_pretrained("yusenthebot/distilbert_food_text_artifacts")This model is a fine-tuned version of distilbert-base-uncased on the None dataset. It achieves the following results on the evaluation set:
This model classifies short food descriptions into semantic classes (e.g., Dish, Ingredient, Beverage).
It was fine-tuned on the augmented split and evaluated on both the test subset of augmented and the original split as an external validation set.
aedupuga/food-description-text (splits: augmented, original)The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|---|---|---|
| 0.1081 | 1.0 | 80 | 0.0947 | 0.975 | 0.9788 | 0.975 | 0.9698 |
| 0.0182 | 2.0 | 160 | 0.0139 | 1.0 | 1.0 | 1.0 | 1.0 |
| 0.0118 | 3.0 | 240 | 0.0077 | 1.0 | 1.0 | 1.0 | 1.0 |
| 0.0085 | 4.0 | 320 | 0.0059 | 1.0 | 1.0 | 1.0 | 1.0 |
| 0.0068 | 5.0 | 400 | 0.0054 | 1.0 | 1.0 | 1.0 | 1.0 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch, numpy as np
model_id = "{cfg.HUB_REPO_ID}"
tok = AutoTokenizer.from_pretrained(model_id)
mdl = AutoModelForSequenceClassification.from_pretrained(model_id)
mdl.eval()
text = "Orange juice is made by squeezing oranges."
inputs = tok(text, return_tensors="pt", truncation=True)
with torch.no_grad():
logits = mdl(**inputs).logits
probs = torch.softmax(logits, dim=-1)[0].detach().numpy()
pred = int(np.argmax(probs))
print(pred, mdl.config.id2label[pred], probs[pred])
Base model
distilbert/distilbert-base-uncased