Upload README.md with huggingface_hub
Browse files123412634895678119101314111213141516171819202122232425262728291930313233343536373839404142434421222345464748495051525354555657585960616263646566676869702671---tags:- ml-intern---# Item Weight Predictor
# ZZandro/weight-predictorA machine learning model that predicts the weight (in grams) of items based on their text description. Designed for food delivery platforms to estimate weights for:
<!-- ml-intern-provenance -->## Generated by ML Intern- **Menu items** (restaurant food portions)- **Grocery items** (packaged food from supermarkets)- **Non-food items** (household goods, electronics, toys, etc.)
This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.## Model Architecture
- Try ML Intern: https://smolagents-ml-intern.hf.space- Source code: https://github.com/huggingface/ml-internThe model uses **per-item-type Ridge regression** on TF-IDF features of text descriptions:
- Separate models trained for each item category (`menu_item`, `grocery`, `non_food`)- Log-transformed target to handle wide weight range (grams to kilograms)- TF-IDF with 1-3 gram features for robust text representation
## Performance
| Item Type | MAE | MAPE | Training Samples | Validation Samples ||------------|--------|--------|------------------|--------------------|| Grocery | 23.1g | 4.4% | 17,246 | 3,044 || Menu Item | 63.1g | 136.9% | 6,786 | 1,198 || Non-Food | 479.9g | 113.6% | 7,152 | 1,263 |
Grocery items perform best because most are standardized to ~100g servings. Menu items and non-food have higher variance but still useful for rough estimates.
## Usage
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport joblibfrom huggingface_hub import hf_hub_download
# Download and load modelmodel_path = hf_hub_download(repo_id="ZZandro/weight-predictor", filename="unified_predictor.pkl")predictor = joblib.load(model_path)
# Predict weighttext = "[MENU_ITEM] grilled chicken breast | food | meal ingredient | portion"weight_g = predictor.predict(text, item_type="menu_item")print(f"Predicted weight: {weight_g:.1f}g")```
### Supported Item Types
model_id = 'ZZandro/weight-predictor'tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained(model_id)- `menu_item` - Restaurant menu items (e.g., "cheeseburger", "caesar salad")- `grocery` - Packaged grocery products (e.g., "chocolate bar", "cereal box")- `non_food` - General retail items (e.g., "laptop", "t-shirt", "toy car")
### Text Format
Include the item type tag at the start:```[MENU_ITEM] <item description>[GROCERY] <item description>[NON_FOOD] <item description>```
## Data Sources
The training data combines:- Amazon product data with shipping weights (non-food items)- NutriBench meal descriptions with per-ingredient gram weights (menu items)- USDA Foundation Food data with standard serving sizes (grocery items)
## Dataset
The processed training dataset is available at: [ZZandro/item-weight-dataset](https://huggingface.co/datasets/ZZandro/item-weight-dataset)
## License
For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.Apache-2.0README.md+60-15