Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
---
|
| 2 |
-
---
|
| 3 |
model_name: Mistral-7B-LoRA-Merged
|
| 4 |
repo: clarkkitchen22/mistral-7b-lora-merged
|
| 5 |
author: clarkkitchen22
|
|
@@ -18,15 +17,15 @@ quantization:
|
|
| 18 |
training:
|
| 19 |
approach: "LoRA (Low-Rank Adaptation)"
|
| 20 |
lora:
|
| 21 |
-
rank_r: 16
|
| 22 |
-
alpha: 32
|
| 23 |
-
dropout: 0.05
|
| 24 |
target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]
|
| 25 |
hardware:
|
| 26 |
gpu: "RTX 2070 (8GB)"
|
| 27 |
cpu: "Intel i7-9750H"
|
| 28 |
ram_gb: 16
|
| 29 |
-
timeframe: "
|
| 30 |
|
| 31 |
chat_template:
|
| 32 |
style: "[INST] ... [/INST]"
|
|
@@ -36,10 +35,10 @@ chat_template:
|
|
| 36 |
metrics:
|
| 37 |
- name: qualitative_instruction_following
|
| 38 |
value: "good"
|
| 39 |
-
notes: "
|
| 40 |
- name: latency
|
| 41 |
value: "device-dependent"
|
| 42 |
-
notes: "Merged weights
|
| 43 |
|
| 44 |
usage:
|
| 45 |
quickstart: |
|
|
@@ -54,55 +53,50 @@ usage:
|
|
| 54 |
|
| 55 |
contact:
|
| 56 |
profile: "https://huggingface.co/clarkkitchen22"
|
| 57 |
-
note: "Open for collaboration and AI engineering
|
| 58 |
|
| 59 |
disclaimer: >
|
| 60 |
-
|
|
|
|
| 61 |
---
|
| 62 |
|
|
|
|
| 63 |
|
| 64 |
-
---
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
# 🧠 Mistral-7B-LoRA-Merged
|
| 69 |
**Author:** [clarkkitchen22](https://huggingface.co/clarkkitchen22)
|
| 70 |
|
| 71 |
---
|
| 72 |
|
| 73 |
## 🚀 Overview
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
|
| 77 |
---
|
| 78 |
|
| 79 |
## 🧩 Model Summary
|
|
|
|
| 80 |
| Field | Details |
|
| 81 |
|-------|----------|
|
| 82 |
| **Base Model** | [Mistral-7B](https://huggingface.co/mistralai/Mistral-7B-v0.1) |
|
| 83 |
-
| **Fine-
|
| 84 |
-
| **Merge Process** | Custom `merge_lora.py` script
|
| 85 |
-
| **Hardware Used** | RTX 2070 (
|
| 86 |
| **Precision** | FP16 / 4-bit (bitsandbytes compatible) |
|
| 87 |
| **Training Time** | One weekend |
|
| 88 |
| **Frameworks** | 🤗 Transformers, PEFT, BitsAndBytes |
|
| 89 |
-
| **Use Case** | Instruction-following, reasoning,
|
| 90 |
| **License** | Apache 2.0 |
|
| 91 |
|
| 92 |
---
|
| 93 |
|
| 94 |
-
## 💡
|
| 95 |
-
-
|
| 96 |
-
-
|
| 97 |
-
-
|
| 98 |
-
-
|
| 99 |
-
|
| 100 |
-
-
|
| 101 |
-
|
| 102 |
-
## 🧠 Conceptual Notes
|
| 103 |
-
Think of this model as a “**self-contained brain upgrade**” to Mistral 7B.
|
| 104 |
-
The LoRA adapter learned new reasoning pathways, and the `merge_lora.py` script permanently integrated those improvements into the model’s core weights.
|
| 105 |
-
The result: faster, cleaner inference — no add-ons required.
|
| 106 |
|
| 107 |
---
|
| 108 |
|
|
@@ -121,7 +115,62 @@ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
|
| 121 |
outputs = model.generate(**inputs, max_new_tokens=150)
|
| 122 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 123 |
|
|
|
|
| 124 |
|
| 125 |
-
-
|
| 126 |
-
|
| 127 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
| 2 |
model_name: Mistral-7B-LoRA-Merged
|
| 3 |
repo: clarkkitchen22/mistral-7b-lora-merged
|
| 4 |
author: clarkkitchen22
|
|
|
|
| 17 |
training:
|
| 18 |
approach: "LoRA (Low-Rank Adaptation)"
|
| 19 |
lora:
|
| 20 |
+
rank_r: 16
|
| 21 |
+
alpha: 32
|
| 22 |
+
dropout: 0.05
|
| 23 |
target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]
|
| 24 |
hardware:
|
| 25 |
gpu: "RTX 2070 (8GB)"
|
| 26 |
cpu: "Intel i7-9750H"
|
| 27 |
ram_gb: 16
|
| 28 |
+
timeframe: "Developed over a single weekend (self-taught; no prior Python experience)"
|
| 29 |
|
| 30 |
chat_template:
|
| 31 |
style: "[INST] ... [/INST]"
|
|
|
|
| 35 |
metrics:
|
| 36 |
- name: qualitative_instruction_following
|
| 37 |
value: "good"
|
| 38 |
+
notes: "Tested manually across diverse prompts; no formal benchmark."
|
| 39 |
- name: latency
|
| 40 |
value: "device-dependent"
|
| 41 |
+
notes: "Merged weights enable faster load times and simplified inference."
|
| 42 |
|
| 43 |
usage:
|
| 44 |
quickstart: |
|
|
|
|
| 53 |
|
| 54 |
contact:
|
| 55 |
profile: "https://huggingface.co/clarkkitchen22"
|
| 56 |
+
note: "Open for collaboration and AI engineering opportunities."
|
| 57 |
|
| 58 |
disclaimer: >
|
| 59 |
+
This is an experimental, educational model created on consumer hardware.
|
| 60 |
+
Outputs may vary or hallucinate — please verify responses for critical tasks.
|
| 61 |
---
|
| 62 |
|
| 63 |
+
# 🧠 Mistral-7B-LoRA-Merged
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
**Author:** [clarkkitchen22](https://huggingface.co/clarkkitchen22)
|
| 66 |
|
| 67 |
---
|
| 68 |
|
| 69 |
## 🚀 Overview
|
| 70 |
+
**Mistral-7B-LoRA-Merged** is a fully merged fine-tuned variant of [Mistral-7B](https://huggingface.co/mistralai/Mistral-7B-v0.1).
|
| 71 |
+
Developed by **@clarkkitchen22** in a single weekend, this project demonstrates how open-source frameworks make it possible to **fine-tune and deploy large models on consumer hardware** — and how those skills translate into real, production-level understanding of model internals.
|
| 72 |
+
|
| 73 |
+
This project highlights practical **AI engineering, optimization, and problem-solving skills**, all learned and applied independently.
|
| 74 |
|
| 75 |
---
|
| 76 |
|
| 77 |
## 🧩 Model Summary
|
| 78 |
+
|
| 79 |
| Field | Details |
|
| 80 |
|-------|----------|
|
| 81 |
| **Base Model** | [Mistral-7B](https://huggingface.co/mistralai/Mistral-7B-v0.1) |
|
| 82 |
+
| **Fine-Tuning Method** | LoRA (Low-Rank Adaptation) |
|
| 83 |
+
| **Merge Process** | Custom `merge_lora.py` script |
|
| 84 |
+
| **Hardware Used** | RTX 2070 (8GB VRAM), i7-9750H, 16GB RAM |
|
| 85 |
| **Precision** | FP16 / 4-bit (bitsandbytes compatible) |
|
| 86 |
| **Training Time** | One weekend |
|
| 87 |
| **Frameworks** | 🤗 Transformers, PEFT, BitsAndBytes |
|
| 88 |
+
| **Use Case** | Instruction-following, reasoning, creative text generation |
|
| 89 |
| **License** | Apache 2.0 |
|
| 90 |
|
| 91 |
---
|
| 92 |
|
| 93 |
+
## 💡 Highlights
|
| 94 |
+
- **Merged weights** — no LoRA adapter required for inference.
|
| 95 |
+
- **Lightweight deployment** — optimized for local GPUs (8GB+).
|
| 96 |
+
- **Fully reproducible** — uses standard Hugging Face tools and scripts.
|
| 97 |
+
- **Built self-taught** — demonstrates accessible AI development using open resources.
|
| 98 |
+
- **Custom tooling** — includes a hand-written Python merge script for model consolidation.
|
| 99 |
+
- **Optimized inference** — reduced load time and memory overhead by merging weights directly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
---
|
| 102 |
|
|
|
|
| 115 |
outputs = model.generate(**inputs, max_new_tokens=150)
|
| 116 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 117 |
|
| 118 |
+
🧠 How It Works — The LoRA Merge Explained
|
| 119 |
|
| 120 |
+
Fine-Tuning Phase
|
| 121 |
+
|
| 122 |
+
LoRA fine-tuning modifies only a subset of weights — typically the projection layers in the transformer blocks.
|
| 123 |
+
|
| 124 |
+
Instead of retraining all 7B parameters, LoRA introduces small low-rank matrices (r=16) that capture task-specific updates efficiently.
|
| 125 |
+
|
| 126 |
+
This allows large models to be fine-tuned with minimal GPU memory usage.
|
| 127 |
+
|
| 128 |
+
Merging Phase
|
| 129 |
+
|
| 130 |
+
The trained LoRA adapters (ΔW) are mathematically added back to the base weights (W₀): Wmerged=W0+α⋅ΔW
|
| 131 |
+
|
| 132 |
+
After merging, the model behaves as if the adapters were permanently installed — no extra files, wrappers, or configuration needed.
|
| 133 |
+
|
| 134 |
+
The final checkpoint contains all learned improvements in a single, easy-to-deploy model file.
|
| 135 |
+
|
| 136 |
+
Result
|
| 137 |
+
|
| 138 |
+
Faster load times, reduced dependencies, and stable inference performance.
|
| 139 |
+
|
| 140 |
+
The merged model runs smoothly on mid-range GPUs while maintaining accuracy comparable to the fine-tuned version.
|
| 141 |
+
|
| 142 |
+
🧰 Technical Skills Demonstrated
|
| 143 |
+
Category Skills & Concepts
|
| 144 |
+
Model Engineering In-depth understanding of transformer internals, LoRA architecture, and PEFT fine-tuning techniques.
|
| 145 |
+
Python Development Wrote custom merge_lora.py to automate model consolidation using the PEFT and Transformers APIs.
|
| 146 |
+
Systems Optimization Applied 4-bit and 8-bit quantization for efficient training/inference on consumer GPUs.
|
| 147 |
+
Experiment Design Planned and executed an end-to-end fine-tuning experiment, validated output quality manually.
|
| 148 |
+
Model Deployment Created a single self-contained model ready for inference on Hugging Face and local hardware.
|
| 149 |
+
Documentation & Reproducibility Produced structured metadata and README documentation for clarity and collaboration.
|
| 150 |
+
Self-Learning Learned Python, PEFT, and LoRA concepts from scratch and successfully implemented them within days.
|
| 151 |
+
🧩 Why This Matters
|
| 152 |
+
|
| 153 |
+
This project is a proof of initiative, adaptability, and technical execution.
|
| 154 |
+
It demonstrates the ability to:
|
| 155 |
+
|
| 156 |
+
Independently research, implement, and validate advanced ML techniques.
|
| 157 |
+
|
| 158 |
+
Bridge the gap between research concepts and deployable systems.
|
| 159 |
+
|
| 160 |
+
Optimize large models for real-world use cases on constrained hardware.
|
| 161 |
+
|
| 162 |
+
Communicate the technical process clearly for both technical and non-technical stakeholders.
|
| 163 |
+
|
| 164 |
+
📬 Contact
|
| 165 |
+
|
| 166 |
+
Profile: huggingface.co/clarkkitchen22
|
| 167 |
+
|
| 168 |
+
Note: Open to collaboration and AI/ML engineering roles.
|
| 169 |
+
|
| 170 |
+
⚠️ Disclaimer
|
| 171 |
+
|
| 172 |
+
This is an educational and experimental project created on consumer hardware.
|
| 173 |
+
Outputs may contain inaccuracies; please verify results for important use cases.
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
---
|