ZZandro commited on
Commit
6167c5c
·
verified ·
1 Parent(s): d2ebf23

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +60 -15
README.md CHANGED
@@ -1,26 +1,71 @@
1
- ---
2
- tags:
3
- - ml-intern
4
- ---
5
 
6
- # ZZandro/weight-predictor
7
 
8
- <!-- ml-intern-provenance -->
9
- ## Generated by ML Intern
 
10
 
11
- 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.
12
 
13
- - Try ML Intern: https://smolagents-ml-intern.hf.space
14
- - Source code: https://github.com/huggingface/ml-intern
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  ## Usage
17
 
18
  ```python
19
- from transformers import AutoModelForCausalLM, AutoTokenizer
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- model_id = 'ZZandro/weight-predictor'
22
- tokenizer = AutoTokenizer.from_pretrained(model_id)
23
- model = AutoModelForCausalLM.from_pretrained(model_id)
 
 
 
 
24
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.
 
1
+ # Item Weight Predictor
 
 
 
2
 
3
+ A 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:
4
 
5
+ - **Menu items** (restaurant food portions)
6
+ - **Grocery items** (packaged food from supermarkets)
7
+ - **Non-food items** (household goods, electronics, toys, etc.)
8
 
9
+ ## Model Architecture
10
 
11
+ The model uses **per-item-type Ridge regression** on TF-IDF features of text descriptions:
12
+
13
+ - Separate models trained for each item category (`menu_item`, `grocery`, `non_food`)
14
+ - Log-transformed target to handle wide weight range (grams to kilograms)
15
+ - TF-IDF with 1-3 gram features for robust text representation
16
+
17
+ ## Performance
18
+
19
+ | Item Type | MAE | MAPE | Training Samples | Validation Samples |
20
+ |------------|--------|--------|------------------|--------------------|
21
+ | Grocery | 23.1g | 4.4% | 17,246 | 3,044 |
22
+ | Menu Item | 63.1g | 136.9% | 6,786 | 1,198 |
23
+ | Non-Food | 479.9g | 113.6% | 7,152 | 1,263 |
24
+
25
+ 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.
26
 
27
  ## Usage
28
 
29
  ```python
30
+ import joblib
31
+ from huggingface_hub import hf_hub_download
32
+
33
+ # Download and load model
34
+ model_path = hf_hub_download(repo_id="ZZandro/weight-predictor", filename="unified_predictor.pkl")
35
+ predictor = joblib.load(model_path)
36
+
37
+ # Predict weight
38
+ text = "[MENU_ITEM] grilled chicken breast | food | meal ingredient | portion"
39
+ weight_g = predictor.predict(text, item_type="menu_item")
40
+ print(f"Predicted weight: {weight_g:.1f}g")
41
+ ```
42
+
43
+ ### Supported Item Types
44
 
45
+ - `menu_item` - Restaurant menu items (e.g., "cheeseburger", "caesar salad")
46
+ - `grocery` - Packaged grocery products (e.g., "chocolate bar", "cereal box")
47
+ - `non_food` - General retail items (e.g., "laptop", "t-shirt", "toy car")
48
+
49
+ ### Text Format
50
+
51
+ Include the item type tag at the start:
52
  ```
53
+ [MENU_ITEM] <item description>
54
+ [GROCERY] <item description>
55
+ [NON_FOOD] <item description>
56
+ ```
57
+
58
+ ## Data Sources
59
+
60
+ The training data combines:
61
+ - Amazon product data with shipping weights (non-food items)
62
+ - NutriBench meal descriptions with per-ingredient gram weights (menu items)
63
+ - USDA Foundation Food data with standard serving sizes (grocery items)
64
+
65
+ ## Dataset
66
+
67
+ The processed training dataset is available at: [ZZandro/item-weight-dataset](https://huggingface.co/datasets/ZZandro/item-weight-dataset)
68
+
69
+ ## License
70
 
71
+ Apache-2.0