TheBloke commited on
Commit
0704c54
1 Parent(s): 69afd5b

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +555 -0
README.md ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: tokyotech-llm/Swallow-70b-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 70B
11
+ model_type: llama
12
+ pipeline_tag: text-generation
13
+ prompt_template: '{prompt}
14
+
15
+ '
16
+ quantized_by: TheBloke
17
+ ---
18
+ <!-- markdownlint-disable MD041 -->
19
+
20
+ <!-- header start -->
21
+ <!-- 200823 -->
22
+ <div style="width: auto; margin-left: auto; margin-right: auto">
23
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
24
+ </div>
25
+ <div style="display: flex; justify-content: space-between; width: 100%;">
26
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
27
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
28
+ </div>
29
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
30
+ <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>
31
+ </div>
32
+ </div>
33
+ <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>
34
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
35
+ <!-- header end -->
36
+
37
+ # Swallow 70B - GGUF
38
+ - Model creator: [tokyotech-llm](https://huggingface.co/tokyotech-llm)
39
+ - Original model: [Swallow 70B](https://huggingface.co/tokyotech-llm/Swallow-70b-hf)
40
+
41
+ <!-- description start -->
42
+ ## Description
43
+
44
+ This repo contains GGUF format model files for [tokyotech-llm's Swallow 70B](https://huggingface.co/tokyotech-llm/Swallow-70b-hf).
45
+
46
+ <!-- description end -->
47
+ <!-- README_GGUF.md-about-gguf start -->
48
+ ### About GGUF
49
+
50
+ 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.
51
+
52
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
53
+
54
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
55
+ * [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.
56
+ * [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.
57
+ * [GPT4All](https://gpt4all.io/index.html), a free and open source local running GUI, supporting Windows, Linux and macOS with full GPU accel.
58
+ * [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.
59
+ * [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.
60
+ * [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.
61
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
62
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
63
+ * [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.
64
+
65
+ <!-- README_GGUF.md-about-gguf end -->
66
+ <!-- repositories-available start -->
67
+ ## Repositories available
68
+
69
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Swallow-70B-AWQ)
70
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Swallow-70B-GPTQ)
71
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Swallow-70B-GGUF)
72
+ * [tokyotech-llm's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/tokyotech-llm/Swallow-70b-hf)
73
+ <!-- repositories-available end -->
74
+
75
+ <!-- prompt-template start -->
76
+ ## Prompt template: None
77
+
78
+ ```
79
+ {prompt}
80
+
81
+ ```
82
+
83
+ <!-- prompt-template end -->
84
+
85
+
86
+ <!-- compatibility_gguf start -->
87
+ ## Compatibility
88
+
89
+ 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)
90
+
91
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
92
+
93
+ ## Explanation of quantisation methods
94
+
95
+ <details>
96
+ <summary>Click to see details</summary>
97
+
98
+ The new methods available are:
99
+
100
+ * 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)
101
+ * 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.
102
+ * 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.
103
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
104
+ * 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
105
+
106
+ Refer to the Provided Files table below to see what files use which methods, and how.
107
+ </details>
108
+ <!-- compatibility_gguf end -->
109
+
110
+ <!-- README_GGUF.md-provided-files start -->
111
+ ## Provided files
112
+
113
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
114
+ | ---- | ---- | ---- | ---- | ---- | ----- |
115
+ | [swallow-70b.Q2_K.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q2_K.gguf) | Q2_K | 2 | 29.38 GB| 31.88 GB | smallest, significant quality loss - not recommended for most purposes |
116
+ | [swallow-70b.Q3_K_S.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q3_K_S.gguf) | Q3_K_S | 3 | 30.03 GB| 32.53 GB | very small, high quality loss |
117
+ | [swallow-70b.Q3_K_M.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q3_K_M.gguf) | Q3_K_M | 3 | 33.30 GB| 35.80 GB | very small, high quality loss |
118
+ | [swallow-70b.Q3_K_L.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q3_K_L.gguf) | Q3_K_L | 3 | 36.26 GB| 38.76 GB | small, substantial quality loss |
119
+ | [swallow-70b.Q4_0.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q4_0.gguf) | Q4_0 | 4 | 39.00 GB| 41.50 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
120
+ | [swallow-70b.Q4_K_S.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q4_K_S.gguf) | Q4_K_S | 4 | 39.20 GB| 41.70 GB | small, greater quality loss |
121
+ | [swallow-70b.Q4_K_M.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q4_K_M.gguf) | Q4_K_M | 4 | 41.55 GB| 44.05 GB | medium, balanced quality - recommended |
122
+ | [swallow-70b.Q5_0.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q5_0.gguf) | Q5_0 | 5 | 47.60 GB| 50.10 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
123
+ | [swallow-70b.Q5_K_S.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q5_K_S.gguf) | Q5_K_S | 5 | 47.60 GB| 50.10 GB | large, low quality loss - recommended |
124
+ | [swallow-70b.Q5_K_M.gguf](https://huggingface.co/TheBloke/Swallow-70B-GGUF/blob/main/swallow-70b.Q5_K_M.gguf) | Q5_K_M | 5 | 48.89 GB| 51.39 GB | large, very low quality loss - recommended |
125
+ | swallow-70b.Q6_K.gguf | Q6_K | 6 | 56.74 GB| 59.24 GB | very large, extremely low quality loss |
126
+ | swallow-70b.Q8_0.gguf | Q8_0 | 8 | 73.49 GB| 75.99 GB | very large, extremely low quality loss - not recommended |
127
+
128
+ **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.
129
+
130
+ ### Q6_K and Q8_0 files are split and require joining
131
+
132
+ **Note:** HF does not support uploading files larger than 50GB. Therefore I have uploaded the Q6_K and Q8_0 files as split files.
133
+
134
+ <details>
135
+ <summary>Click for instructions regarding Q6_K and Q8_0 files</summary>
136
+
137
+ ### q6_K
138
+ Please download:
139
+ * `swallow-70b.Q6_K.gguf-split-a`
140
+ * `swallow-70b.Q6_K.gguf-split-b`
141
+
142
+ ### q8_0
143
+ Please download:
144
+ * `swallow-70b.Q8_0.gguf-split-a`
145
+ * `swallow-70b.Q8_0.gguf-split-b`
146
+
147
+ To join the files, do the following:
148
+
149
+ Linux and macOS:
150
+ ```
151
+ cat swallow-70b.Q6_K.gguf-split-* > swallow-70b.Q6_K.gguf && rm swallow-70b.Q6_K.gguf-split-*
152
+ cat swallow-70b.Q8_0.gguf-split-* > swallow-70b.Q8_0.gguf && rm swallow-70b.Q8_0.gguf-split-*
153
+ ```
154
+ Windows command line:
155
+ ```
156
+ COPY /B swallow-70b.Q6_K.gguf-split-a + swallow-70b.Q6_K.gguf-split-b swallow-70b.Q6_K.gguf
157
+ del swallow-70b.Q6_K.gguf-split-a swallow-70b.Q6_K.gguf-split-b
158
+
159
+ COPY /B swallow-70b.Q8_0.gguf-split-a + swallow-70b.Q8_0.gguf-split-b swallow-70b.Q8_0.gguf
160
+ del swallow-70b.Q8_0.gguf-split-a swallow-70b.Q8_0.gguf-split-b
161
+ ```
162
+
163
+ </details>
164
+ <!-- README_GGUF.md-provided-files end -->
165
+
166
+ <!-- README_GGUF.md-how-to-download start -->
167
+ ## How to download GGUF files
168
+
169
+ **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.
170
+
171
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
172
+
173
+ * LM Studio
174
+ * LoLLMS Web UI
175
+ * Faraday.dev
176
+
177
+ ### In `text-generation-webui`
178
+
179
+ Under Download Model, you can enter the model repo: TheBloke/Swallow-70B-GGUF and below it, a specific filename to download, such as: swallow-70b.Q4_K_M.gguf.
180
+
181
+ Then click Download.
182
+
183
+ ### On the command line, including multiple files at once
184
+
185
+ I recommend using the `huggingface-hub` Python library:
186
+
187
+ ```shell
188
+ pip3 install huggingface-hub
189
+ ```
190
+
191
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
192
+
193
+ ```shell
194
+ huggingface-cli download TheBloke/Swallow-70B-GGUF swallow-70b.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
195
+ ```
196
+
197
+ <details>
198
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
199
+
200
+ You can also download multiple files at once with a pattern:
201
+
202
+ ```shell
203
+ huggingface-cli download TheBloke/Swallow-70B-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
204
+ ```
205
+
206
+ 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).
207
+
208
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
209
+
210
+ ```shell
211
+ pip3 install hf_transfer
212
+ ```
213
+
214
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
215
+
216
+ ```shell
217
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/Swallow-70B-GGUF swallow-70b.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
218
+ ```
219
+
220
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
221
+ </details>
222
+ <!-- README_GGUF.md-how-to-download end -->
223
+
224
+ <!-- README_GGUF.md-how-to-run start -->
225
+ ## Example `llama.cpp` command
226
+
227
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
228
+
229
+ ```shell
230
+ ./main -ngl 35 -m swallow-70b.Q4_K_M.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "{prompt}"
231
+ ```
232
+
233
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
234
+
235
+ 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.
236
+
237
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
238
+
239
+ 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)
240
+
241
+ ## How to run in `text-generation-webui`
242
+
243
+ 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).
244
+
245
+ ## How to run from Python code
246
+
247
+ 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.
248
+
249
+ ### How to load this model in Python code, using llama-cpp-python
250
+
251
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
252
+
253
+ #### First install the package
254
+
255
+ Run one of the following commands, according to your system:
256
+
257
+ ```shell
258
+ # Base ctransformers with no GPU acceleration
259
+ pip install llama-cpp-python
260
+ # With NVidia CUDA acceleration
261
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
262
+ # Or with OpenBLAS acceleration
263
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
264
+ # Or with CLBLast acceleration
265
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
266
+ # Or with AMD ROCm GPU acceleration (Linux only)
267
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
268
+ # Or with Metal GPU acceleration for macOS systems only
269
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
270
+
271
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
272
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
273
+ pip install llama-cpp-python
274
+ ```
275
+
276
+ #### Simple llama-cpp-python example code
277
+
278
+ ```python
279
+ from llama_cpp import Llama
280
+
281
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
282
+ llm = Llama(
283
+ model_path="./swallow-70b.Q4_K_M.gguf", # Download the model file first
284
+ n_ctx=4096, # The max sequence length to use - note that longer sequence lengths require much more resources
285
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
286
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
287
+ )
288
+
289
+ # Simple inference example
290
+ output = llm(
291
+ "{prompt}", # Prompt
292
+ max_tokens=512, # Generate up to 512 tokens
293
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
294
+ echo=True # Whether to echo the prompt
295
+ )
296
+
297
+ # Chat Completion API
298
+
299
+ llm = Llama(model_path="./swallow-70b.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
300
+ llm.create_chat_completion(
301
+ messages = [
302
+ {"role": "system", "content": "You are a story writing assistant."},
303
+ {
304
+ "role": "user",
305
+ "content": "Write a story about llamas."
306
+ }
307
+ ]
308
+ )
309
+ ```
310
+
311
+ ## How to use with LangChain
312
+
313
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
314
+
315
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
316
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
317
+
318
+ <!-- README_GGUF.md-how-to-run end -->
319
+
320
+ <!-- footer start -->
321
+ <!-- 200823 -->
322
+ ## Discord
323
+
324
+ For further support, and discussions on these models and AI in general, join us at:
325
+
326
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
327
+
328
+ ## Thanks, and how to contribute
329
+
330
+ Thanks to the [chirper.ai](https://chirper.ai) team!
331
+
332
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
333
+
334
+ 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.
335
+
336
+ 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.
337
+
338
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
339
+
340
+ * Patreon: https://patreon.com/TheBlokeAI
341
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
342
+
343
+ **Special thanks to**: Aemon Algiz.
344
+
345
+ **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
346
+
347
+
348
+ Thank you to all my generous patrons and donaters!
349
+
350
+ And thank you again to a16z for their generous grant.
351
+
352
+ <!-- footer end -->
353
+
354
+ <!-- original-model-card start -->
355
+ # Original model card: tokyotech-llm's Swallow 70B
356
+
357
+
358
+ # Swallow
359
+
360
+ 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).
361
+ Links to other models can be found in the index.
362
+
363
+ ## Swallow Model Index
364
+ |Model|Swallow-hf|Swallow-instruct-hf|
365
+ |---|---|---|
366
+ |7B| [Link](https://huggingface.co/tokyotech-llm/Swallow-7b-hf) | [Link](https://huggingface.co/tokyotech-llm/Swallow-7b-instruct-hf)|
367
+ |13B| [Link](https://huggingface.co/tokyotech-llm/Swallow-13b-hf) | [Link](https://huggingface.co/tokyotech-llm/Swallow-13b-instruct-hf)|
368
+ |70B| [Link](https://huggingface.co/tokyotech-llm/Swallow-70b-hf) | [Link](https://huggingface.co/tokyotech-llm/Swallow-70b-instruct-hf)|
369
+
370
+
371
+ ![logo](./logo.png)
372
+
373
+ This repository provides large language models developed by [TokyoTech-LLM](https://tokyotech-llm.github.io/).
374
+ Read our [blog post](https://zenn.dev/tokyotech_lm/articles/d6cb3a8fdfc907) or our paper (preprint coming soon) for more details!
375
+
376
+
377
+ ## Model Details
378
+
379
+ * **Model type**: Please refer to LLaMA-2 technical report for details on the model architecture.
380
+ * **Language(s)**: Japanese English
381
+ * **Library**: [Megatron-LM](https://github.com/rioyokotalab/Megatron-Llama2)
382
+ * **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.
383
+ * **Contact**: swallow[at]nlp.c.titech.ac.jp
384
+
385
+ ## Base Model Performance
386
+
387
+ ### Japanese version
388
+
389
+ |Model|Size|JCommonsenseQA|JEMHopQA|NIILC|JSQuAD|XL-Sum|MGSM|WMT20-en-ja|WMT20-ja-en|
390
+ |---|---|---|---|---|---|---|---|---|---|
391
+ | | |4-shot|4-shot|4-shot|4-shot|1-shot|4-shot|4-shot|4-shot|
392
+ |Llama 2|7B|0.3852|0.4240|0.3410|0.7917|0.1905|0.0760|0.1783|0.1738|
393
+ |Swallow|7B|0.4808|0.5078|0.5968|0.8573|0.1830|0.1240|0.2510|0.1511|
394
+ |Llama 2|13B|0.6997|0.4415|0.4170|0.8533|0.2139|0.1320|0.2146|0.1982|
395
+ |Swallow|13B|0.7837|0.5063|0.6398|0.9005|0.2168|0.2040|0.2720|0.1771|
396
+ |Llama 2|70B|0.8686|0.4656|0.5256|0.9080|**0.2361**|0.3560|0.2643|**0.2398**|
397
+ |Swallow|70B|**0.9348**|**0.6290**|**0.6960**|**0.9176**|0.2266|**0.4840**|**0.3043**|0.2298|
398
+
399
+ ## Usage
400
+
401
+ First install additional dependencies in [requirements.txt](./requirements.txt):
402
+
403
+ ```sh
404
+ pip install -r requirements.txt
405
+ ```
406
+
407
+ ### Use the instruct model
408
+
409
+ ```python
410
+ import torch
411
+ from transformers import AutoTokenizer, AutoModelForCausalLM
412
+
413
+ model_name = "tokyotech-llm/Swallow-7b-instruct-hf"
414
+
415
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
416
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, device_map="auto")
417
+
418
+
419
+ PROMPT_DICT = {
420
+ "prompt_input": (
421
+ "以下に、あるタスクを説明する指示があり、それに付随する入力が更なる文脈を提供しています。"
422
+ "リクエストを適切に完了するための回答を記述してください。\n\n"
423
+ "### 指示:\n{instruction}\n\n### 入力:\n{input}\n\n### 応答:"
424
+
425
+ ),
426
+ "prompt_no_input": (
427
+ "以下に、あるタスクを説明する指示があります。"
428
+ "リクエストを適切に完了するための回答を記述してください。\n\n"
429
+ "### 指示:\n{instruction}\n\n### 応答:"
430
+ ),
431
+ }
432
+
433
+ def create_prompt(instruction, input=None):
434
+ """
435
+ Generates a prompt based on the given instruction and an optional input.
436
+ If input is provided, it uses the 'prompt_input' template from PROMPT_DICT.
437
+ If no input is provided, it uses the 'prompt_no_input' template.
438
+
439
+ Args:
440
+ instruction (str): The instruction describing the task.
441
+ input (str, optional): Additional input providing context for the task. Default is None.
442
+
443
+ Returns:
444
+ str: The generated prompt.
445
+ """
446
+ if input:
447
+ # Use the 'prompt_input' template when additional input is provided
448
+ return PROMPT_DICT["prompt_input"].format(instruction=instruction, input=input)
449
+ else:
450
+ # Use the 'prompt_no_input' template when no additional input is provided
451
+ return PROMPT_DICT["prompt_no_input"].format(instruction=instruction)
452
+
453
+ # Example usage
454
+ instruction_example = "以下のトピックに関する詳細な情報を提供してください。"
455
+ input_example = "東京工業大学の主なキャンパスについて教えてください"
456
+ prompt = create_prompt(instruction_example, input_example)
457
+
458
+ input_ids = tokenizer.encode(
459
+ prompt,
460
+ add_special_tokens=False,
461
+ return_tensors="pt"
462
+ )
463
+
464
+ tokens = model.generate(
465
+ input_ids.to(device=model.device),
466
+ max_new_tokens=128,
467
+ temperature=0.99,
468
+ top_p=0.95,
469
+ do_sample=True,
470
+ )
471
+
472
+ out = tokenizer.decode(tokens[0], skip_special_tokens=True)
473
+ print(out)
474
+
475
+ ```
476
+
477
+ ### Use the base model
478
+
479
+ ```python
480
+ import torch
481
+ from transformers import AutoTokenizer, AutoModelForCausalLM
482
+
483
+ model_name = "tokyotech-llm/Swallow-7b-hf"
484
+
485
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
486
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
487
+
488
+ prompt = "東京工業大学の主なキャンパスは、"
489
+ input_ids = tokenizer.encode(
490
+ prompt,
491
+ add_special_tokens=False,
492
+ return_tensors="pt"
493
+ )
494
+ tokens = model.generate(
495
+ input_ids.to(device=model.device),
496
+ max_new_tokens=128,
497
+ temperature=0.99,
498
+ top_p=0.95,
499
+ do_sample=True,
500
+ )
501
+
502
+ out = tokenizer.decode(tokens[0], skip_special_tokens=True)
503
+ print(out)
504
+ ```
505
+
506
+ ## Training Datasets
507
+
508
+ ### Continual Pre-Training
509
+ The following datasets were used for continual pre-training.
510
+
511
+ - [Japanese Wikipedia](https://dumps.wikimedia.org/other/cirrussearch)
512
+ - [RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)
513
+ - Swallow Corpus
514
+ - [The Pile](https://huggingface.co/datasets/EleutherAI/pile)
515
+
516
+
517
+ ### Instruction Tuning
518
+
519
+ The following datasets were used for the instruction tuning.
520
+
521
+ - [Anthropic HH-RLHF](https://huggingface.co/datasets/kunishou/hh-rlhf-49k-ja)
522
+ - [Databricks Dolly 15-k](https://huggingface.co/datasets/kunishou/databricks-dolly-15k-ja)
523
+ - [OpenAssistant Conversations Dataset](https://huggingface.co/datasets/kunishou/oasst1-89k-ja)
524
+
525
+ ## Risks and Limitations
526
+
527
+ 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.
528
+
529
+ ## Acknowledgements
530
+
531
+ We thank Meta Research for releasing Llama 2 under an open license for others to build on.
532
+
533
+ 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.
534
+
535
+ ## License
536
+
537
+ Llama 2 is licensed under the LLAMA 2 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.
538
+
539
+ ## Authors
540
+
541
+ Here are the team members:
542
+ - From [Okazaki Laboratory](https://www.nlp.c.titech.ac.jp/index.en.html), the following members:
543
+ - [Naoaki Okazaki](https://www.chokkan.org/index.ja.html)
544
+ - [Sakae Mizuki](https://s-mizuki-nlp.github.io/)
545
+ - [Hiroki Iida](https://meshidenn.github.io/)
546
+ - [Mengsay Loem](https://loem-ms.github.io/)
547
+ - [Shota Hirai](https://huggingface.co/Kotemo428)
548
+ - [Kakeru Hattori](https://aya-se.vercel.app/)
549
+ - [Masanari Ohi](https://twitter.com/stjohn2007)
550
+ - From [YOKOTA Laboratory](https://www.rio.gsic.titech.ac.jp/en/index.html), the following members:
551
+ - [Rio Yokota](https://twitter.com/rioyokota)
552
+ - [Kazuki Fujii](https://twitter.com/okoge_kaz)
553
+ - [Taishi Nakamura](https://twitter.com/Setuna7777_2)
554
+
555
+ <!-- original-model-card end -->