Spaces:
Running
Running
Uploaded new content for fine tuning
Browse files- Finetuning.html +60 -0
Finetuning.html
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Fine tuning LLM study - Experimental Setup</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
line-height: 1.6;
|
| 11 |
+
margin: 20px;
|
| 12 |
+
}
|
| 13 |
+
h1, h2 {
|
| 14 |
+
color: #333;
|
| 15 |
+
}
|
| 16 |
+
h2 {
|
| 17 |
+
margin-top: 30px;
|
| 18 |
+
}
|
| 19 |
+
ul {
|
| 20 |
+
list-style-type: disc;
|
| 21 |
+
margin-left: 20px;
|
| 22 |
+
}
|
| 23 |
+
p {
|
| 24 |
+
margin-bottom: 15px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
table{
|
| 28 |
+
border-collapse: collapse;
|
| 29 |
+
width: 95%;
|
| 30 |
+
border: 2px solid #2c3e50;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
tr{
|
| 34 |
+
border-bottom: 2px solid #b60e0e;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
td{
|
| 38 |
+
width: 15%;
|
| 39 |
+
vertical-align: top;
|
| 40 |
+
border: 2px solid #3498db;
|
| 41 |
+
}
|
| 42 |
+
</style>
|
| 43 |
+
</head>
|
| 44 |
+
<body>
|
| 45 |
+
<h2>The very basics</h2>
|
| 46 |
+
<p>
|
| 47 |
+
There are various open sourc libraries available to fine tune LLM's. In the following experimental setup, we will utilize <br>
|
| 48 |
+
mlx_lm, its blazing fast on a mac, as it uses native apple silicon hardware. Under the PEFT (Parameter Efficient Fine Tuning) bucket,
|
| 49 |
+
it offers LORA, DORA and Full fine tuning options. (Pls refert to --fine-tune-type {lora,dora,full} option).
|
| 50 |
+
Several other libraries like Unsloth, Hugging face transformers, Llama-factory etc can be used as well.
|
| 51 |
+
<b>Absolute Golden Rule of Thumb: Decide to finetune a LLM on how model behaves, use RAG on what it knows.</b>
|
| 52 |
+
</p>
|
| 53 |
+
<h2>So, here is a very basic run down of the three fine tuning types</h2>
|
| 54 |
+
<p>
|
| 55 |
+
1. lora (Low-Rank Adaptation)Status: This is the default mode.Behavior: It injects small low-rank adapter matrices while freezing the base model. If you pass a quantized base model (e.g., 4-bit), mlx_lm will automatically perform QLoRA instead of standard LoRA to save massive amounts of memory.
|
| 56 |
+
2. dora (Weight-Decomposition Low-Rank Adaptation)Status: Fully supported PEFT method in mlx_lm.Behavior: DoRA is an advanced PEFT styled fine-tuning method that decomposes the weights into magnitude and direction components. It trains similarly to LoRA but mathematically matches full fine-tuning performance much more closely.
|
| 57 |
+
3. full (Full Fine-Tuning / FFT)Status: Supported.Behavior: This is not a PEFT method. It unfreezes all parameters of the model and modifies every single weight directly. It requires vastly more Unified Memory (RAM) on your Mac, but it completely eliminates the restrictions of adapters when trying to teach the model deep, complex factual knowledge
|
| 58 |
+
</p>
|
| 59 |
+
</body>
|
| 60 |
+
</html>
|