ktiyab commited on
Commit
09d1ca8
·
verified ·
1 Parent(s): 9ffde3e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +223 -1
README.md CHANGED
@@ -4,4 +4,226 @@ language:
4
  - en
5
  base_model:
6
  - google/gemma-2-2b
7
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  - en
5
  base_model:
6
  - google/gemma-2-2b
7
+ ---
8
+
9
+ # Model Summary
10
+
11
+ **Model Name**: `sustainable-fashion-gemma2-2b-202501080`
12
+ **Model Description**: This model is a **specialized** variant of the Gemma-2 2B, fine-tuned to consistently deliver **robust sustainable fashion advice**, practical **capsule wardrobe** guidance, and **timeless styling** recommendations. By integrating **LoRA** techniques, the model efficiently captures **nuanced, real-world** fashion insights without sacrificing inference performance.
13
+
14
+ ### Core Criteria
15
+
16
+ 1. **Conciseness & Directness**
17
+ - Offers clear, actionable fashion tips without unnecessary complexity.
18
+
19
+ 2. **Personalization**
20
+ - Tailors advice to individual budgets, lifestyles, and style preferences.
21
+
22
+ 3. **Integration of Concepts**
23
+ - Connects sustainability principles, budget constraints, and style guidelines into a unified approach.
24
+
25
+ 4. **Tone & Accessibility**
26
+ - Maintains a friendly, approachable voice—ideal for newcomers and seasoned eco-conscious dressers alike.
27
+
28
+ 5. **Strategic Focus**
29
+ - Emphasizes long-term wardrobe value, cost-benefit analyses, and ecological impact in every recommendation.
30
+
31
+ 6. **Practical Reality**
32
+ - Balances high-quality investments with realistic budgeting, mixing accessible pieces with sustainable choices.
33
+
34
+ ### Architecture & Training Highlights
35
+ - **Base Model**: Gemma-2 2B parameters
36
+ - **Fine-Tuning Method**: LoRA-based instruct tuning (`--task=instruct-lora`)
37
+ - **Epochs**: 5
38
+ - **Learning Rate**: 0.0002, using a cosine scheduler
39
+ - **Optimizer**: `paged_adamw_32bit`
40
+ - **Attention Implementation**: `flash_attention_2`, improving speed and memory usage
41
+ - **Precision**: 4-bit quantization for memory efficiency (`--precision_mode=4bit`)
42
+ - **Training Data**: Synthetic Q&A pairs on sustainable and timeless fashion (see [https://www.kaggle.com/datasets/tiyabk/sustainable-fashion/data](#data-overview))
43
+
44
+ ### Primary Use
45
+ The model excels at answering sustainable and timelesse fashion questions on:
46
+
47
+ **Eco-friendly fabrics**
48
+ - Fabric Recommendations: Users inquire about the best sustainable materials (e.g., organic cotton, linen, hemp, Tencel) for different climates or occasions.
49
+ - Material Care Guidance: Advice on proper care (washing, drying, storing) to extend the life of garments made with eco-friendly fabrics.
50
+
51
+ **Capsule wardrobe construction**
52
+ - Core Wardrobe Planning: Helps users identify essential clothing items that suit their lifestyle (e.g., a few versatile tops, bottom pieces, layering pieces).
53
+ - Minimalist Shopping Lists: Suggests how many items to include in each category (tops, pants, outerwear, etc.) to maintain both variety and wearability.
54
+ - Seasonal Transitions: Guides on switching out certain pieces for seasonal changes while keeping the majority of items year-round.
55
+
56
+ **Climate-specific styling**
57
+ - Weather-Appropriate Outfits: Users input local climate details (hot and humid vs. cold and dry), and the model advises on layering, fabric weights, and silhouettes.
58
+ - Travel Packing Assistance: For trips to different climates, the model helps curate a light but versatile wardrobe that can handle temperature and weather variations.
59
+ - Regional Seasonality: Accounts for monsoon seasons, harsh winters, or desert climates when recommending outfit structures, color choices, and fabric blends.
60
+
61
+ **Timeless color palettes and silhouettes**
62
+ - Color Palette Selection: Helps users identify a cohesive range of neutrals, accent colors, and core hues that - suit their skin tone and personal style.
63
+ - Long-Lasting Trends: Suggests classic cuts (e.g., A-line skirts, tailored trousers, button-up shirts) that transcend seasonal fads.
64
+ - Personalization: Balances timelessness with individual flair (e.g., a signature color or pattern) without sacrificing longevity.
65
+
66
+ ### Evaluation
67
+ The model was evaluated on an internal validation set using built-in metrics (e.g., loss). The model has demonstrated robust understanding and consistent instruction-following behavior for fashion-related queries.
68
+
69
+ ---
70
+
71
+ ## Usage
72
+
73
+ Below is a minimal code snippet showing how to load and use the model for inference. This example assumes the merged model is available in a storage bucket or local path.
74
+
75
+ ```bash
76
+ !pip install transformers accelerate huggingface_hub
77
+ ```
78
+
79
+ ```python
80
+ import torch
81
+ from transformers import AutoTokenizer, AutoModelForCausalLM
82
+ from huggingface_hub import notebook_login
83
+
84
+ # If your model is private, uncomment:
85
+ # notebook_login()
86
+
87
+ # 1) Set up the device
88
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
89
+
90
+ # 2) Load tokenizer & model from Hugging Face
91
+ model_path = "YourUsername/my-awesome-finetuned-model"
92
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
93
+ model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16)
94
+ model.to(device)
95
+
96
+ # 3) Define your generation functions
97
+ def ask_fashion_model_short_response(question):
98
+ inputs = tokenizer(question, return_tensors="pt").to(device)
99
+ with torch.no_grad():
100
+ outputs = model.generate(
101
+ **inputs,
102
+ max_new_tokens=200,
103
+ do_sample=True,
104
+ temperature=0.7,
105
+ top_k=50,
106
+ top_p=0.9,
107
+ repetition_penalty=1.2,
108
+ num_beams=1
109
+ )
110
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
111
+
112
+ def ask_fashion_model_long_response(question):
113
+ inputs = tokenizer(question, return_tensors="pt").to(device)
114
+ with torch.no_grad():
115
+ outputs = model.generate(
116
+ **inputs,
117
+ max_new_tokens=512,
118
+ num_beams=2,
119
+ length_penalty=1.8,
120
+ temperature=1,
121
+ top_k=50,
122
+ top_p=1,
123
+ do_sample=False
124
+ )
125
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
126
+
127
+ # 4) Example usage
128
+ query = "What are some timeless ways to incorporate color into my wardrobe if I usually stick to neutral shades?"
129
+ response = ask_fashion_model_long_response(query)
130
+ print(response)```
131
+
132
+ ### Input / Output Shape
133
+ - **Input**: A user prompt or query in natural language (e.g., “How do I choose the right colors for my skin tone?”).
134
+ - **Output**: A single, text-based answer or instruction.
135
+
136
+ ### Known and Preventable Failures
137
+ - **Ambiguous Requests**: Vague queries may yield broad responses. Encourage users to provide context.
138
+ - **Non-Fashion Queries**: The model is specialized for sustainable fashion tasks and might produce less accurate or irrelevant answers for unrelated domains.
139
+
140
+ ---
141
+
142
+ ## System
143
+
144
+ This model can be used as a **standalone** text-generation system or integrated into broader chat/assistant pipelines:
145
+ - **Input Requirements**: A plain text prompt describing a fashion or styling question.
146
+ - **Downstream Dependencies**: Any application expecting textual recommendations (e.g., e-commerce chatbots, personal stylist apps, content generation tools).
147
+
148
+ The model’s text output could feed into:
149
+ - **E-commerce**: Product recommendations for sustainability suggestions.
150
+ - **Editorial/Content**: Generating blog articles or social media posts on sustainability fashion topics.
151
+
152
+ ---
153
+
154
+ ## Implementation Requirements
155
+
156
+ - **Training Hardware**:
157
+ - **Machine Type**: `a2-ultragpu-8g` with 8 NVIDIA A100 80GB GPUs
158
+ - **Disk**: 500 GB SSD (`pd-ssd`)
159
+ - **Replica Count**: 1 (single worker)
160
+
161
+ - **Software**:
162
+ - Container image: `us-docker.pkg.dev/vertex-ai-restricted/vertex-vision-model-garden-dockers/pytorch-peft-train:stable_20240909`
163
+ - Key packages: PyTorch, Transformers, Deepspeed (Zero 2 config), LoRA libraries
164
+
165
+ - **Compute Requirements**:
166
+ Training with 8 GPUs over 5 epochs on a dataset of fashion Q&A pairs. Time to convergence depends on final dataset size and batch configuration (`per_device_train_batch_size=1` with gradient accumulation steps).
167
+
168
+ - **Performance & Energy Consumption**:
169
+ The usage of flash attention and 4-bit precision helps reduce memory usage and training costs. No exact energy consumption metrics are published, but overhead is significantly reduced compared to full FP16 or FP32 training.
170
+
171
+ ---
172
+
173
+ # Model Characteristics
174
+
175
+ ## Model Initialization
176
+
177
+ The model was **fine-tuned** from a pre-trained Gemma-2 2B parameter LLM. It was **not** trained from scratch.
178
+
179
+ ## Model Stats
180
+
181
+ - **Parameter Count**: ~2B base parameters, plus LoRA adapters
182
+ - **Model Size (disk)**: ~5GB
183
+ - **Layers**: The base Gemma-2 architecture with multi-headed self-attention and transformer blocks.
184
+ - **Latency**: Inference latency depends on GPU/CPU hardware. On a single GPU, the flash attention significantly speeds up token generation compared to naive implementations.
185
+
186
+ ## Other Details
187
+
188
+ - **Pruning**: Not applied.
189
+ - **Quantization**: 4-bit quantization used for training to reduce memory footprint.
190
+ - **Differential Privacy**: No specialized techniques implemented; the dataset is synthetic with no direct PII.
191
+
192
+ ---
193
+
194
+ # Data Overview
195
+
196
+ ## Training Data
197
+
198
+ **Source**: A synthetic collection of 38K lines Q&A pairs about sustainable fashion, generated via advanced prompt engineering to cover:
199
+ - **Sustainable practices** (e.g., recycled materials, secondhand shopping)
200
+ - **Wardrobe fundamentals** (e.g., neutral color palettes, timeless silhouettes)
201
+ - **Climate-specific styling**
202
+ - **Budget constraints**
203
+ ...
204
+
205
+ **Pre-processing**: Minimal text cleaning (e.g., removing extraneous symbols), focusing on clarity and consistency.
206
+
207
+ ## Demographic Groups
208
+
209
+ The data does not explicitly classify demographics. Rather, it addresses general styling contexts (body changes, climate differences, budget considerations) that can be relevant across diverse populations.
210
+
211
+ ## Evaluation Data
212
+
213
+ - **Train / Test / Dev Splits**: Partitioned from the same synthetic source:
214
+ - **Train**: Main dataset (`train` split)
215
+ - **Evaluation**: Sustainable Fashion Eval
216
+ - **Differences**: All synthetic, but evaluation focuses on multi-turn instructions, ensuring coverage of real-world complexities.
217
+
218
+ ---
219
+
220
+ # Evaluation Results
221
+
222
+ ## Summary
223
+
224
+ The model’s performance was measured via:
225
+ - **Loss** on the held-out evaluation set every few steps (`--eval_steps=5`)
226
+ - **Qualitative** checks for correctness, clarity, and coherence
227
+
228
+ Results indicated:
229
+ - **Low perplexity** on domain-specific