burpi commited on
Commit
5221f04
·
verified ·
1 Parent(s): 4f4d82c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +162 -113
README.md CHANGED
@@ -1,199 +1,248 @@
1
- ---
2
- library_name: transformers
3
- tags: []
4
- ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
 
58
- ## Bias, Risks, and Limitations
 
 
 
 
 
 
 
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
 
62
- [More Information Needed]
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
- ## How to Get Started with the Model
71
 
72
- Use the code below to get started with the model.
73
 
74
- [More Information Needed]
 
 
 
 
 
 
 
75
 
76
- ## Training Details
77
 
78
- ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
83
 
84
- ### Training Procedure
 
 
 
 
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
89
 
90
- [More Information Needed]
91
 
 
92
 
93
- #### Training Hyperparameters
 
 
 
 
 
 
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
 
97
- #### Speeds, Sizes, Times [optional]
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
 
101
- [More Information Needed]
 
 
 
 
 
 
 
 
102
 
103
- ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
 
107
- ### Testing Data, Factors & Metrics
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
 
119
- [More Information Needed]
 
 
 
 
 
 
 
 
 
120
 
121
- #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
- [More Information Needed]
126
 
127
- ### Results
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
132
 
 
133
 
 
 
134
 
135
- ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
 
 
 
 
 
138
 
139
- [More Information Needed]
140
 
141
- ## Environmental Impact
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
158
 
159
- ### Compute Infrastructure
 
 
 
 
 
 
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
164
 
165
- [More Information Needed]
166
 
167
- #### Software
168
 
169
- [More Information Needed]
 
 
 
 
 
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
 
 
 
 
 
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
1
+ # Cooking-Qwen-Merged
 
 
 
2
 
3
+ **A small, specialized cooking language model fine-tuned using synthetic instruction data, knowledge distillation, and Low-Rank Adaptation (LoRA).**
4
 
5
+ ## Overview
6
 
7
+ Cooking-Qwen-Merged is a fine-tuned Qwen language model designed to answer cooking questions, explain recipes, identify ingredient quantities, and provide preparation guidance.
8
 
9
+ The goal of this project was straightforward: **build and fine-tune a functional cooking assistant within a single weekend.**
10
 
11
+ Rather than training a language model from scratch, the project uses a pretrained Qwen model and a teacher–student knowledge distillation pipeline to generate specialized training data.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
+ A larger language model was provided with relevant recipe information retrieved from a vector database. Its generated answers were then used to fine-tune the smaller model using LoRA.
14
 
15
+ The resulting model contains approximately 597 million parameters, with fewer than 0.2% updated during fine-tuning.
16
 
17
+ ## Model Details
 
 
 
 
 
 
 
 
 
 
18
 
