File size: 2,889 Bytes
7c0169c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3ccad1
7c0169c
e3ccad1
 
7c0169c
 
 
 
 
 
 
 
 
 
 
 
 
 
e3ccad1
7c0169c
e3ccad1
 
7c0169c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3ccad1
7c0169c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
license: cc-by-nc-4.0
tags:
- merge
- mergekit
- lazymergekit
- automerger
---

## 🧩 Configuration
```yaml
#slices:
#  - sources:
#      - model: liminerity/M7-7b
#        layer_range: [0, 32]
#      - model: AurelPx/Percival_01-7b-slerp
#        layer_range: [0, 32]
#merge_method: slerp
#base_model: liminerity/M7-7b
#parameters:
#  t:
#    - filter: self_attn
#      value: [0.10671682864418519, 0.2587429682722914, 0.7254855120576987, 0.36811557880904033, 0.01600047241283964]
#    - filter: mlp
#      value: [0.8932831713558148, 0.7412570317277086, 0.6318844211909597, 0.6318844211909597, 0.9839995275871604]
#    - value: 0.6580019418208543
#dtype: bfloat16
#random_seed: 0

#slices:
#  - sources:
#      - model: psmathur/orca_mini_v3_13b
#        layer_range: [0, 40]
#      - model: garage-bAInd/Platypus2-7b 
#        layer_range: [0, 32]
#merge_method: slerp
#base_model: psmathur/orca_mini_v3_13b
#parameters:
#  t:
#    - filter: self_attn
#      value: [0.10671682864418519, 0.2587429682722914, 0.7254855120576987, 0.36811557880904033, 0.01600047241283964]
#    - filter: mlp
#      value: [0.8932831713558148, 0.7412570317277086, 0.27451448794230127, 0.6318844211909597, 0.9839995275871604]
#    - value: 0.6580019418208543
#dtype: float16
#random_seed: 0

#slices:
#  - sources:
#    - model: psmathur/orca_mini_v3_13b
#      parameters:
#        density: [1, 0.7, 0.1] # density gradient
#        weight: 1.0
#    - model: garage-bAInd/Platypus2-13B
#      parameters:
#        density: 0.5
#        weight: [0, 0.3, 0.7, 1] # weight gradient
#    - model: WizardLM/WizardMath-13B-V1.0
#      parameters:
#        density: 0.33
#        weight:
#          - filter: mlp
#            value: 0.5
#          - value: 0
#merge_method: ties
#base_model: TheBloke/Llama-2-13B-fp16
#parameters:
#  normalize: true
#  int8_mask: true
#dtype: float16
#random_seed: 0

base_model: mlabonne/AlphaMonarch-7B
experts:
  - source_model: mlabonne/AlphaMonarch-7B
    positive_prompts:
    - "chat"
    - "assistant"
    - "tell me"
    - "explain"
    - "I want"
  - source_model: TheBloke/Llama-2-13B-fp16
    positive_prompts:
    - "reason"
    - "math"
    - "mathematics"
    - "solve"
    - "count"
    ```
## 💻 Usage
```python
!pip install -qU transformers accelerate
from transformers import AutoTokenizer
import transformers
import torch
model = "EthanLiu1991/Merged_model_MoE"
messages = [{"role": "user", "content": "What is a large language model?"}]
tokenizer = AutoTokenizer.from_pretrained(model)
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
pipeline = transformers.pipeline(
    "text-generation",
    model=model,
    torch_dtype=torch.float16,
    device_map="auto",
)
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
print(outputs[0]["generated_text"])
```