Safetensors
File size: 2,911 Bytes
b081c1f
 
2bf967b
 
 
 
 
b081c1f
2bf967b
5320d73
 
 
 
 
 
 
 
 
 
2bf967b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5320d73
 
 
 
 
 
 
 
5fc7d7b
5320d73
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
license: apache-2.0
base_model: mistralai/Mistral-7B-v0.1
datasets:
- abacusai/MetaMathFewshot
- shahules786/orca-chat
- anon8231489123/ShareGPT_Vicuna_unfiltered
---

```json
{
  "layer_map": [
    [0, 16],
    [8, 24],
    [16, 32]
  ]
}
```

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c14f6b02e1f8f67c73bd05/pf4d6FA7DriRtVq5HCkxd.png)

This model is a variation of [abacusai/Fewshot-Metamath-OrcaVicuna-Mistral](https://huggingface.co/datasets/abacusai/Fewshot-Metamath-OrcaVicuna-Mistral)
that builds on the idea of scaling up models by duplicating layers of the base model, in this case
[mistralai/Mistral-7B-v0.1](https://huggingface.co/datasets/mistralai/Mistral-7B-v0.1). It relies on the functionality added in this PR
https://github.com/huggingface/peft/pull/1368 to train a model with replicated layers without much extra GPU memory. So although there are 48 layers
that have lora adapters added, there are only 32 original layers so the memory usage is pretty much the same as the memory usage for the base 7B model.

This is just a demonstration model to indicate how this approach can be used and the goal is to apply it to much larger models. For example
models like Goliath or MegaDolphin which are effectively 120B models but using this approach they will only use 70B of memory for the base model and
a little extra for the LoRA adaption layers.

In our training runs we did find a difference in the behavior of the eval loss:

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c14f95cac5f9ba52bbcd7f/vszXUSmANBw6EFjn4sX1N.png)

vs the loss curve for the original LoRA finetune of the 7B model

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c14f95cac5f9ba52bbcd7f/dis1P2MD_Rsyw81aIVByS.png)

The larger model achieved a best eval loss of 0.3915 vs 0.3971 in a lot fewer steps.

Overall, we think this is a promising approach to accessing much larger models without significantly more resources.

# Performance on Metrics

To do a proper abalation we compared the performance of 4 models trained for ~1 epoch on the combined datasets (Metamath,
Orca, ShareGPT). Here are the results:

| Model | Trainable Params | Train Loss | Eval Loss | GSM8K | TruthfulQA |
| :-----| ------: | ---------: | -------: | ----: | ---------: |
| Mistral 7B | 0 | - | - | 0.374 | 0.426 |
| Mistral 10B | 0 | - | - | 0.290 | 0.407 |
| Mistral 7B + LoRA r=12 | 31M | 0.412 | 0.366 | 0.514 | 0.499 |
| Mistral 10B + LoRA r=8 | 31M | 0.401 | 0.363 | 0.663 | 0.540 |

This ablation compares the base model (Mistral 7B), expansion using the layer map described here and fine tunes of a lora `r=12`
on the base model and `r=8` (to match trainable params). The ablation demonstrates quite clearly that fine tuning the expanded
model leads to a significant improvement in metrics even with the same number of trainable parameters (and training steps).