19
+ | Property | Description |
20
+ |---|---|
21
+ | Developer | Murphy Amos |
22
+ | Hugging Face | [burpi](https://huggingface.co/burpi) |
23
+ | Model type | Causal language model |
24
+ | Architecture | Qwen-based transformer |
25
+ | Parameters | 597,196,800 |
26
+ | Language | English |
27
+ | Specialization | Cooking and recipe question answering |
28
+ | Fine-tuning method | Supervised fine-tuning with LoRA |
29
+ | Training framework | PyTorch, Transformers, PEFT |
30
+ | Distribution | Merged model weights |
31
+ | License | To be verified against the base model license |
32
 
33
+ ## Project Objective
34
 
35
+ The objective was to develop a small, domain-specific cooking assistant over a weekend using existing open-source machine learning tools.
36
 
37
+ The project involved building a data-generation pipeline, generating thousands of cooking-related questions, using a larger teacher model to produce training responses, and fine-tuning a smaller Qwen model.
38
 
39
+ The focus was on delivering a working model rather than conducting a formal research experiment.
40
 
41
+ ## Intended Uses
42
 
43
+ Cooking-Qwen-Merged is intended for:
44
 
45
+ - Answering general cooking questions.
46
+ - Explaining recipe instructions and preparation methods.
47
+ - Identifying ingredients and their quantities.
48
+ - Suggesting ingredient substitutions.
49
+ - Explaining cooking techniques.
50
+ - Assisting with recipe scaling.
51
+ - Providing beginner-friendly cooking guidance.
52
+ - Answering questions using externally retrieved recipe context.
53
 
54
+ ### Out-of-Scope Uses
55
 
56
+ The model is not intended to replace professional advice regarding nutrition, food allergies, or food safety.
57
 
58
+ Generated cooking instructions should be independently verified when incorrect information could create a safety risk.
59
 
60
+ ## Training Methodology
61
 
62
+ ### Dataset Generation
63
 
64
+ The training dataset was constructed using structured recipe information and synthetically generated question–answer pairs.
65
 
66
+ A collection of **5,000 distinct cooking-related questions** was created to cover a variety of tasks, including:
67
 
68
+ - Ingredient identification and measurements.
69
+ - Recipe preparation and step-by-step instructions.
70
+ - Cooking methods and techniques.
71
+ - Ingredient substitutions.
72
+ - Recipe scaling and quantity adjustments.
73
+ - Dietary modifications.
74
+ - Cooking troubleshooting.
75
+ - Cooking times, temperatures, and doneness indicators.
76
 
77
+ The questions were used to query a larger teacher language model with relevant recipe information retrieved from a vector database.
78
 
79
+ The teacher-generated responses formed the basis of the student model's supervised fine-tuning dataset.
80
 
81
+ ### Training Dataset
82
 
83
+ The recorded training split contained:
84
 
85
+ | Dataset | Examples |
86
+ |---|---:|
87
+ | Training | 4,270 |
88
+ | Evaluation | 1,068 |
89
+ | Total | 5,338 |
90
 
91
+ The 5,000-question collection represents the question-generation input. The 5,338 examples represent the recorded fine-tuning dataset.
92
 
93
+ The difference between these counts has not been independently reconciled.
94
 
95
+ ### Knowledge Distillation Pipeline
96
 
97
+ The project used a teacher–student workflow:
98
 
99
+ 1. **Recipe ingestion:** Structured recipe information was loaded into a vector database.
100
+ 2. **Question generation:** A collection of 5,000 cooking-related questions was prepared.
101
+ 3. **Context retrieval:** Relevant recipe information was retrieved for each question.
102
+ 4. **Teacher inference:** A larger language model generated answers using the retrieved context.
103
+ 5. **Dataset construction:** Generated question–answer pairs were formatted as conversational training examples.
104
+ 6. **Student fine-tuning:** A smaller Qwen model was fine-tuned using LoRA.
105
+ 7. **Model merging:** The trained adapter was merged into the original model weights for standalone distribution.
106
 
107
+ This approach allowed the project to specialize an existing small language model without full-parameter training.
108
 
109
+ ## Parameter-Efficient Fine-Tuning
110
 
111
+ Low-Rank Adaptation (LoRA) was used to update a small subset of the model's parameters.
112
 
113
+ | Training property | Value |
114
+ |---|---:|
115
+ | Total parameters | 597,196,800 |
116
+ | Trainable parameters | 1,146,880 |
117
+ | Trainable proportion | 0.192% |
118
+ | Initial learning rate | Approximately 0.0002 |
119
+ | Training steps | Approximately 2,150 |
120
+ | Training approach | LoRA / PEFT |
121
+ | Optimization objective | Supervised next-token prediction |
122
 
123
+ LoRA adapters were applied to attention projection layers, including query and value projections.
124
 
125
+ The trained adapter was subsequently merged with the pretrained model weights.
126
 
127
+ ## Training Performance
128
 
129
+ The model was fine-tuned for approximately 2,150 optimization steps using LoRA and a linearly decaying learning-rate schedule.
130
 
131
+ ### Training and Evaluation Curves
132
 
133
+ ![Training and evaluation loss with learning-rate schedule](training_metrics.png)
134
 
135
+ The training graph illustrates the optimization process, including raw training loss, smoothed training loss, evaluation loss, and learning-rate decay.
136
 
137
+ ### Training Metrics
138
 
139
+ | Metric | Approximate value |
140
+ |---|---:|
141
+ | Initial recorded training loss | 3.17 |
142
+ | Final training loss | 1.40 |
143
+ | Final evaluation loss | 1.41 |
144
+ | Training-loss reduction | 56% |
145
+ | Initial learning rate | 0.0002 |
146
+ | Final learning rate | Approximately 0 |
147
+ | Optimization steps | Approximately 2,150 |
148
+ | Learning-rate schedule | Linear decay |
149
 
150
+ ### Training Observations
151
 
152
+ **Initial convergence:** Training loss decreased rapidly during the first 200–300 optimization steps, indicating substantial early adaptation to the cooking instruction dataset.
153
 
154
+ **Continued optimization:** Loss decreased more gradually throughout the remaining training process, stabilizing around 1.35–1.45.
155
 
156
+ **Evaluation performance:** Evaluation loss remained approximately 1.4 at the recorded evaluation checkpoints. The relatively small difference between training and evaluation loss suggests no obvious severe overfitting at those checkpoints, although further testing is necessary.
157
 
158
+ **Learning-rate behavior:** The learning rate decreased approximately linearly from 2 × 10⁻⁴ to zero across the training run.
159
 
160
+ ### Interpretation
161
 
162
+ The results demonstrate that the LoRA fine-tuning process successfully reduced the model's next-token prediction loss on the cooking instruction dataset.
163
 
164
+ These measurements establish training convergence but do not independently verify cooking accuracy, factual reliability, or improvement over the original pretrained model.
165
+ ## Training Results
166
 
167
+ Training progress was monitored using training loss, evaluation loss, and learning-rate metrics.
168
 
169
+ | Metric | Approximate value |
170
+ |---|---:|
171
+ | Initial recorded training loss | 3.17 |
172
+ | Final recorded training loss | 1.40 |
173
+ | Recorded evaluation loss | 1.41 |
174
+ | Training-loss reduction | 56% |
175
 
176
+ The reduction in training loss indicates improved predictive fit to the fine-tuning data.
177
 
178
+ These metrics do not independently establish factual accuracy, generalization to unseen recipes, or superiority over the original pretrained model.
179
 
180
+ ### Evaluation Status
181
 
182
+ The model has undergone preliminary interactive testing with cooking-related questions.
183
 
184
+ A comprehensive independent benchmark comparing the pretrained and fine-tuned models has not yet been completed.
 
 
 
 
185
 
186
+ Future evaluations may measure ingredient accuracy, instruction correctness, hallucination frequency, and performance on recipes excluded from training.
187
 
188
+ ## Limitations
189
 
190
+ Cooking-Qwen-Merged has several limitations:
191
 
192
+ - The model may generate incorrect ingredient quantities, cooking times, or temperatures.
193
+ - It may produce plausible but unsupported cooking instructions.
194
+ - Synthetic training data may contain errors inherited from the teacher model or retrieval pipeline.
195
+ - Some generated training questions contain formatting or measurement inconsistencies.
196
+ - The model has not been comprehensively evaluated on unseen recipes.
197
+ - Fine-tuning does not guarantee memorization of the complete recipe database.
198
+ - Retrieval augmentation may improve performance on questions requiring exact recipe information.
199
 
200
+ The model should be treated as a cooking assistant rather than an authoritative recipe database.
201
 
202
+ ## Technical Architecture
203
 
204
+ The model is based on a pretrained Qwen causal language model.
205
 
206
+ Its fine-tuning process used:
207
 
208
+ - PyTorch for model execution and optimization.
209
+ - Hugging Face Transformers for model loading and training.
210
+ - PEFT for parameter-efficient fine-tuning.
211
+ - LoRA for low-rank weight adaptation.
212
+ - A vector database for recipe retrieval during synthetic data generation.
213
+ - A larger teacher language model for generating supervised training responses.
214
 
215
+ After fine-tuning, the LoRA adapter was merged into the base model for deployment.
216
 
217
+ ## Future Improvements
218
 
219
+ Potential improvements include:
220
 
221
+ 1. Benchmarking the fine-tuned model against the original Qwen model.
222
+ 2. Improving the quality and consistency of synthetic training examples.
223
+ 3. Testing generalization on recipes excluded from training.
224
+ 4. Quantizing the model to reduce memory requirements.
225
+ 5. Comparing standalone inference with retrieval-augmented inference.
226
+ 6. Integrating the model into a cooking assistant application.
227
 
228
+ ## Project Background
229
 
230
+ Cooking-Qwen-Merged was developed as an independent weekend machine learning project.
231
 
232
+ The project demonstrates a practical workflow for creating a specialized language model using retrieval-grounded synthetic data, teacher–student distillation, and parameter-efficient fine-tuning.
233
 
234
+ It is an engineering project rather than a peer-reviewed research publication.
235
 
236
+ ## Citation
237
 
238
+ **Amos, M. (2026). Cooking-Qwen-Merged: A Small Cooking Language Model Fine-Tuned with Synthetic Instruction Data and LoRA. Hugging Face.**
239
 
240
+ https://huggingface.co/burpi/Cooking-Qwen-Merged
241
 
242
+ ## Author
243
 
244
+ **Murphy Amos**
245
 
246
+ AI Software Engineer | Computer Game Development Undergraduate
247
 
248
+ [GitHub](https://github.com/MurphyAmos) | [Hugging Face](https://huggingface.co/burpi)