File size: 1,451 Bytes
c1badd1
 
96ff260
b89272c
 
 
 
 
 
 
c1badd1
 
96ff260
c1badd1
96ff260
b74055d
 
 
 
 
 
96ff260
c1badd1
96ff260
7e6637a
b74055d
 
 
 
 
 
 
96ff260
 
c1badd1
96ff260
 
 
c1badd1
 
96ff260
 
 
 
 
b89272c
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
---
library_name: transformers
license: apache-2.0
language:
- en
tags:
- conversational
- math
- distillation
- mistral
---

This is an experimental model. 

The idea is :
- Calculate the difference in weights between a donor model(meta-math/MetaMath-Mistral-7B) and the base model(mistralai/Mistral-7B-v0.1). This difference represents how much each parameter needs to be adjusted to go from the base state to the donor state.

```
vector = math_model.state_dict()[k] - base_model.state_dict()[k]
```

- Vector retrieved from the result of step one, is added to third model(lex-hue/Delexa-7b). This should transfer **math** *skills* to our third model.

```
vector = new_math_model.state_dict()[k]
new_v = v + vector.to(v.device)
v.copy_(new_v)
```

### Example:

```  
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_name = "aloobun/CosmicNoodle-7B"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")


prompt = "For the natural number A, the quotient of A divided by 9 is 6 and the remainder is 5. What is the value of A?\n"
input_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
tokens = model.generate(input_ids.to(device=model.device), max_new_tokens=128, temperature=0.99, top_p=0.95, do_sample=True)
out = tokenizer.decode(tokens[0], skip_special_tokens=True)
print(out)
```