File size: 8,900 Bytes
11addf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
---
base_model:
- nitky/Oumuamua-7b-base
- stabilityai/japanese-stablelm-base-gamma-7b
- tokyotech-llm/Swallow-MS-7b-v0.1
- DataPilot/ArrowPro-7B-KillerWhale
- nitky/RP-7b-instruct
- mistralai/Mistral-7B-Instruct-v0.3
- mistralai/Mistral-7B-v0.1
library_name: transformers
tags:
- mergekit
- merge
language:
  - ja
  - en
pipeline_tag: text-generation
license: apache-2.0
---
# Oumuamua-7b-instruct

This is a merge of pre-trained language models created using [mergekit](https://github.com/cg123/mergekit).

## Output example

```
[INST] <<SYS>>
ใ‚ใชใŸใฏๆ—ฅๆœฌ่ชžใ‚’่ฉฑใ™ๅ„ช็ง€ใชใ‚ขใ‚ทใ‚นใ‚ฟใƒณใƒˆใงใ™ใ€‚ๅ›ž็ญ”ใซใฏๅฟ…ใšๆ—ฅๆœฌ่ชžใง็ญ”ใˆใฆใใ ใ•ใ„ใ€‚ใพใŸ่€ƒใˆใ‚‹้Ž็จ‹ใ‚‚ๅ‡บๅŠ›ใ—ใฆใใ ใ•ใ„ใ€‚
<</SYS>>

้“่ทฏใงๆณฃใ„ใฆใ„ใ‚‹ๅญไพ›ใŒใ„ใพใ™ใ€‚ใใฎๅญไพ›ใซใฏไฝ•ใŒใ‚ใฃใŸใจ่€ƒใˆใ‚‰ใ‚Œใพใ™ใ‹๏ผŸ [/INST] ้“่ทฏใงๆณฃใ„ใฆใ„ใ‚‹ๅญไพ›ใŒใ„ใ‚‹ๅ ดๅˆใ€่€ƒใˆใ‚‰ใ‚Œใ‚‹็†็”ฑใฏใ„ใใคใ‹ใ‚ใ‚Šใพใ™ใ€‚

1. ๆ€ชๆˆ‘ใ‚’ใ—ใŸ: ่ปขใ‚“ใงๆ€ชๆˆ‘ใ‚’ใ—ใŸใ‚Šใ€ไฝ•ใ‹ใซใถใคใ‹ใฃใฆ็—›ใฟใ‚’ๆ„Ÿใ˜ใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
2. ่ฟทๅญใซใชใฃใŸ: ่ฆชใ‚„ไฟ่ญท่€…ใจใฏใใ‚Œใฆใ—ใพใฃใŸใ€ใพใŸใฏ้“ใซ่ฟทใฃใฆไธๅฎ‰ใซใชใฃใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
3. ใŠ่…นใŒ็ฉบใ„ใŸ: ้•ทๆ™‚้–“้ฃŸไบ‹ใ‚’ใ—ใฆใ„ใชใ„ใ€ใพใŸใฏใŠ่…นใŒ็ฉบใ„ใฆใ„ใ‚‹ใŸใ‚ใซๆณฃใ„ใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
4. ็–ฒใ‚ŒใŸ: ้•ทๆ™‚้–“ๆญฉใ„ใฆใ„ใŸใ‚Šใ€้Šใณ็–ฒใ‚Œใฆ็–ฒใ‚Œใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
5. ๅฏ‚ใ—ใ‹ใฃใŸ: ไธ€ไบบใงใ„ใ‚‹ใ“ใจใซๅฏ‚ใ—ใ•ใ‚’ๆ„Ÿใ˜ใฆใ„ใ‚‹ใ€ใพใŸใฏ่ฆชใ‚„ๅ‹้”ใŒใ„ใชใใฆๅฏ‚ใ—ใ„ใจๆ„Ÿใ˜ใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
6. ๆ€–ใ„ๆ€ใ„ใ‚’ใ—ใŸ: ่ปŠใ‚„ไธๅฏฉ่€…ใซ้ญ้‡ใ—ใŸใ€ใพใŸใฏไฝ•ใ‹ใซ้ฉšใ„ใŸๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
7. ไฝ“่ชฟใŒๆ‚ชใ„: ็™บ็†ฑใ‚„้ ญ็—›ใ€ๅใๆฐ—ใชใฉใฎไฝ“่ชฟไธ่‰ฏใ‚’ๆ„Ÿใ˜ใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
8. ใƒˆใ‚คใƒฌใซ่กŒใใŸใ„: ใŠใ‚€ใคใŒๆฟกใ‚Œใฆใ„ใŸใ‚Šใ€ใƒˆใ‚คใƒฌใซ่กŒใใŸใใฆๆณฃใ„ใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚
9. ไฝ•ใ‹ใ‚’ๆฑ‚ใ‚ใฆใ„ใ‚‹: ๆณจๆ„ใ‚’ๅผ•ใใŸใ‹ใฃใŸใ‚Šใ€ๅŠฉใ‘ใ‚’ๆฑ‚ใ‚ใฆใ„ใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚Šใพใ™ใ€‚

ๅญไพ›ใฎ็Šถๆณใ‚’ใ‚ˆใ่ฆณๅฏŸใ—ใ€ๅฃฐใ‚’ใ‹ใ‘ใฆ่ฉฑใ‚’่žใ„ใฆใฟใ‚‹ใ“ใจใŒๅคงๅˆ‡ใงใ™ใ€‚ๅฟ…่ฆใซๅฟœใ˜ใฆใ€ไฟ่ญท่€…ใ‚„่ญฆๅฏŸใ€ๆ•‘ๆ€ฅ่ปŠใ‚’ๅ‘ผใถใชใฉใฎๅฏพๅฟœใ‚’ใ™ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ใ‹ใ‚‚ใ—ใ‚Œใพใ›ใ‚“ใ€‚
```

## Test environment

This model was tested using [text-generation-webui](https://github.com/oobabooga/text-generation-webui/tree/main). I use preset `min_p` and `Null preset` with temperature=0.3 for Generation.


## Usage

This format must be adhered to strictly, as deviations may result in less optimal outputs from the model.

The template used to construct a prompt for the Instruct model is specified as follows:

```
<s>[INST] <<SYS>>\n{SYSTEM_PROMPT}\n<</SYS>>\n\n{USER_MESSAGE_1} [/INST] {BOT_MESSAGE_1}</s>[INST] {USER_MESSAGE_2} [/INST] 
```


Please be aware that ``<s>`` and ``</s>`` are special tokens used for the beginning of string (BOS) and end of string (EOS), respectively, while [INST] and [/INST] are considered regular strings.

For the "{SYSTEM_PROMPT}" part, We recommend using "ใ‚ใชใŸใฏๆ—ฅๆœฌ่ชžใ‚’่ฉฑใ™ๅ„ช็ง€ใชใ‚ขใ‚ทใ‚นใ‚ฟใƒณใƒˆใงใ™ใ€‚ๅ›ž็ญ”ใซใฏๅฟ…ใšๆ—ฅๆœฌ่ชžใง็ญ”ใˆใฆใใ ใ•ใ„ใ€‚ใพใŸ่€ƒใˆใ‚‹้Ž็จ‹ใ‚‚ๅ‡บๅŠ›ใ—ใฆใใ ใ•ใ„ใ€‚"

For the "{USER_MESSAGE_1}" part, We recommend using {instruction}\n{input}

In other words, We recommend the following:

``` 
<s>[INST] <<SYS>>\nใ‚ใชใŸใฏๆ—ฅๆœฌ่ชžใ‚’่ฉฑใ™ๅ„ช็ง€ใชใ‚ขใ‚ทใ‚นใ‚ฟใƒณใƒˆใงใ™ใ€‚ๅ›ž็ญ”ใซใฏๅฟ…ใšๆ—ฅๆœฌ่ชžใง็ญ”ใˆใฆใใ ใ•ใ„ใ€‚ใพใŸ่€ƒใˆใ‚‹้Ž็จ‹ใ‚‚ๅ‡บๅŠ›ใ—ใฆใใ ใ•ใ„ใ€‚\n<</SYS>>\n\n{instruction1}\n{input1} [/INST] {BOT_MESSAGE_1}</s>[INST] {instruction2}\n{input2} [/INST] 
```

### Use the instruct model

```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "nitky/Oumuamua-7b-instruct"
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)

device = "cuda"

messages = [
    {"role": "system", "content": "ใ‚ใชใŸใฏๆ—ฅๆœฌ่ชžใ‚’่ฉฑใ™ๅ„ช็ง€ใชใ‚ขใ‚ทใ‚นใ‚ฟใƒณใƒˆใงใ™ใ€‚ๅ›ž็ญ”ใซใฏๅฟ…ใšๆ—ฅๆœฌ่ชžใง็ญ”ใˆใฆใใ ใ•ใ„ใ€‚ใพใŸ่€ƒใˆใ‚‹้Ž็จ‹ใ‚‚ๅ‡บๅŠ›ใ—ใฆใใ ใ•ใ„ใ€‚"},
    {"role": "user", "content": "้“่ทฏใงๆณฃใ„ใฆใ„ใ‚‹ๅญไพ›ใŒใ„ใพใ™ใ€‚ใใฎๅญไพ›ใซใฏไฝ•ใŒใ‚ใฃใŸใจ่€ƒใˆใ‚‰ใ‚Œใพใ™ใ‹๏ผŸ"}
]

encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")

model_inputs = encodeds.to(device)
model.to(device)

generated_ids = model.generate(model_inputs, max_new_tokens=256, do_sample=True, temperature=0.3)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])
```

## Merge Details
### Merge Method

This model was merged using the [Model Stock](https://arxiv.org/abs/2403.19522) merge method using [nitky/Oumuamua-7b-base](https://huggingface.co/nitky/Oumuamua-7b-base) as a base.

### Models Merged

The following models were included in the merge:
* [stabilityai/japanese-stablelm-base-gamma-7b](https://huggingface.co/stabilityai/japanese-stablelm-base-gamma-7b)
* [tokyotech-llm/Swallow-MS-7b-v0.1](https://huggingface.co/tokyotech-llm/Swallow-MS-7b-v0.1)
* [DataPilot/ArrowPro-7B-KillerWhale](https://huggingface.co/DataPilot/ArrowPro-7B-KillerWhale)
* [nitky/RP-7b-instruct](https://huggingface.co/nitky/RP-7b-instruct)
* [mistralai/Mistral-7B-Instruct-v0.3](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3)
* [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1)

### Configuration

The following YAML configuration was used to produce this model:

```yaml
merge_method: task_arithmetic
base_model: mistralai/Mistral-7B-v0.1
models:
  - model: tokyotech-llm/Swallow-MS-7b-v0.1
    parameters:
      weight:
      - filter: embed_tokens
        value: 1.0
      - value: 0
dtype: bfloat16
tokenizer_source: model:tokyotech-llm/Swallow-MS-7b-v0.1
name: Mistral-7B-v0.1-VE-Swallow-MS
---
merge_method: task_arithmetic
base_model: stabilityai/japanese-stablelm-base-gamma-7b
models:
  - model: tokyotech-llm/Swallow-MS-7b-v0.1
    parameters:
      weight:
      - filter: embed_tokens
        value: 1.0
      - value: 0
dtype: bfloat16
tokenizer_source: model:tokyotech-llm/Swallow-MS-7b-v0.1
name: japanese-stablelm-base-gamma-7b-VE-Swallow-MS
---
merge_method: task_arithmetic
base_model: DataPilot/ArrowPro-7B-KillerWhale
models:
  - model: tokyotech-llm/Swallow-MS-7b-v0.1
    parameters:
      weight:
      - filter: embed_tokens
        value: 1.0
      - value: 0
dtype: bfloat16
tokenizer_source: model:tokyotech-llm/Swallow-MS-7b-v0.1
name: ArrowPro-7B-KillerWhale-VE-Swallow-MS
---
merge_method: task_arithmetic
base_model: nitky/RP-7b-instruct
models:
  - model: tokyotech-llm/Swallow-MS-7b-v0.1
    parameters:
      weight:
      - filter: embed_tokens
        value: 1.0
      - value: 0
dtype: bfloat16
tokenizer_source: model:tokyotech-llm/Swallow-MS-7b-v0.1
name: RP-7b-instruct-VE-Swallow-MS
---
merge_method: task_arithmetic
base_model: mistralai/Mistral-7B-Instruct-v0.3
models:
  - model: tokyotech-llm/Swallow-MS-7b-v0.1
    parameters:
      weight:
      - filter: embed_tokens
        value: 1.0
      - value: 0
dtype: bfloat16
tokenizer_source: model:tokyotech-llm/Swallow-MS-7b-v0.1
name: Mistral-7B-Instruct-v0.3-VE-Swallow-MS
---
merge_method: linear
models:
  - model: nitky/Oumuamua-7b-base
    parameters:
      weight: 1.0
  - model: tokyotech-llm/Swallow-MS-7b-instruct-v0.1
    parameters:
      weight: 0.8
  - model: tokyotech-llm/Swallow-MS-7b-v0.1
    parameters:
      weight: -0.8
  - model: Mistral-7B-Instruct-v0.3-VE-Swallow-MS
    parameters:
      weight: 0.8
  - model: Mistral-7B-v0.1-VE-Swallow-MS
    parameters:
      weight: -0.8
dtype: bfloat16
name: Oumuamua-7b-instruct-alpha
---
merge_method: linear
models:
  - model: nitky/Oumuamua-7b-base
    parameters:
      weight: 1.0
  - model: ArrowPro-7B-KillerWhale-VE-Swallow-MS # include Mistral-7B-Instruct-v0.3
    parameters:
      weight: 0.8
  - model: japanese-stablelm-base-gamma-7b-VE-Swallow-MS
    parameters:
      weight: -0.8
dtype: bfloat16
name: Oumuamua-7b-instruct-beta
---
merge_method: linear
models:
  - model: nitky/Oumuamua-7b-base
    parameters:
      weight: 1.0
  - model: RP-7b-instruct-VE-Swallow-MS
    parameters:
      weight: 0.8
  - model: japanese-stablelm-base-gamma-7b-VE-Swallow-MS
    parameters:
      weight: -0.8
  - model: Mistral-7B-Instruct-v0.3-VE-Swallow-MS
    parameters:
      weight: 0.8
  - model: Mistral-7B-v0.1-VE-Swallow-MS
    parameters:
      weight: -0.8
dtype: bfloat16
name: Oumuamua-7b-instruct-gamma
---
merge_method: model_stock
base_model: nitky/Oumuamua-7b-base
models:
  - model: Oumuamua-7b-instruct-alpha
  - model: Oumuamua-7b-instruct-beta
  - model: Oumuamua-7b-instruct-gamma
dtype: bfloat16
name: Oumuamua-7b-instruct
```