adhafajp commited on
Commit
2fc4a1a
Β·
1 Parent(s): 77fc812

Feat: Totally change adapter with final version (1d 21h)

Browse files
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- license: apache-2.0
3
  base_model: microsoft/phi-2
4
  pipeline_tag: text-generation
5
  datasets:
@@ -31,7 +31,7 @@ tags:
31
 
32
  This repository contains the **QLoRA adapter** for creating **"Zero"**, a specialized instruction-following AI assistant fine-tuned from [`microsoft/phi-2`](https://huggingface.co/microsoft/phi-2).
33
 
34
- This model is the core component of a **full-stack MLOps portfolio project**, demonstrating capabilities from **fine-tuning** to **production-ready deployment**.
35
 
36
  - 🧩 **Model Adapter:** [adhafajp/phi2-qlora-zero-chat](https://huggingface.co/adhafajp/phi2-qlora-zero-chat)
37
  - βš™οΈ **Full FastAPI Project (Main Portfolio):** [GitHub – ZeroChat](https://github.com/adhafajp/ZeroChat)
@@ -40,13 +40,14 @@ This model is the core component of a **full-stack MLOps portfolio project**, de
40
 
41
  ## πŸš€ Project Overview
42
 
43
- **Zero** is designed to serve as a fast, memory-efficient conversational model optimized for reasoning, instruction-following, and question-answering tasks.
44
 
45
- ### Key Features
46
- - 🧠 **Fine-tuned using QLoRA** β€” efficient, low-resource adaptation of Phi-2.
47
- - ⚑ **Backend:** Asynchronous **FastAPI** server with streaming responses.
48
- - πŸ’¬ **Frontend:** Interactive chat interface built with **HTML**, **TailwindCSS**, and **JavaScript** (via Server-Sent Events).
49
- - πŸ” **Deployment-ready:** Lightweight and easy to containerize.
 
50
 
51
  ---
52
 
@@ -58,6 +59,8 @@ This model is the core component of a **full-stack MLOps portfolio project**, de
58
  | **Method** | QLoRA (Quantized LoRA Fine-Tuning) |
59
  | **Language** | English only |
60
  | **Precision** | 4-bit (NF4) |
 
 
61
  | **Frameworks** | `transformers`, `peft`, `bitsandbytes`, `fastapi` |
62
 
63
  ### Dataset Composition
@@ -68,6 +71,13 @@ The adapter was trained on a curated blend of English datasets:
68
 
69
  ---
70
 
 
 
 
 
 
 
 
71
  ## πŸ”§ Integration Example
72
 
73
  A complete **local deployment example** (FastAPI backend + chat frontend) is available at the main project repository:
@@ -82,20 +92,27 @@ This repository demonstrates how to integrate this adapter with:
82
 
83
  ## πŸ“ˆ Training Phases Summary
84
 
85
- The fine-tuning process consisted of multiple experimental stages:
 
 
86
 
87
  | Phase | Summary | Runtime |
88
  |--------|----------|----------|
89
- | **1A** | Initial fine-tune (canceled at 11h 50m due to val overfit) | 11h 50m |
90
- | **1B** | Full 2-epoch fine-tune on Alpaca + SQuADv2 + persona (main baseline) | 5d 11h 50m |
91
- | **1C** | Small re-train on reduced subset (underfit) | 19h |
92
- | **1D / 1D-A / 1E** | Refinement attempts with packing and oversampling | ~3d total |
93
  | **1F** | Final adapter re-train from **1B** (expanded persona dataset, balanced oversampling) | 1d 5h |
94
 
95
- The released adapter corresponds to **Phase 1F**, which achieved balanced performance across **instruction-following**, **reasoning**, and **identity consistency**.
 
 
 
 
 
96
 
97
- πŸ“Š W&B Log (Phase 1F):
98
- [wandb.ai/VoidNova/phi-2-2.7B_qlora_alpaca-51.8k_identity-model-232_squadv2-15k/runs/bpju3d09](https://wandb.ai/VoidNova/phi-2-2.7B_qlora_alpaca-51.8k_identity-model-232_squadv2-15k/runs/bpju3d09?nw=nwuseradhafajp)
99
 
100
  ---
101
 
@@ -192,7 +209,7 @@ print(f"Model response:\n{final_answer}")
192
  ---
193
 
194
  ### πŸͺΆ Example Prompts
195
- "Who are you?"
196
  "How to be success?"
197
 
198
  ---
@@ -201,11 +218,14 @@ print(f"Model response:\n{final_answer}")
201
  "CONTEXT:---Zinc is an essential mineral perceived by the public today as being of ''exceptional biologic and public health importance'', especially regarding prenatal and postnatal development. Zinc deficiency affects about two billion people in the developing world and is associated with many diseases. In children it causes growth retardation, delayed sexual maturation, infection susceptibility, and diarrhea. Enzymes with a zinc atom in the reactive center are widespread in biochemistry, such as alcohol dehydrogenase in humans. Consumption of excess zinc can cause ataxia, lethargy and copper deficiency.---QUESTION:How many people are affected by zinc deficiency?"
202
 
203
 
204
- ## Acknowledgements & Licenses
205
 
206
  This project builds upon several outstanding open-source contributions:
207
 
208
- * **Base Model:** This work is a fine-tuned adapter of `microsoft/phi-2`. The `phi-2` model is licensed under the **MIT License**.
209
- * `Copyright (c) 2023 Microsoft`
210
- * **Libraries:** This project is powered by `transformers`, `peft`, and `bitsandbytes` by Hugging Face πŸ€—, as well as `torch` by PyTorch. These libraries are generally available under the Apache 2.0 or similar permissive licenses.
211
- * **This Adapter & Code:** The original code for this repository (including the adapter weights) is licensed under the **Apache 2.0 License**.
 
 
 
 
1
  ---
2
+ license: mit
3
  base_model: microsoft/phi-2
4
  pipeline_tag: text-generation
5
  datasets:
 
31
 
32
  This repository contains the **QLoRA adapter** for creating **"Zero"**, a specialized instruction-following AI assistant fine-tuned from [`microsoft/phi-2`](https://huggingface.co/microsoft/phi-2).
33
 
34
+ This model serves as the **core component** of a full-stack **AI engineering and MLOps workflow project**, covering the complete lifecycle from **fine-tuning (with W&B tracking)** to **local inference and system integration** using FastAPI.
35
 
36
  - 🧩 **Model Adapter:** [adhafajp/phi2-qlora-zero-chat](https://huggingface.co/adhafajp/phi2-qlora-zero-chat)
37
  - βš™οΈ **Full FastAPI Project (Main Portfolio):** [GitHub – ZeroChat](https://github.com/adhafajp/ZeroChat)
 
40
 
41
  ## πŸš€ Project Overview
42
 
43
+ **Zero** is designed as a lightweight, memory-efficient conversational model optimized for reasoning, instruction-following, and question-answering tasks.
44
 
45
+ ### Key Features:
46
+ - 🧠 **Fine-tuned using QLoRA** β€” efficient, low-resource adaptation of Phi-2
47
+ - βš™οΈ **Backend:** Asynchronous **FastAPI** inference server with streaming responses
48
+ - πŸ’¬ **Frontend:** Interactive chat interface built with **HTML**, **TailwindCSS**, and **JavaScript** (via Server-Sent Events)
49
+ - πŸ” **Experiment tracking:** Integrated **Weights & Biases (W&B)** logging for training runs
50
+ - πŸ” **Local deployment-ready:** Lightweight, easily containerized for offline use
51
 
52
  ---
53
 
 
59
  | **Method** | QLoRA (Quantized LoRA Fine-Tuning) |
60
  | **Language** | English only |
61
  | **Precision** | 4-bit (NF4) |
62
+ | **LoRA Config** | r=16, alpha=32, Dropout=0.07 |
63
+ | **Optimizer** | Paged AdamW 8-bit |
64
  | **Frameworks** | `transformers`, `peft`, `bitsandbytes`, `fastapi` |
65
 
66
  ### Dataset Composition
 
71
 
72
  ---
73
 
74
+ ## πŸ–₯️ Training Hardware
75
+ Fine-tuning was performed entirely on a consumer-grade laptop:
76
+ - **Laptop:** Acer Nitro V15 - **GPU:** NVIDIA RTX 2050 Mobile (4 GB VRAM) - **CPU:** Intel Core i5-13420H - **RAM:** 16 GB - **Quantization:** 4-bit NF4 - **Strategy:** Low VRAM setup using gradient accumulation, packing, and LoRA adapters
77
+ This demonstrates that Phi-2 can be fine-tuned effectively even on low-VRAM devices.
78
+
79
+ ---
80
+
81
  ## πŸ”§ Integration Example
82
 
83
  A complete **local deployment example** (FastAPI backend + chat frontend) is available at the main project repository:
 
92
 
93
  ## πŸ“ˆ Training Phases Summary
94
 
95
+ The fine tuning consist of multiple stage experiment
96
+
97
+ Stage 1:
98
 
99
  | Phase | Summary | Runtime |
100
  |--------|----------|----------|
101
+ | **1A** | Initial fine-tune (canceled due to overfitting) | 11h 50m |
102
+ | **1B** | Full 2-epoch fine-tune on Alpaca + SQuADv2 + persona | 5d 11h 50m |
103
+ | **1C** | Small re-train (underfit) | 19h |
104
+ | **1D / 1D-A / 1E** | Refinement attempts with packing & oversampling | ~3d total |
105
  | **1F** | Final adapter re-train from **1B** (expanded persona dataset, balanced oversampling) | 1d 5h |
106
 
107
+ Stage 2:
108
+ After gathering all the insights from the initial experiments (1A-1F), fine-tuning was restarted completely from scratch. By applying all the lessons learned, this new training process achieved better and more balanced performance in just 1s 21h.
109
+ The adapter released in this repository is the result of this final, optimized training.
110
+ | Phase | Summary | Runtime |
111
+ |--------|----------|----------|
112
+ | **1** | Fine-tune again from scratch by applying all the insights from previous experiments. | 1d 21h |
113
 
114
+ πŸ“Š **W&B Log (Phase 1F):** [wandb.ai/VoidNova/.../runs/bpju3d09](https://wandb.ai/VoidNova/phi-2-2.7B_qlora_alpaca-51.8k_identity-model-232_squadv2-15k/runs/bpju3d09?nw=nwuseradhafajp)
115
+ πŸ“Š **W&B Log (Final):** [wandb.ai/VoidNova/.../runs/rx5fih5v](https://wandb.ai/VoidNova/phi-2_qlora_ZeroChat/runs/rx5fih5v?nw=nwuseradhafajp)
116
 
117
  ---
118
 
 
209
  ---
210
 
211
  ### πŸͺΆ Example Prompts
212
+ "Who are you?"
213
  "How to be success?"
214
 
215
  ---
 
218
  "CONTEXT:---Zinc is an essential mineral perceived by the public today as being of ''exceptional biologic and public health importance'', especially regarding prenatal and postnatal development. Zinc deficiency affects about two billion people in the developing world and is associated with many diseases. In children it causes growth retardation, delayed sexual maturation, infection susceptibility, and diarrhea. Enzymes with a zinc atom in the reactive center are widespread in biochemistry, such as alcohol dehydrogenase in humans. Consumption of excess zinc can cause ataxia, lethargy and copper deficiency.---QUESTION:How many people are affected by zinc deficiency?"
219
 
220
 
221
+ ## Acknowledgements & License
222
 
223
  This project builds upon several outstanding open-source contributions:
224
 
225
+ * **Base Model:** This adapter is fine-tuned from [`microsoft/phi-2`](https://huggingface.co/microsoft/phi-2), licensed under the **MIT License**.
226
+ *Copyright (c) 2023 Microsoft.*
227
+
228
+ * **Libraries:** Powered by `transformers`, `peft`, and `bitsandbytes` from Hugging Face πŸ€—, as well as `torch` from PyTorch β€” all permissively licensed (Apache 2.0 or MIT).
229
+
230
+ * **This Adapter & Code:** Released under the **MIT License**.
231
+ You are free to use, modify, and distribute it with proper attribution.
adapter_config.json CHANGED
@@ -15,7 +15,7 @@
15
  "loftq_config": {},
16
  "lora_alpha": 32,
17
  "lora_bias": false,
18
- "lora_dropout": 0.07,
19
  "megatron_config": null,
20
  "megatron_core": "megatron.core",
21
  "modules_to_save": null,
@@ -25,12 +25,12 @@
25
  "rank_pattern": {},
26
  "revision": null,
27
  "target_modules": [
28
- "k_proj",
29
- "v_proj",
30
  "q_proj",
31
  "fc1",
 
 
32
  "dense",
33
- "fc2"
34
  ],
35
  "target_parameters": null,
36
  "task_type": "CAUSAL_LM",
 
15
  "loftq_config": {},
16
  "lora_alpha": 32,
17
  "lora_bias": false,
18
+ "lora_dropout": 0.1,
19
  "megatron_config": null,
20
  "megatron_core": "megatron.core",
21
  "modules_to_save": null,
 
25
  "rank_pattern": {},
26
  "revision": null,
27
  "target_modules": [
 
 
28
  "q_proj",
29
  "fc1",
30
+ "k_proj",
31
+ "fc2",
32
  "dense",
33
+ "v_proj"
34
  ],
35
  "target_parameters": null,
36
  "task_type": "CAUSAL_LM",
adapter_model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:96a8c75e8f69f978ebd7fecb8e78f5e70b0edccc8adb77a3f327e6fe427d346a
3
  size 1124708052
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:800299e8664be4bf9d9c68eb6634579b655b31d4368bc08db5939586cf61ea8b
3
  size 1124708052
training_args.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4910e3cbee3e89235f7dd52c7d44cc26f899f642b3d29a6507a0e1a93d211e40
3
  size 6353
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71b37fb951bfd8e038bc1f7eaef715f3a4811da107951f8765b217a70438ae00
3
  size 6353