TheBloke commited on
Commit
e218dff
1 Parent(s): 2b86a29

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +527 -0
README.md ADDED
@@ -0,0 +1,527 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: tokyotech-llm/Swallow-7b-instruct-hf
3
+ inference: false
4
+ language:
5
+ - en
6
+ - ja
7
+ library_name: transformers
8
+ license: llama2
9
+ model_creator: tokyotech-llm
10
+ model_name: Swallow 7B Instruct
11
+ model_type: llama
12
+ pipeline_tag: text-generation
13
+ prompt_template: "\u4EE5\u4E0B\u306B\u3001\u3042\u308B\u30BF\u30B9\u30AF\u3092\u8AAC\
14
+ \u660E\u3059\u308B\u6307\u793A\u304C\u3042\u308A\u307E\u3059\u3002\u30EA\u30AF\u30A8\
15
+ \u30B9\u30C8\u3092\u9069\u5207\u306B\u5B8C\u4E86\u3059\u308B\u305F\u3081\u306E\u56DE\
16
+ \u7B54\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\\n\\n### \u6307\
17
+ \u793A:\\n{prompt}\\n\\n### \u5FDC\u7B54:\n"
18
+ quantized_by: TheBloke
19
+ ---
20
+ <!-- markdownlint-disable MD041 -->
21
+
22
+ <!-- header start -->
23
+ <!-- 200823 -->
24
+ <div style="width: auto; margin-left: auto; margin-right: auto">
25
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
26
+ </div>
27
+ <div style="display: flex; justify-content: space-between; width: 100%;">
28
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
29
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
30
+ </div>
31
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
32
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
33
+ </div>
34
+ </div>
35
+ <div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
36
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
37
+ <!-- header end -->
38
+
39
+ # Swallow 7B Instruct - GGUF
40
+ - Model creator: [tokyotech-llm](https://huggingface.co/tokyotech-llm)
41
+ - Original model: [Swallow 7B Instruct](https://huggingface.co/tokyotech-llm/Swallow-7b-instruct-hf)
42
+
43
+ <!-- description start -->
44
+ ## Description
45
+
46
+ This repo contains GGUF format model files for [tokyotech-llm's Swallow 7B Instruct](https://huggingface.co/tokyotech-llm/Swallow-7b-instruct-hf).
47
+
48
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
49
+
50
+ <!-- description end -->
51
+ <!-- README_GGUF.md-about-gguf start -->
52
+ ### About GGUF
53
+
54
+ GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp.
55
+
56
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
57
+
58
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
59
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
60
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
61
+ * [GPT4All](https://gpt4all.io/index.html), a free and open source local running GUI, supporting Windows, Linux and macOS with full GPU accel.
62
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration. Linux available, in beta as of 27/11/2023.
63
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui), a great web UI with many interesting and unique features, including a full model library for easy model selection.
64
+ * [Faraday.dev](https://faraday.dev/), an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
65
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
66
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
67
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server. Note, as of time of writing (November 27th 2023), ctransformers has not been updated in a long time and does not support many recent models.
68
+
69
+ <!-- README_GGUF.md-about-gguf end -->
70
+ <!-- repositories-available start -->
71
+ ## Repositories available
72
+
73
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Swallow-7B-Instruct-AWQ)
74
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GPTQ)
75
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF)
76
+ * [tokyotech-llm's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/tokyotech-llm/Swallow-7b-instruct-hf)
77
+ <!-- repositories-available end -->
78
+
79
+ <!-- prompt-template start -->
80
+ ## Prompt template: Swallow-Instruct
81
+
82
+ ```
83
+ 以下に、あるタスクを説明する指示があります。リクエストを適切に完了するための回答を記述してください。\n\n### 指示:\n{prompt}\n\n### 応答:
84
+
85
+ ```
86
+
87
+ <!-- prompt-template end -->
88
+
89
+
90
+ <!-- compatibility_gguf start -->
91
+ ## Compatibility
92
+
93
+ These quantised GGUFv2 files are compatible with llama.cpp from August 27th onwards, as of commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221)
94
+
95
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
96
+
97
+ ## Explanation of quantisation methods
98
+
99
+ <details>
100
+ <summary>Click to see details</summary>
101
+
102
+ The new methods available are:
103
+
104
+ * GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
105
+ * GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
106
+ * GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
107
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
108
+ * GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw
109
+
110
+ Refer to the Provided Files table below to see what files use which methods, and how.
111
+ </details>
112
+ <!-- compatibility_gguf end -->
113
+
114
+ <!-- README_GGUF.md-provided-files start -->
115
+ ## Provided files
116
+
117
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
118
+ | ---- | ---- | ---- | ---- | ---- | ----- |
119
+ | [swallow-7b-instruct.Q2_K.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q2_K.gguf) | Q2_K | 2 | 2.88 GB| 5.38 GB | smallest, significant quality loss - not recommended for most purposes |
120
+ | [swallow-7b-instruct.Q3_K_S.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q3_K_S.gguf) | Q3_K_S | 3 | 3.01 GB| 5.51 GB | very small, high quality loss |
121
+ | [swallow-7b-instruct.Q3_K_M.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q3_K_M.gguf) | Q3_K_M | 3 | 3.36 GB| 5.86 GB | very small, high quality loss |
122
+ | [swallow-7b-instruct.Q3_K_L.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q3_K_L.gguf) | Q3_K_L | 3 | 3.65 GB| 6.15 GB | small, substantial quality loss |
123
+ | [swallow-7b-instruct.Q4_0.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q4_0.gguf) | Q4_0 | 4 | 3.89 GB| 6.39 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
124
+ | [swallow-7b-instruct.Q4_K_S.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q4_K_S.gguf) | Q4_K_S | 4 | 3.92 GB| 6.42 GB | small, greater quality loss |
125
+ | [swallow-7b-instruct.Q4_K_M.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q4_K_M.gguf) | Q4_K_M | 4 | 4.14 GB| 6.64 GB | medium, balanced quality - recommended |
126
+ | [swallow-7b-instruct.Q5_0.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q5_0.gguf) | Q5_0 | 5 | 4.72 GB| 7.22 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
127
+ | [swallow-7b-instruct.Q5_K_S.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q5_K_S.gguf) | Q5_K_S | 5 | 4.72 GB| 7.22 GB | large, low quality loss - recommended |
128
+ | [swallow-7b-instruct.Q5_K_M.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q5_K_M.gguf) | Q5_K_M | 5 | 4.85 GB| 7.35 GB | large, very low quality loss - recommended |
129
+ | [swallow-7b-instruct.Q6_K.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q6_K.gguf) | Q6_K | 6 | 5.60 GB| 8.10 GB | very large, extremely low quality loss |
130
+ | [swallow-7b-instruct.Q8_0.gguf](https://huggingface.co/TheBloke/Swallow-7B-Instruct-GGUF/blob/main/swallow-7b-instruct.Q8_0.gguf) | Q8_0 | 8 | 7.26 GB| 9.76 GB | very large, extremely low quality loss - not recommended |
131
+
132
+ **Note**: the above RAM figures assume no GPU offloading. If layers are offloaded to the GPU, this will reduce RAM usage and use VRAM instead.
133
+
134
+
135
+
136
+ <!-- README_GGUF.md-provided-files end -->
137
+
138
+ <!-- README_GGUF.md-how-to-download start -->
139
+ ## How to download GGUF files
140
+
141
+ **Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.
142
+
143
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
144
+
145
+ * LM Studio
146
+ * LoLLMS Web UI
147
+ * Faraday.dev
148
+
149
+ ### In `text-generation-webui`
150
+
151
+ Under Download Model, you can enter the model repo: TheBloke/Swallow-7B-Instruct-GGUF and below it, a specific filename to download, such as: swallow-7b-instruct.Q4_K_M.gguf.
152
+
153
+ Then click Download.
154
+
155
+ ### On the command line, including multiple files at once
156
+
157
+ I recommend using the `huggingface-hub` Python library:
158
+
159
+ ```shell
160
+ pip3 install huggingface-hub
161
+ ```
162
+
163
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
164
+
165
+ ```shell
166
+ huggingface-cli download TheBloke/Swallow-7B-Instruct-GGUF swallow-7b-instruct.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
167
+ ```
168
+
169
+ <details>
170
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
171
+
172
+ You can also download multiple files at once with a pattern:
173
+
174
+ ```shell
175
+ huggingface-cli download TheBloke/Swallow-7B-Instruct-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
176
+ ```
177
+
178
+ For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
179
+
180
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
181
+
182
+ ```shell
183
+ pip3 install hf_transfer
184
+ ```
185
+
186
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
187
+
188
+ ```shell
189
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/Swallow-7B-Instruct-GGUF swallow-7b-instruct.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
190
+ ```
191
+
192
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
193
+ </details>
194
+ <!-- README_GGUF.md-how-to-download end -->
195
+
196
+ <!-- README_GGUF.md-how-to-run start -->
197
+ ## Example `llama.cpp` command
198
+
199
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
200
+
201
+ ```shell
202
+ ./main -ngl 35 -m swallow-7b-instruct.Q4_K_M.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "以下に、あるタスクを説明する指示があります。リクエストを適切に完了するための回答を記述してください。\n\n### 指示:\n{prompt}\n\n### 応答:"
203
+ ```
204
+
205
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
206
+
207
+ Change `-c 4096` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
208
+
209
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
210
+
211
+ For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
212
+
213
+ ## How to run in `text-generation-webui`
214
+
215
+ Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
216
+
217
+ ## How to run from Python code
218
+
219
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) or [ctransformers](https://github.com/marella/ctransformers) libraries. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.
220
+
221
+ ### How to load this model in Python code, using llama-cpp-python
222
+
223
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
224
+
225
+ #### First install the package
226
+
227
+ Run one of the following commands, according to your system:
228
+
229
+ ```shell
230
+ # Base ctransformers with no GPU acceleration
231
+ pip install llama-cpp-python
232
+ # With NVidia CUDA acceleration
233
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
234
+ # Or with OpenBLAS acceleration
235
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
236
+ # Or with CLBLast acceleration
237
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
238
+ # Or with AMD ROCm GPU acceleration (Linux only)
239
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
240
+ # Or with Metal GPU acceleration for macOS systems only
241
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
242
+
243
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
244
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
245
+ pip install llama-cpp-python
246
+ ```
247
+
248
+ #### Simple llama-cpp-python example code
249
+
250
+ ```python
251
+ from llama_cpp import Llama
252
+
253
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
254
+ llm = Llama(
255
+ model_path="./swallow-7b-instruct.Q4_K_M.gguf", # Download the model file first
256
+ n_ctx=4096, # The max sequence length to use - note that longer sequence lengths require much more resources
257
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
258
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
259
+ )
260
+
261
+ # Simple inference example
262
+ output = llm(
263
+ "以下に、あるタスクを説明する指示があります。リクエストを適切に完了するための回答を記述してください。\n\n### 指示:\n{prompt}\n\n### 応答:", # Prompt
264
+ max_tokens=512, # Generate up to 512 tokens
265
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
266
+ echo=True # Whether to echo the prompt
267
+ )
268
+
269
+ # Chat Completion API
270
+
271
+ llm = Llama(model_path="./swallow-7b-instruct.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
272
+ llm.create_chat_completion(
273
+ messages = [
274
+ {"role": "system", "content": "You are a story writing assistant."},
275
+ {
276
+ "role": "user",
277
+ "content": "Write a story about llamas."
278
+ }
279
+ ]
280
+ )
281
+ ```
282
+
283
+ ## How to use with LangChain
284
+
285
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
286
+
287
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
288
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
289
+
290
+ <!-- README_GGUF.md-how-to-run end -->
291
+
292
+ <!-- footer start -->
293
+ <!-- 200823 -->
294
+ ## Discord
295
+
296
+ For further support, and discussions on these models and AI in general, join us at:
297
+
298
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
299
+
300
+ ## Thanks, and how to contribute
301
+
302
+ Thanks to the [chirper.ai](https://chirper.ai) team!
303
+
304
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
305
+
306
+ I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
307
+
308
+ If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
309
+
310
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
311
+
312
+ * Patreon: https://patreon.com/TheBlokeAI
313
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
314
+
315
+ **Special thanks to**: Aemon Algiz.
316
+
317
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
318
+
319
+
320
+ Thank you to all my generous patrons and donaters!
321
+
322
+ And thank you again to a16z for their generous grant.
323
+
324
+ <!-- footer end -->
325
+
326
+ <!-- original-model-card start -->
327
+ # Original model card: tokyotech-llm's Swallow 7B Instruct
328
+
329
+
330
+ # Swallow
331
+
332
+ Our Swallow model has undergone continuous pre-training from the Llama 2 family, primarily with the addition of Japanese language data. The tuned versions use supervised fine-tuning (SFT).
333
+ Links to other models can be found in the index.
334
+
335
+ ## Swallow Model Index
336
+ |Model|Swallow-hf|Swallow-instruct-hf|
337
+ |---|---|---|
338
+ |7B| [Link](https://huggingface.co/tokyotech-llm/Swallow-7b-hf) | [Link](https://huggingface.co/tokyotech-llm/Swallow-7b-instruct-hf)|
339
+ |13B| [Link](https://huggingface.co/tokyotech-llm/Swallow-13b-hf) | [Link](https://huggingface.co/tokyotech-llm/Swallow-13b-instruct-hf)|
340
+ |70B| [Link](https://huggingface.co/tokyotech-llm/Swallow-70b-hf) | [Link](https://huggingface.co/tokyotech-llm/Swallow-70b-instruct-hf)|
341
+
342
+
343
+ ![logo](./logo.png)
344
+
345
+ This repository provides large language models developed by [TokyoTech-LLM](https://tokyotech-llm.github.io/).
346
+ Read our [blog post](https://zenn.dev/tokyotech_lm/articles/d6cb3a8fdfc907) or our paper (preprint coming soon) for more details!
347
+
348
+
349
+ ## Model Details
350
+
351
+ * **Model type**: Please refer to LLaMA-2 technical report for details on the model architecture.
352
+ * **Language(s)**: Japanese English
353
+ * **Library**: [Megatron-LM](https://github.com/rioyokotalab/Megatron-Llama2)
354
+ * **Tokenizer**: This model employs a tokenizer that features a broadened vocabulary based on Japanese data. This allows for a more efficient representation of text using fewer tokens, leading to a notably faster inference process.
355
+ * **Contact**: swallow[at]nlp.c.titech.ac.jp
356
+
357
+ ## Base Model Performance
358
+
359
+ ### Japanese version
360
+
361
+ |Model|Size|JCommonsenseQA|JEMHopQA|NIILC|JSQuAD|XL-Sum|MGSM|WMT20-en-ja|WMT20-ja-en|
362
+ |---|---|---|---|---|---|---|---|---|---|
363
+ | | |4-shot|4-shot|4-shot|4-shot|1-shot|4-shot|4-shot|4-shot|
364
+ |Llama 2|7B|0.3852|0.4240|0.3410|0.7917|0.1905|0.0760|0.1783|0.1738|
365
+ |Swallow|7B|0.4808|0.5078|0.5968|0.8573|0.1830|0.1240|0.2510|0.1511|
366
+ |Llama 2|13B|0.6997|0.4415|0.4170|0.8533|0.2139|0.1320|0.2146|0.1982|
367
+ |Swallow|13B|0.7837|0.5063|0.6398|0.9005|0.2168|0.2040|0.2720|0.1771|
368
+ |Llama 2|70B|0.8686|0.4656|0.5256|0.9080|**0.2361**|0.3560|0.2643|**0.2398**|
369
+ |Swallow|70B|**0.9348**|**0.6290**|**0.6960**|**0.9176**|0.2266|**0.4840**|**0.3043**|0.2298|
370
+
371
+ ## Usage
372
+
373
+ First install additional dependencies in [requirements.txt](./requirements.txt):
374
+
375
+ ```sh
376
+ pip install -r requirements.txt
377
+ ```
378
+
379
+ ### Use the instruct model
380
+
381
+ ```python
382
+ import torch
383
+ from transformers import AutoTokenizer, AutoModelForCausalLM
384
+
385
+ model_name = "tokyotech-llm/Swallow-7b-instruct-hf"
386
+
387
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
388
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, device_map="auto")
389
+
390
+
391
+ PROMPT_DICT = {
392
+ "prompt_input": (
393
+ "以下に、あるタスクを説明する指示があり、それに付随する入力が更なる文脈を提供しています。"
394
+ "リクエストを適切に完了するための回答を記述してください。\n\n"
395
+ "### 指示:\n{instruction}\n\n### 入力:\n{input}\n\n### 応答:"
396
+
397
+ ),
398
+ "prompt_no_input": (
399
+ "以下に、あるタスクを説明する指示があります。"
400
+ "リクエストを適切に完了するための回答を記述してください。\n\n"
401
+ "### 指示:\n{instruction}\n\n### 応答:"
402
+ ),
403
+ }
404
+
405
+ def create_prompt(instruction, input=None):
406
+ """
407
+ Generates a prompt based on the given instruction and an optional input.
408
+ If input is provided, it uses the 'prompt_input' template from PROMPT_DICT.
409
+ If no input is provided, it uses the 'prompt_no_input' template.
410
+
411
+ Args:
412
+ instruction (str): The instruction describing the task.
413
+ input (str, optional): Additional input providing context for the task. Default is None.
414
+
415
+ Returns:
416
+ str: The generated prompt.
417
+ """
418
+ if input:
419
+ # Use the 'prompt_input' template when additional input is provided
420
+ return PROMPT_DICT["prompt_input"].format(instruction=instruction, input=input)
421
+ else:
422
+ # Use the 'prompt_no_input' template when no additional input is provided
423
+ return PROMPT_DICT["prompt_no_input"].format(instruction=instruction)
424
+
425
+ # Example usage
426
+ instruction_example = "以下のトピックに関する詳細な情報を提供してください。"
427
+ input_example = "東京工業大学の主なキャンパスについて教えてください"
428
+ prompt = create_prompt(instruction_example, input_example)
429
+
430
+ input_ids = tokenizer.encode(
431
+ prompt,
432
+ add_special_tokens=False,
433
+ return_tensors="pt"
434
+ )
435
+
436
+ tokens = model.generate(
437
+ input_ids.to(device=model.device),
438
+ max_new_tokens=128,
439
+ temperature=0.99,
440
+ top_p=0.95,
441
+ do_sample=True,
442
+ )
443
+
444
+ out = tokenizer.decode(tokens[0], skip_special_tokens=True)
445
+ print(out)
446
+
447
+ ```
448
+
449
+ ### Use the base model
450
+
451
+ ```python
452
+ import torch
453
+ from transformers import AutoTokenizer, AutoModelForCausalLM
454
+
455
+ model_name = "tokyotech-llm/Swallow-7b-hf"
456
+
457
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
458
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
459
+
460
+ prompt = "東京工業大学の主なキャンパスは、"
461
+ input_ids = tokenizer.encode(
462
+ prompt,
463
+ add_special_tokens=False,
464
+ return_tensors="pt"
465
+ )
466
+ tokens = model.generate(
467
+ input_ids.to(device=model.device),
468
+ max_new_tokens=128,
469
+ temperature=0.99,
470
+ top_p=0.95,
471
+ do_sample=True,
472
+ )
473
+
474
+ out = tokenizer.decode(tokens[0], skip_special_tokens=True)
475
+ print(out)
476
+ ```
477
+
478
+ ## Training Datasets
479
+
480
+ ### Continual Pre-Training
481
+ The following datasets were used for continual pre-training.
482
+
483
+ - [Japanese Wikipedia](https://dumps.wikimedia.org/other/cirrussearch)
484
+ - [RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)
485
+ - Swallow Corpus
486
+ - [The Pile](https://huggingface.co/datasets/EleutherAI/pile)
487
+
488
+
489
+ ### Instruction Tuning
490
+
491
+ The following datasets were used for the instruction tuning.
492
+
493
+ - [Anthropic HH-RLHF](https://huggingface.co/datasets/kunishou/hh-rlhf-49k-ja)
494
+ - [Databricks Dolly 15-k](https://huggingface.co/datasets/kunishou/databricks-dolly-15k-ja)
495
+ - [OpenAssistant Conversations Dataset](https://huggingface.co/datasets/kunishou/oasst1-89k-ja)
496
+
497
+ ## Risks and Limitations
498
+
499
+ The models released here are still in the early stages of our research and development and have not been tuned to ensure outputs align with human intent and safety considerations.
500
+
501
+ ## Acknowledgements
502
+
503
+ We thank Meta Research for releasing Llama 2 under an open license for others to build on.
504
+
505
+ Our project is supported by the [ABCI Large-scale Language Model Building Support Program](https://abci.ai/en/link/llm_support_program.html) of the National Institute of Advanced Industrial Science and Technology.
506
+
507
+ ## License
508
+
509
+ Llama 2 is licensed under the LLAMA 2 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.
510
+
511
+ ## Authors
512
+
513
+ Here are the team members:
514
+ - From [Okazaki Laboratory](https://www.nlp.c.titech.ac.jp/index.en.html), the following members:
515
+ - [Naoaki Okazaki](https://www.chokkan.org/index.ja.html)
516
+ - [Sakae Mizuki](https://s-mizuki-nlp.github.io/)
517
+ - [Hiroki Iida](https://meshidenn.github.io/)
518
+ - [Mengsay Loem](https://loem-ms.github.io/)
519
+ - [Shota Hirai](https://huggingface.co/Kotemo428)
520
+ - [Kakeru Hattori](https://aya-se.vercel.app/)
521
+ - [Masanari Ohi](https://twitter.com/stjohn2007)
522
+ - From [YOKOTA Laboratory](https://www.rio.gsic.titech.ac.jp/en/index.html), the following members:
523
+ - [Rio Yokota](https://twitter.com/rioyokota)
524
+ - [Kazuki Fujii](https://twitter.com/okoge_kaz)
525
+ - [Taishi Nakamura](https://twitter.com/Setuna7777_2)
526
+
527
+ <!-- original-model-card end -->