Transformers
GGUF
Japanese
llama
TheBloke commited on
Commit
de62a88
โ€ข
1 Parent(s): b2ade10

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +372 -0
README.md ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: https://huggingface.co/lightblue/openorca_stx
3
+ datasets:
4
+ - snow_simplified_japanese_corpus
5
+ - khalidalt/tydiqa-goldp
6
+ - csebuetnlp/xlsum
7
+ inference: false
8
+ language:
9
+ - ja
10
+ license: llama2
11
+ model_creator: Lightblue Technology Inc.
12
+ model_name: OpenOrca Stx
13
+ model_type: llama
14
+ quantized_by: TheBloke
15
+ ---
16
+
17
+ <!-- header start -->
18
+ <!-- 200823 -->
19
+ <div style="width: auto; margin-left: auto; margin-right: auto">
20
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
21
+ </div>
22
+ <div style="display: flex; justify-content: space-between; width: 100%;">
23
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
24
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
25
+ </div>
26
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
27
+ <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>
28
+ </div>
29
+ </div>
30
+ <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>
31
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
32
+ <!-- header end -->
33
+
34
+ # OpenOrca Stx - GGUF
35
+ - Model creator: [Lightblue Technology Inc.](https://huggingface.co/lightblue)
36
+ - Original model: [OpenOrca Stx](https://huggingface.co/lightblue/openorca_stx)
37
+
38
+ <!-- description start -->
39
+ ## Description
40
+
41
+ This repo contains GGUF format model files for [Lightblue Technology Inc.'s OpenOrca Stx](https://huggingface.co/lightblue/openorca_stx).
42
+
43
+ <!-- description end -->
44
+ <!-- README_GGUF.md-about-gguf start -->
45
+ ### About GGUF
46
+
47
+ 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. GGUF offers numerous advantages over GGML, such as better tokenisation, and support for special tokens. It is also supports metadata, and is designed to be extensible.
48
+
49
+ Here is an incomplate list of clients and libraries that are known to support GGUF:
50
+
51
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
52
+ * [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.
53
+ * [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.
54
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
55
+ * [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.
56
+ * [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.
57
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
58
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
59
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
60
+
61
+ <!-- README_GGUF.md-about-gguf end -->
62
+ <!-- repositories-available start -->
63
+ ## Repositories available
64
+
65
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/OpenOrca_Stx-GPTQ)
66
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF)
67
+ * [Lightblue Technology Inc.'s original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/lightblue/openorca_stx)
68
+ <!-- repositories-available end -->
69
+
70
+ <!-- prompt-template start -->
71
+ ## Prompt template: None
72
+
73
+ ```
74
+ {prompt}
75
+
76
+ ```
77
+
78
+ <!-- prompt-template end -->
79
+
80
+
81
+ <!-- compatibility_gguf start -->
82
+ ## Compatibility
83
+
84
+ These quantised GGUFv2 files are compatible with llama.cpp from August 27th onwards, as of commit [d0cee0d36d5be95a0d9088b674dbb27354107221](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221)
85
+
86
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
87
+
88
+ ## Explanation of quantisation methods
89
+ <details>
90
+ <summary>Click to see details</summary>
91
+
92
+ The new methods available are:
93
+ * 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)
94
+ * 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.
95
+ * 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.
96
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
97
+ * 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
98
+
99
+ Refer to the Provided Files table below to see what files use which methods, and how.
100
+ </details>
101
+ <!-- compatibility_gguf end -->
102
+
103
+ <!-- README_GGUF.md-provided-files start -->
104
+ ## Provided files
105
+
106
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
107
+ | ---- | ---- | ---- | ---- | ---- | ----- |
108
+ | [openorca_stx.Q2_K.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q2_K.gguf) | Q2_K | 2 | 5.43 GB| 7.93 GB | smallest, significant quality loss - not recommended for most purposes |
109
+ | [openorca_stx.Q3_K_S.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q3_K_S.gguf) | Q3_K_S | 3 | 5.66 GB| 8.16 GB | very small, high quality loss |
110
+ | [openorca_stx.Q3_K_M.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q3_K_M.gguf) | Q3_K_M | 3 | 6.34 GB| 8.84 GB | very small, high quality loss |
111
+ | [openorca_stx.Q3_K_L.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q3_K_L.gguf) | Q3_K_L | 3 | 6.93 GB| 9.43 GB | small, substantial quality loss |
112
+ | [openorca_stx.Q4_0.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q4_0.gguf) | Q4_0 | 4 | 7.37 GB| 9.87 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
113
+ | [openorca_stx.Q4_K_S.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q4_K_S.gguf) | Q4_K_S | 4 | 7.41 GB| 9.91 GB | small, greater quality loss |
114
+ | [openorca_stx.Q4_K_M.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q4_K_M.gguf) | Q4_K_M | 4 | 7.87 GB| 10.37 GB | medium, balanced quality - recommended |
115
+ | [openorca_stx.Q5_0.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q5_0.gguf) | Q5_0 | 5 | 8.97 GB| 11.47 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
116
+ | [openorca_stx.Q5_K_S.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q5_K_S.gguf) | Q5_K_S | 5 | 8.97 GB| 11.47 GB | large, low quality loss - recommended |
117
+ | [openorca_stx.Q5_K_M.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q5_K_M.gguf) | Q5_K_M | 5 | 9.23 GB| 11.73 GB | large, very low quality loss - recommended |
118
+ | [openorca_stx.Q6_K.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q6_K.gguf) | Q6_K | 6 | 10.68 GB| 13.18 GB | very large, extremely low quality loss |
119
+ | [openorca_stx.Q8_0.gguf](https://huggingface.co/TheBloke/OpenOrca_Stx-GGUF/blob/main/openorca_stx.Q8_0.gguf) | Q8_0 | 8 | 13.83 GB| 16.33 GB | very large, extremely low quality loss - not recommended |
120
+
121
+ **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.
122
+
123
+
124
+
125
+ <!-- README_GGUF.md-provided-files end -->
126
+
127
+ <!-- README_GGUF.md-how-to-download start -->
128
+ ## How to download GGUF files
129
+
130
+ **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.
131
+
132
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
133
+ - LM Studio
134
+ - LoLLMS Web UI
135
+ - Faraday.dev
136
+
137
+ ### In `text-generation-webui`
138
+
139
+ Under Download Model, you can enter the model repo: TheBloke/OpenOrca_Stx-GGUF and below it, a specific filename to download, such as: openorca_stx.q4_K_M.gguf.
140
+
141
+ Then click Download.
142
+
143
+ ### On the command line, including multiple files at once
144
+
145
+ I recommend using the `huggingface-hub` Python library:
146
+
147
+ ```shell
148
+ pip3 install huggingface-hub>=0.17.1
149
+ ```
150
+
151
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
152
+
153
+ ```shell
154
+ huggingface-cli download TheBloke/OpenOrca_Stx-GGUF openorca_stx.q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
155
+ ```
156
+
157
+ <details>
158
+ <summary>More advanced huggingface-cli download usage</summary>
159
+
160
+ You can also download multiple files at once with a pattern:
161
+
162
+ ```shell
163
+ huggingface-cli download TheBloke/OpenOrca_Stx-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
164
+ ```
165
+
166
+ 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).
167
+
168
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
169
+
170
+ ```shell
171
+ pip3 install hf_transfer
172
+ ```
173
+
174
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
175
+
176
+ ```shell
177
+ HUGGINGFACE_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/OpenOrca_Stx-GGUF openorca_stx.q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
178
+ ```
179
+
180
+ Windows CLI users: Use `set HUGGINGFACE_HUB_ENABLE_HF_TRANSFER=1` before running the download command.
181
+ </details>
182
+ <!-- README_GGUF.md-how-to-download end -->
183
+
184
+ <!-- README_GGUF.md-how-to-run start -->
185
+ ## Example `llama.cpp` command
186
+
187
+ Make sure you are using `llama.cpp` from commit [d0cee0d36d5be95a0d9088b674dbb27354107221](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
188
+
189
+ ```shell
190
+ ./main -ngl 32 -m openorca_stx.q4_K_M.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "{prompt}"
191
+ ```
192
+
193
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
194
+
195
+ 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.
196
+
197
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
198
+
199
+ 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)
200
+
201
+ ## How to run in `text-generation-webui`
202
+
203
+ Further instructions here: [text-generation-webui/docs/llama.cpp.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/llama.cpp.md).
204
+
205
+ ## How to run from Python code
206
+
207
+ 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.
208
+
209
+ ### How to load this model from Python using ctransformers
210
+
211
+ #### First install the package
212
+
213
+ ```bash
214
+ # Base ctransformers with no GPU acceleration
215
+ pip install ctransformers>=0.2.24
216
+ # Or with CUDA GPU acceleration
217
+ pip install ctransformers[cuda]>=0.2.24
218
+ # Or with ROCm GPU acceleration
219
+ CT_HIPBLAS=1 pip install ctransformers>=0.2.24 --no-binary ctransformers
220
+ # Or with Metal GPU acceleration for macOS systems
221
+ CT_METAL=1 pip install ctransformers>=0.2.24 --no-binary ctransformers
222
+ ```
223
+
224
+ #### Simple example code to load one of these GGUF models
225
+
226
+ ```python
227
+ from ctransformers import AutoModelForCausalLM
228
+
229
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
230
+ llm = AutoModelForCausalLM.from_pretrained("TheBloke/OpenOrca_Stx-GGUF", model_file="openorca_stx.q4_K_M.gguf", model_type="llama", gpu_layers=50)
231
+
232
+ print(llm("AI is going to"))
233
+ ```
234
+
235
+ ## How to use with LangChain
236
+
237
+ Here's guides on using llama-cpp-python or ctransformers with LangChain:
238
+
239
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
240
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
241
+
242
+ <!-- README_GGUF.md-how-to-run end -->
243
+
244
+ <!-- footer start -->
245
+ <!-- 200823 -->
246
+ ## Discord
247
+
248
+ For further support, and discussions on these models and AI in general, join us at:
249
+
250
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
251
+
252
+ ## Thanks, and how to contribute
253
+
254
+ Thanks to the [chirper.ai](https://chirper.ai) team!
255
+
256
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
257
+
258
+ 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.
259
+
260
+ 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.
261
+
262
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
263
+
264
+ * Patreon: https://patreon.com/TheBlokeAI
265
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
266
+
267
+ **Special thanks to**: Aemon Algiz.
268
+
269
+ **Patreon special mentions**: Alicia Loh, Stephen Murray, K, Ajan Kanaga, RoA, Magnesian, Deo Leter, Olakabola, Eugene Pentland, zynix, Deep Realms, Raymond Fosdick, Elijah Stavena, Iucharbius, Erik Bjรคreholt, Luis Javier Navarrete Lozano, Nicholas, theTransient, John Detwiler, alfie_i, knownsqashed, Mano Prime, Willem Michiel, Enrico Ros, LangChain4j, OG, Michael Dempsey, Pierre Kircher, Pedro Madruga, James Bentley, Thomas Belote, Luke @flexchar, Leonard Tan, Johann-Peter Hartmann, Illia Dulskyi, Fen Risland, Chadd, S_X, Jeff Scroggin, Ken Nordquist, Sean Connelly, Artur Olbinski, Swaroop Kallakuri, Jack West, Ai Maven, David Ziegler, Russ Johnson, transmissions 11, John Villwock, Alps Aficionado, Clay Pascal, Viktor Bowallius, Subspace Studios, Rainer Wilmers, Trenton Dambrowitz, vamX, Michael Levine, ๏ฟฝ๏ฟฝ๏ฟฝ๊ต ๊น€, Brandon Frisco, Kalila, Trailburnt, Randy H, Talal Aujan, Nathan Dryer, Vadim, ้˜ฟๆ˜Ž, ReadyPlayerEmma, Tiffany J. Kim, George Stoitzev, Spencer Kim, Jerry Meng, Gabriel Tamborski, Cory Kujawski, Jeffrey Morgan, Spiking Neurons AB, Edmond Seymore, Alexandros Triantafyllidis, Lone Striker, Cap'n Zoog, Nikolai Manek, danny, ya boyyy, Derek Yates, usrbinkat, Mandus, TL, Nathan LeClaire, subjectnull, Imad Khwaja, webtim, Raven Klaugh, Asp the Wyvern, Gabriel Puliatti, Caitlyn Gatomon, Joseph William Delisle, Jonathan Leane, Luke Pendergrass, SuperWojo, Sebastain Graf, Will Dee, Fred von Graf, Andrey, Dan Guido, Daniel P. Andersen, Nitin Borwankar, Elle, Vitor Caleffi, biorpg, jjj, NimbleBox.ai, Pieter, Matthew Berman, terasurfer, Michael Davis, Alex, Stanislav Ovsiannikov
270
+
271
+
272
+ Thank you to all my generous patrons and donaters!
273
+
274
+ And thank you again to a16z for their generous grant.
275
+
276
+ <!-- footer end -->
277
+
278
+ <!-- original-model-card start -->
279
+ # Original model card: Lightblue Technology Inc.'s OpenOrca Stx
280
+
281
+ # About
282
+ This model is Lightblue's QLoRA finetune of OpenOrca's [Open-Orca/OpenOrcaxOpenChat-Preview2-13B](https://huggingface.co/Open-Orca/OpenOrcaxOpenChat-Preview2-13B) model on Japanese fine-tuning datasets.
283
+
284
+ This model specialises on answering **Closed Question Answering** in Japanese. Input a piece of reference text, ask a question, and see the model answer based on the reference text.
285
+
286
+ We trained on equal samples of the following three datasets:
287
+ * [SNOW](https://huggingface.co/datasets/snow_simplified_japanese_corpus)
288
+ * [TyDiQA (Ja)](https://huggingface.co/datasets/khalidalt/tydiqa-goldp)
289
+ * [XLSUM (Ja)](https://huggingface.co/datasets/csebuetnlp/xlsum)
290
+
291
+ which resulted in a dataset of 13,167 samples total.
292
+
293
+ These three datasets were chosen as they represent three distinct fine-tuning tasks (Text simplification, question answering, and text summarization, respectively) which we hypothesize can help to improve the language models suitability for dealing with Japanese data.
294
+ These three datasets make up the model name: STX.
295
+
296
+ With these datasets, we achieve the following scores on the JGLUE benchmark:
297
+
298
+ | Model Name | Open-Orca/OpenOrcaxOpenChat-Preview2-13B | lightblue/openorca_stx |
299
+ |------------------------|------------------------------------------|------------------------|
300
+ | jsquad-1.1-0.3 | 0.692 | 0.836 |
301
+ | jcommonsenseqa-1.1-0.3 | 0.831 | 0.782 |
302
+ | jnli-1.1-0.3 | 0.504 | 0.48 |
303
+ | marc_ja-1.1-0.3 | 0.936 | 0.959 |
304
+
305
+ Our model achieves much better results on the question answering benchmark (JSQuAD) than the base checkpoint without monstrous degradation of performance on multi-choice question benchmarks (JCommonSense, JNLI, MARC-Ja) purely through QLoRA training.
306
+ This shows the potential for applying strong language models such as [Open-Orca/OpenOrcaxOpenChat-Preview2-13B](https://huggingface.co/Open-Orca/OpenOrcaxOpenChat-Preview2-13B) to minimal QLoRA fine-tuning using Japanese fine-tuning datasets to achieve better results at narrow NLP tasks.
307
+
308
+ # How to use
309
+
310
+ ```python
311
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
312
+
313
+ tokenizer = AutoTokenizer.from_pretrained(model_dir)
314
+ model = AutoModelForCausalLM.from_pretrained(
315
+ model_dir, torch_dtype=torch.bfloat16, device_map='auto',
316
+ )
317
+
318
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
319
+
320
+ def do_closed_qa(context, question):
321
+ return context + "\n\n" + question
322
+
323
+ test_article = """ใ€€ใƒขใƒŽใƒžใƒใฎใƒฌใƒ‘ใƒผใƒˆใƒชใƒผใซใ€Œใƒชใƒผใƒใƒปใƒžใ‚คใ‚ฑใƒซ้ธๆ‰‹ใ€ใŒใ‚ใ‚‹ใƒฌใ‚คใ‚ถใƒผใƒฉใƒขใƒณRGใ•ใ‚“ใ€‚ๆœฌไบบๅ…ฌ่ชใฎใƒขใƒŽใƒžใƒใงใ™ใŒใ€ใƒฉใ‚ฐใƒ“ใƒผใƒ•ใ‚กใƒณใฎๅๅฟœใซๅฐ‘ใ—้ฉšใ„ใŸใใ†ใงใ™ใ€‚
324
+ ใ€€ใƒชใƒผใƒใƒปใƒžใ‚คใ‚ฑใƒซ้ธๆ‰‹ใฎใƒขใƒŽใƒžใƒใฏใ€ไฝ•ใŒใใฃใ‹ใ‘ใงใ™ใ‹ใ€‚
325
+ ใ€Œ2015ๅนดใฎใƒฏใƒผใƒซใƒ‰ใ‚ซใƒƒใƒ—๏ผˆWๆฏ๏ผ‰ใ‚คใƒณใ‚ฐใƒฉใƒณใƒ‰ๅคงไผšใงๆ—ฅๆœฌใŒๅ—ใ‚ขใƒ•ใƒชใ‚ซใ‚’ๅ€’ใ—ใŸๆฌกใฎๆ—ฅใŒใ€ไบฌ้ƒฝใงใฎ็•ช็ต„ใƒญใ‚ฑใงใ—ใŸใ€‚ๅฝ“ๆ™‚ใฏใ€ใ‚ขใƒƒใƒ—ใƒซใฎๅ…ฑๅŒๅ‰ตๆฅญ่€…ใ‚นใƒ†ใ‚ฃใƒผใƒ–ใƒปใ‚ธใƒงใƒ–ใ‚บใฎใƒขใƒŽใƒžใƒใฐใ‹ใ‚Šใงใ—ใŸใŒใ€ไธ€็ท’ใซใƒญใ‚ฑใ‚’ใ—ใฆใ„ใŸใ‚ธใƒฃใƒณใ‚ฐใƒซใƒใ‚ฑใƒƒใƒˆใ‹ใ‚‰ใ€Žใƒชใƒผใƒใƒปใƒžใ‚คใ‚ฑใƒซใซไผผใฆใพใ™ใ‚ˆใ€‚ใ‚ธใƒงใƒ–ใ‚บใฎใพใพใ€ใ„ใ‘ใ‚‹ใ‚“ใ˜ใ‚ƒใชใ„ใงใ™ใ‹๏ผŸใ€ใจ่จ€ใ‚ใ‚ŒใŸใฎใŒๅง‹ใพใ‚Šใงใ™ใ€
326
+ ใ€ŒใŸใ ใ€ใฟใ‚“ใช็Ÿฅ่ญ˜ใŒใชใ„ใ€‚ใƒฉใ‚ฐใƒ“ใƒผใ‚ทใƒงใƒƒใƒ—ใ‚’ๆŽขใ—ใ€ๆ—ฅๆœฌไปฃ่กจใฎใƒฆใƒ‹ใƒ›ใƒผใƒ ใŒๅฃฒใ‚Šๅˆ‡ใ‚Œใ ใฃใŸใฎใงใ€่ตคใฃใฝใ„ใƒฆใƒ‹ใƒ›ใƒผใƒ ใจใƒ”ใƒใƒ”ใƒใฎ็Ÿญใƒ‘ใƒณใ‚’ใฏใ„ใฆใ€‚ใจใ‚Šใ‚ใˆใšSNSใงใ€Žใƒชใƒผใƒใƒปใƒžใ‚คใ‚ฑใƒซใงใ™ใ€ใฃใฆใ„ใฃใฑใ„ๅ†™็œŸใ‚’่ผ‰ใ›ใพใ—ใŸใ€
327
+ ใ€Œใ™ใ‚‹ใจใ€ใใ‚Œใ‚’่ฆ‹ใŸใƒชใƒผใƒใ•ใ‚“ๆœฌไบบใ‹ใ‚‰DM๏ผˆใƒ€ใ‚คใƒฌใ‚ฏใƒˆใƒกใƒƒใ‚ปใƒผใ‚ธ๏ผ‰ใŒๅฑŠใใพใ—ใŸใ€‚ใ€ŽใƒขใƒŽใƒžใƒใ‚ใ‚ŠใŒใจใ†ใ”ใ–ใ„ใพใ™ใ€‚ใ‚‚ใ—ใƒขใƒŽใƒžใƒใ‚’ใ™ใ‚‹ใชใ‚‰ใ€ๅƒ•ใฎใƒฆใƒ‹ใƒ›ใƒผใƒ ใ‚’้€ใ‚Šใพใ™ใฎใง็€ใฆใใ ใ•ใ„ใ€ใจใ€‚WๆฏๅพŒใซใƒฆใƒ‹ใƒ›ใƒผใƒ 2็€ใจใƒ‘ใƒณใƒ„ใ‚„ใ‚ฝใƒƒใ‚ฏใ‚นใชใฉใ‚’ใปใ‚“ใพใซ้€ใฃใฆใใฆใใ‚Œใพใ—ใŸใ€‚ไปŠ็€ใฆใ„ใ‚‹ใฎใŒใใ‚Œใงใ™ใ€
328
+ ใ“ใ‚Œใพใงใ€ๆ•ฐใ€…ใฎ่‘—ๅไบบใ‚’ใƒขใƒŽใƒžใƒใ—ใฆใ“ใ‚‰ใ‚Œใพใ—ใŸใ€‚ใƒชใƒผใƒ้ธๆ‰‹ใฎใƒใ‚ฟใฎๅ้Ÿฟใฏใ„ใ‹ใŒใงใ—ใŸใ‹ใ€‚
329
+ ใ€€ใ€Œๅƒ•ใฏใƒฉใ‚ฐใƒ“ใƒผ็ตŒ้จ“ใŒใชใ„ใงใ™ใ—ใ€ใƒฉใ‚ฐใƒ“ใƒผใ‚’ๅ…จ็„ถ็Ÿฅใ‚‰ใชใ‹ใฃใŸใ‘ใฉใ€ใ‚„ใฃใฑใ‚Šๆœฌไบบใ‹ใ‚‰ใƒฆใƒ‹ใƒ›ใƒผใƒ ใ‚’้ ‚ใ„ใฆใ‚‹ใฃใฆใ„ใ†โ€œๅฐ็ฑ ๏ผˆใ„ใ‚“ใ‚ใ†๏ผ‰โ€ใฟใŸใ„ใชใฎใŒใ‚ใฃใฆใ€‚ใ€Žใ‚ใ„ใคใฏใƒชใƒผใƒใ•ใ‚“ๆœฌไบบใซ่ชใ‚ใ‚‰ใ‚Œใฆใ‚‹ใ€ใจใ€‚ไธ€็›ฎ็ฝฎใ‹ใ‚Œใฆใ„ใ‚‹ใฎใ‹ใชใจๆ„Ÿใ˜ใพใ™ใ€
330
+ ใ€€ใ€Œใ‚„ใฃใฆใ„ใ‚‹ใ“ใจใฏใ€่ฆ‹ใŸ็›ฎใ‚’ๆœฌไบบใซๅฏ„ใ›ใฆใƒฏใƒณใƒใƒผใƒ ใฃใฆ่จ€ใ†ใ ใ‘ใชใ‚“ใงใ™ใ‘ใฉใญใ€‚ใใ‚Œใงใ‚‚ใ€Žใ‚ใ‚ใ€ใƒชใƒผใƒใ•ใ‚“ใ ใ€ใจ่จ€ใฃใฆใ‚‚ใ‚‰ใˆใพใ™ใ€
331
+ ใ€€ใ€Œใƒชใƒผใƒใ•ใ‚“ใจๅฎŸ้š›ใซไผšใ†ใ“ใจใชใ‚“ใฆใ€็ฐกๅ˜ใซใฏใงใใชใ„ใ˜ใ‚ƒใชใ„ใงใ™ใ‹ใ€‚ใงใ‚‚ใ€ใƒชใƒผใƒใ•ใ‚“ใฎใพใญใ‚’ใ—ใฆใ„ใ‚‹RGใซใฏไผšใˆใŸใ‚ใ€ใฟใŸใ„ใช๏ผˆ็ฌ‘๏ผ‰ใ€‚ไฝ•ใ ใ‚ใ†ใชใ€ๆœ‰ๅใช็ฅž็คพใฎๆ”ฏ็คพใฎใ‚ˆใ†ใชๅญ˜ๅœจใงใ™ใ‹ใญใ€‚ใ‚ใ‚ŠใŒใŸใŒใ‚‰ใ‚Œใ‚‹ใจใ„ใ†ๆ„ๅ‘ณใงใฏไป–ใฎใƒขใƒŽใƒžใƒใจใฏใ™ใ”ใ้•ใ„ใพใ™ใญใ€
332
+ """
333
+
334
+ test_question = "ใ€€ใƒชใƒผใƒใƒปใƒžใ‚คใ‚ฑใƒซใฏไฝ•ใ‚’้€ใฃใฆใใพใ—ใŸใ‹๏ผŸ"
335
+
336
+ pipe(do_closed_qa(test_article, question), max_new_tokens=128, temperature=0)[0]["generated_text"]
337
+ # "ใƒฆใƒ‹ใƒ›ใƒผใƒ 2็€ใจใƒ‘ใƒณใƒ„ใ‚„ใ‚ฝใƒƒใ‚ฏใ‚นใชใฉ"
338
+ ```
339
+
340
+
341
+ # Training details
342
+
343
+ This model was trained for 1000 steps (1.2 epochs) with the model being evaluated every 50 steps. We then chose the best model from these evaluations based on validation loss.
344
+ We used the [qlora](https://github.com/artidoro/qlora) package from artidoro.
345
+ We trained with the following hyperparameters:
346
+
347
+ ```
348
+ Per device evaluation batch size: 16
349
+ Per device train batch size: 8
350
+ LoRA (lora_r): 64
351
+ LoRA alpha (lora_alpha): 16
352
+ LoRA modules: all
353
+ Double quantization: Enabled
354
+ Quantization type: nf4
355
+ BF16: Enabled
356
+ Bits: 4
357
+ Warmup ratio: 0.03
358
+ Learning rate scheduler type: Constant
359
+ Gradient checkpointing: Enabled
360
+ Gradient accumulation steps: 2
361
+ Learning rate: 0.0002
362
+ Adam beta2: 0.999
363
+ Maximum gradient norm: 0.3
364
+ LoRA dropout: 0.05
365
+ Weight decay: 0.0
366
+ ```
367
+
368
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/64b63f8ad57e02621dc93c8b/UWiE7z5tG8t_vdSFrb5WC.png)
369
+
370
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/64b63f8ad57e02621dc93c8b/_fKBf9sdq9UAKKYMxM6ad.png)
371
+
372
+ <!-- original-model-card end -->