Hebrew Grocery Item Classifier v2
Fine-tuned intfloat/multilingual-e5-small
for classifying Hebrew grocery shopping list items into 12 supermarket categories.
finetune code at https://github.com/davidit17/shopping_list_bot
What's new in v2
- Larger dataset — 1886 total items (1508 train / 378 test), up from ~600 in v1
- 4 training sources — manual lists, Excel grocery data, Gemini-labelled web data, and a ChatGPT-labelled set
- Synthetic augmentation — rule-based Hebrew item generator to balance under-represented categories
- Weak-class booster — extra hand-curated examples for משקאות, קפואים וסלטים, and רטבים וממרחים
- Per-class F1 tracking — evaluation now reports per-category F1 to surface weak spots
Categories
מוצרי חלב וביצים
ירקות ופירות
לחם מאפים ודגנים
חטיפים ומתוקים
ניקיון טיפוח וחד פעמי
משקאות
מוצרים לאפייה
בשר ודגים
קפואים וסלטים
יבשים
רטבים וממרחים
אחר
Usage
from transformers import pipeline
classifier = pipeline(
"text-classification",
model=f"davidit17/e5-grocery-finetuned-v2",
)
items = ["גבינה צהובה", "עגבניות שרי", "שמפו", "קוקה קולה", "חזה עוף"]
for item in items:
result = classifier(item)[0]
print(item, "→", result["label"], f"({result['score']:.2f})")
With confidence threshold (recommended)
CONFIDENCE_THRESHOLD = 0.5
def predict(text: str) -> str:
result = classifier(text)[0]
return result["label"] if result["score"] >= CONFIDENCE_THRESHOLD else "אחר"
Training
Data sources
Evaluation
Overall
Per-class F1 (fine-tuned v2)
Limitations
- Primarily covers Israeli supermarket conventions and Hebrew product naming.
- Brand-specific or very niche items may fall back to
אחר.
- Low-confidence predictions (score < 0.5) should be treated as
אחר.
- Synthetic training examples may not fully reflect natural shopping list variation.
- The
אחר category is a catch-all and may have lower precision than domain-specific categories.
🚀 ONNX Support
This repository now includes optimized ONNX versions of the model for efficient inference.
📊 CPU Performance Comparison
The repository includes the original PyTorch model as well as optimized ONNX versions for faster CPU inference.
🚀 Improvements over the PyTorch model
ONNX (FP32)
- ⚡ 2.02× lower inference latency (19.83 ms → 9.80 ms)
- 🚀 2.02× higher throughput (50.4 → 102.1 samples/sec)
- ✅ No loss in accuracy or F1 score
ONNX (INT8)
- ⚡ 2.96× lower inference latency (19.83 ms → 6.70 ms)
- 🚀 2.96× higher throughput (50.4 → 149.2 samples/sec)
- 📉 Accuracy: −4.76 percentage points
- 📉 Weighted F1: −5.73 percentage points
Recommendation
- PyTorch (
safetensors) — Best for further fine-tuning and GPU inference.
- ONNX FP32 — Recommended for CPU deployment when maintaining the original model quality is important.
- ONNX INT8 — Best for latency-critical CPU applications where a small reduction in predictive performance is acceptable in exchange for nearly 3× faster inference.
Loading the ONNX model
from optimum.onnxruntime import ORTModelForFeatureExtraction
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(
"davidit17/e5-grocery-finetuned-v2"
)
model = ORTModelForFeatureExtraction.from_pretrained(
"davidit17/e5-grocery-finetuned-v2",
subfolder="onnx",
)
model = ORTModelForFeatureExtraction.from_pretrained(
"davidit17/e5-grocery-finetuned-v2",
subfolder="onnx-int8",
)