TheBloke commited on
Commit
bb29b37
1 Parent(s): c1acf7b

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +384 -0
README.md ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: defog/sqlcoder2
3
+ inference: false
4
+ language:
5
+ - en
6
+ license: other
7
+ model_creator: Defog.ai
8
+ model_name: Sqlcoder2
9
+ model_type: starcoder
10
+ pipeline_tag: text-generation
11
+ prompt_template: "## Task\nGenerate a SQL query to answer the following question:\n\
12
+ `{prompt}`\n\n### Database Schema\nThis query will run on a database whose schema\
13
+ \ is represented in this string:\nCREATE TABLE products (\n product_id INTEGER\
14
+ \ PRIMARY KEY, -- Unique ID for each product\n name VARCHAR(50), -- Name of the\
15
+ \ product\n price DECIMAL(10,2), -- Price of each unit of the product\n quantity\
16
+ \ INTEGER -- Current quantity in stock\n);\n\nCREATE TABLE sales (\n sale_id INTEGER\
17
+ \ PRIMARY KEY, -- Unique ID for each sale\n product_id INTEGER, -- ID of product\
18
+ \ sold\n customer_id INTEGER, -- ID of customer who made purchase\n salesperson_id\
19
+ \ INTEGER, -- ID of salesperson who made the sale\n sale_date DATE, -- Date the\
20
+ \ sale occurred\n quantity INTEGER -- Quantity of product sold\n);\n\n-- sales.product_id\
21
+ \ can be joined with products.product_id\n\n### SQL\nGiven the database schema,\
22
+ \ here is the SQL query that answers `{prompt}`:\n```sql\n"
23
+ quantized_by: TheBloke
24
+ tags:
25
+ - code
26
+ ---
27
+
28
+ <!-- header start -->
29
+ <!-- 200823 -->
30
+ <div style="width: auto; margin-left: auto; margin-right: auto">
31
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
32
+ </div>
33
+ <div style="display: flex; justify-content: space-between; width: 100%;">
34
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
35
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
36
+ </div>
37
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
38
+ <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>
39
+ </div>
40
+ </div>
41
+ <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>
42
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
43
+ <!-- header end -->
44
+
45
+ # Sqlcoder2 - GGUF
46
+ - Model creator: [Defog.ai](https://huggingface.co/defog)
47
+ - Original model: [Sqlcoder2](https://huggingface.co/defog/sqlcoder2)
48
+
49
+ <!-- description start -->
50
+ ## Description
51
+
52
+ This repo contains GGUF format model files for [Defog.ai's Sqlcoder2](https://huggingface.co/defog/sqlcoder2).
53
+
54
+ <!-- description end -->
55
+ <!-- README_GGUF.md-about-gguf start -->
56
+ ### About GGUF
57
+
58
+ 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.
59
+
60
+ Here is an incomplate list of clients and libraries that are known to support GGUF:
61
+
62
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
63
+ * [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.
64
+ * [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.
65
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
66
+ * [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.
67
+ * [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.
68
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
69
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
70
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
71
+
72
+ <!-- README_GGUF.md-about-gguf end -->
73
+ <!-- repositories-available start -->
74
+ ## Repositories available
75
+
76
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/sqlcoder2-AWQ)
77
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/sqlcoder2-GPTQ)
78
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/sqlcoder2-GGUF)
79
+ * [Defog.ai's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/defog/sqlcoder2)
80
+ <!-- repositories-available end -->
81
+
82
+ <!-- prompt-template start -->
83
+ ## Prompt template: Sqlcoder
84
+
85
+ ```
86
+ ## Task
87
+ Generate a SQL query to answer the following question:
88
+ `{prompt}`
89
+
90
+ ### Database Schema
91
+ This query will run on a database whose schema is represented in this string:
92
+ CREATE TABLE products (
93
+ product_id INTEGER PRIMARY KEY, -- Unique ID for each product
94
+ name VARCHAR(50), -- Name of the product
95
+ price DECIMAL(10,2), -- Price of each unit of the product
96
+ quantity INTEGER -- Current quantity in stock
97
+ );
98
+
99
+ CREATE TABLE sales (
100
+ sale_id INTEGER PRIMARY KEY, -- Unique ID for each sale
101
+ product_id INTEGER, -- ID of product sold
102
+ customer_id INTEGER, -- ID of customer who made purchase
103
+ salesperson_id INTEGER, -- ID of salesperson who made the sale
104
+ sale_date DATE, -- Date the sale occurred
105
+ quantity INTEGER -- Quantity of product sold
106
+ );
107
+
108
+ -- sales.product_id can be joined with products.product_id
109
+
110
+ ### SQL
111
+ Given the database schema, here is the SQL query that answers `{prompt}`:
112
+ ```sql
113
+
114
+ ```
115
+
116
+ <!-- prompt-template end -->
117
+
118
+
119
+ <!-- compatibility_gguf start -->
120
+ ## Compatibility
121
+
122
+ 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)
123
+
124
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
125
+
126
+ ## Explanation of quantisation methods
127
+ <details>
128
+ <summary>Click to see details</summary>
129
+
130
+ The new methods available are:
131
+ * 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)
132
+ * 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.
133
+ * 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.
134
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
135
+ * 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
136
+
137
+ Refer to the Provided Files table below to see what files use which methods, and how.
138
+ </details>
139
+ <!-- compatibility_gguf end -->
140
+
141
+ <!-- README_GGUF.md-provided-files start -->
142
+ ## Provided files
143
+
144
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
145
+ | ---- | ---- | ---- | ---- | ---- | ----- |
146
+ | [sqlcoder2.Q2_K.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q2_K.gguf) | Q2_K | 2 | 6.73 GB| 9.23 GB | smallest, significant quality loss - not recommended for most purposes |
147
+ | [sqlcoder2.Q3_K_S.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q3_K_S.gguf) | Q3_K_S | 3 | 6.93 GB| 9.43 GB | very small, high quality loss |
148
+ | [sqlcoder2.Q3_K_M.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q3_K_M.gguf) | Q3_K_M | 3 | 8.18 GB| 10.68 GB | very small, high quality loss |
149
+ | [sqlcoder2.Q4_0.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q4_0.gguf) | Q4_0 | 4 | 8.99 GB| 11.49 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
150
+ | [sqlcoder2.Q4_K_S.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q4_K_S.gguf) | Q4_K_S | 4 | 9.06 GB| 11.56 GB | small, greater quality loss |
151
+ | [sqlcoder2.Q3_K_L.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q3_K_L.gguf) | Q3_K_L | 3 | 9.08 GB| 11.58 GB | small, substantial quality loss |
152
+ | [sqlcoder2.Q4_K_M.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q4_K_M.gguf) | Q4_K_M | 4 | 9.96 GB| 12.46 GB | medium, balanced quality - recommended |
153
+ | [sqlcoder2.Q5_0.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q5_0.gguf) | Q5_0 | 5 | 10.93 GB| 13.43 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
154
+ | [sqlcoder2.Q5_K_S.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q5_K_S.gguf) | Q5_K_S | 5 | 10.93 GB| 13.43 GB | large, low quality loss - recommended |
155
+ | [sqlcoder2.Q5_K_M.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q5_K_M.gguf) | Q5_K_M | 5 | 11.54 GB| 14.04 GB | large, very low quality loss - recommended |
156
+ | [sqlcoder2.Q6_K.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q6_K.gguf) | Q6_K | 6 | 12.99 GB| 15.49 GB | very large, extremely low quality loss |
157
+ | [sqlcoder2.Q8_0.gguf](https://huggingface.co/TheBloke/sqlcoder2-GGUF/blob/main/sqlcoder2.Q8_0.gguf) | Q8_0 | 8 | 16.82 GB| 19.32 GB | very large, extremely low quality loss - not recommended |
158
+
159
+ **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.
160
+
161
+
162
+
163
+ <!-- README_GGUF.md-provided-files end -->
164
+
165
+ <!-- README_GGUF.md-how-to-download start -->
166
+ ## How to download GGUF files
167
+
168
+ **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.
169
+
170
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
171
+ - LM Studio
172
+ - LoLLMS Web UI
173
+ - Faraday.dev
174
+
175
+ ### In `text-generation-webui`
176
+
177
+ Under Download Model, you can enter the model repo: TheBloke/sqlcoder2-GGUF and below it, a specific filename to download, such as: sqlcoder2.Q4_K_M.gguf.
178
+
179
+ Then click Download.
180
+
181
+ ### On the command line, including multiple files at once
182
+
183
+ I recommend using the `huggingface-hub` Python library:
184
+
185
+ ```shell
186
+ pip3 install huggingface-hub
187
+ ```
188
+
189
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
190
+
191
+ ```shell
192
+ huggingface-cli download TheBloke/sqlcoder2-GGUF sqlcoder2.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
193
+ ```
194
+
195
+ <details>
196
+ <summary>More advanced huggingface-cli download usage</summary>
197
+
198
+ You can also download multiple files at once with a pattern:
199
+
200
+ ```shell
201
+ huggingface-cli download TheBloke/sqlcoder2-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
202
+ ```
203
+
204
+ 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).
205
+
206
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
207
+
208
+ ```shell
209
+ pip3 install hf_transfer
210
+ ```
211
+
212
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
213
+
214
+ ```shell
215
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/sqlcoder2-GGUF sqlcoder2.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
216
+ ```
217
+
218
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
219
+ </details>
220
+ <!-- README_GGUF.md-how-to-download end -->
221
+
222
+ <!-- README_GGUF.md-how-to-run start -->
223
+ ## Example `llama.cpp` command
224
+
225
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
226
+
227
+ ```shell
228
+ ./main -ngl 32 -m sqlcoder2.Q4_K_M.gguf --color -c 2048 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "## Task\nGenerate a SQL query to answer the following question:\n`{prompt}`\n\n### Database Schema\nThis query will run on a database whose schema is represented in this string:\nCREATE TABLE products (\n product_id INTEGER PRIMARY KEY, -- Unique ID for each product\n name VARCHAR(50), -- Name of the product\n price DECIMAL(10,2), -- Price of each unit of the product\n quantity INTEGER -- Current quantity in stock\n);\n\nCREATE TABLE sales (\n sale_id INTEGER PRIMARY KEY, -- Unique ID for each sale\n product_id INTEGER, -- ID of product sold\n customer_id INTEGER, -- ID of customer who made purchase\n salesperson_id INTEGER, -- ID of salesperson who made the sale\n sale_date DATE, -- Date the sale occurred\n quantity INTEGER -- Quantity of product sold\n);\n\n-- sales.product_id can be joined with products.product_id\n\n### SQL\nGiven the database schema, here is the SQL query that answers `{prompt}`:\n```sql"
229
+ ```
230
+
231
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
232
+
233
+ Change `-c 2048` 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.
234
+
235
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
236
+
237
+ 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)
238
+
239
+ ## How to run in `text-generation-webui`
240
+
241
+ Further instructions here: [text-generation-webui/docs/llama.cpp.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/llama.cpp.md).
242
+
243
+ ## How to run from Python code
244
+
245
+ 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.
246
+
247
+ ### How to load this model in Python code, using ctransformers
248
+
249
+ #### First install the package
250
+
251
+ Run one of the following commands, according to your system:
252
+
253
+ ```shell
254
+ # Base ctransformers with no GPU acceleration
255
+ pip install ctransformers
256
+ # Or with CUDA GPU acceleration
257
+ pip install ctransformers[cuda]
258
+ # Or with AMD ROCm GPU acceleration (Linux only)
259
+ CT_HIPBLAS=1 pip install ctransformers --no-binary ctransformers
260
+ # Or with Metal GPU acceleration for macOS systems only
261
+ CT_METAL=1 pip install ctransformers --no-binary ctransformers
262
+ ```
263
+
264
+ #### Simple ctransformers example code
265
+
266
+ ```python
267
+ from ctransformers import AutoModelForCausalLM
268
+
269
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
270
+ llm = AutoModelForCausalLM.from_pretrained("TheBloke/sqlcoder2-GGUF", model_file="sqlcoder2.Q4_K_M.gguf", model_type="starcoder", gpu_layers=50)
271
+
272
+ print(llm("AI is going to"))
273
+ ```
274
+
275
+ ## How to use with LangChain
276
+
277
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
278
+
279
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
280
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
281
+
282
+ <!-- README_GGUF.md-how-to-run end -->
283
+
284
+ <!-- footer start -->
285
+ <!-- 200823 -->
286
+ ## Discord
287
+
288
+ For further support, and discussions on these models and AI in general, join us at:
289
+
290
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
291
+
292
+ ## Thanks, and how to contribute
293
+
294
+ Thanks to the [chirper.ai](https://chirper.ai) team!
295
+
296
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
297
+
298
+ 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.
299
+
300
+ 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.
301
+
302
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
303
+
304
+ * Patreon: https://patreon.com/TheBlokeAI
305
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
306
+
307
+ **Special thanks to**: Aemon Algiz.
308
+
309
+ **Patreon special mentions**: Pierre Kircher, Stanislav Ovsiannikov, Michael Levine, Eugene Pentland, Andrey, 준교 김, Randy H, Fred von Graf, Artur Olbinski, Caitlyn Gatomon, terasurfer, Jeff Scroggin, James Bentley, Vadim, Gabriel Puliatti, Harry Royden McLaughlin, Sean Connelly, Dan Guido, Edmond Seymore, Alicia Loh, subjectnull, AzureBlack, Manuel Alberto Morcote, Thomas Belote, Lone Striker, Chris Smitley, Vitor Caleffi, Johann-Peter Hartmann, Clay Pascal, biorpg, Brandon Frisco, sidney chen, transmissions 11, Pedro Madruga, jinyuan sun, Ajan Kanaga, Emad Mostaque, Trenton Dambrowitz, Jonathan Leane, Iucharbius, usrbinkat, vamX, George Stoitzev, Luke Pendergrass, theTransient, Olakabola, Swaroop Kallakuri, Cap'n Zoog, Brandon Phillips, Michael Dempsey, Nikolai Manek, danny, Matthew Berman, Gabriel Tamborski, alfie_i, Raymond Fosdick, Tom X Nguyen, Raven Klaugh, LangChain4j, Magnesian, Illia Dulskyi, David Ziegler, Mano Prime, Luis Javier Navarrete Lozano, Erik Bjäreholt, 阿明, Nathan Dryer, Alex, Rainer Wilmers, zynix, TL, Joseph William Delisle, John Villwock, Nathan LeClaire, Willem Michiel, Joguhyik, GodLy, OG, Alps Aficionado, Jeffrey Morgan, ReadyPlayerEmma, Tiffany J. Kim, Sebastain Graf, Spencer Kim, Michael Davis, webtim, Talal Aujan, knownsqashed, John Detwiler, Imad Khwaja, Deo Leter, Jerry Meng, Elijah Stavena, Rooh Singh, Pieter, SuperWojo, Alexandros Triantafyllidis, Stephen Murray, Ai Maven, ya boyyy, Enrico Ros, Ken Nordquist, Deep Realms, Nicholas, Spiking Neurons AB, Elle, Will Dee, Jack West, RoA, Luke @flexchar, Viktor Bowallius, Derek Yates, Subspace Studios, jjj, Toran Billups, Asp the Wyvern, Fen Risland, Ilya, NimbleBox.ai, Chadd, Nitin Borwankar, Emre, Mandus, Leonard Tan, Kalila, K, Trailburnt, S_X, Cory Kujawski
310
+
311
+
312
+ Thank you to all my generous patrons and donaters!
313
+
314
+ And thank you again to a16z for their generous grant.
315
+
316
+ <!-- footer end -->
317
+
318
+ <!-- original-model-card start -->
319
+ # Original model card: Defog.ai's Sqlcoder2
320
+
321
+ # Defog SQLCoder
322
+ Defog's SQLCoder is a state-of-the-art LLM for converting natural language questions to SQL queries.
323
+
324
+ [Interactive Demo](https://defog.ai/sqlcoder-demo/) | [🤗 HF Repo](https://huggingface.co/defog/sqlcoder2) | [♾️ Colab](https://colab.research.google.com/drive/1z4rmOEiFkxkMiecAWeTUlPl0OmKgfEu7?usp=sharing) | [🐦 Twitter](https://twitter.com/defogdata)
325
+
326
+ ## TL;DR
327
+ SQLCoder is a 15B parameter model that outperforms `gpt-3.5-turbo` for natural language to SQL generation tasks on our [sql-eval](https://github.com/defog-ai/sql-eval) framework, and significantly outperforms all popular open-source models. When fine-tuned on a given schema, it also outperforms `gpt-4`
328
+
329
+ SQLCoder is fine-tuned on a base StarCoder model.
330
+
331
+ ## Results on novel datasets not seen in training
332
+ | model | perc_correct |
333
+ |-|-|
334
+ | gpt4-2023-10-04 | 82.0 |
335
+ | defog-sqlcoder2 | 74.5 |
336
+ | gpt4-2023-08-28 | 74.0 |
337
+ | defog-sqlcoder-7b | 71.0 |
338
+ | gpt-3.5-2023-10-04 | 66.0 |
339
+ | claude-2 | 64.5 |
340
+ | gpt-3.5-2023-08-28 | 61.0 |
341
+ | claude_instant_1 | 61.0 |
342
+ | text-davinci-003 | 52.5 |
343
+
344
+ ## License
345
+ The code in this repo (what little there is of it) is Apache-2 licensed. The model weights have a `CC BY-SA 4.0` license, with additional responsible use restrictions added. The TL;DR is that you can use and modify the model for any purpose – including commercial use. However, if you modify the weights (for example, by fine-tuning), you must open-source your modified weights under the same license terms.
346
+
347
+ ## Training
348
+ Defog was trained on more than 20,000 human-curated questions. These questions were based on 10 different schemas. None of the schemas in the training data were included in our evaluation framework.
349
+
350
+ You can read more about our [training approach](https://defog.ai/blog/open-sourcing-sqlcoder2-7b/) and [evaluation framework](https://defog.ai/blog/open-sourcing-sqleval/).
351
+
352
+ ## Results by question category
353
+ We classified each generated question into one of 5 categories. The table displays the percentage of questions answered correctly by each model, broken down by category.
354
+ | query_category | gpt-4 | sqlcoder2-15b | sqlcoder-7b | gpt-3.5 | claude-2 | claude-instant | gpt-3 |
355
+ |:-----------------|--------:|----------------:|--------------:|----------:|-----------:|-----------------:|--------:|
356
+ | date | 72 | 76 | 64 | 68 | 52 | 48 | 32 |
357
+ | group_by | 91.4 | 80 | 82.9 | 77.1 | 71.4 | 71.4 | 71.4 |
358
+ | order_by | 82.9 | 77.1 | 74.3 | 68.6 | 74.3 | 74.3 | 68.6 |
359
+ | ratio | 80 | 60 | 54.3 | 37.1 | 57.1 | 45.7 | 25.7 |
360
+ | join | 82.9 | 77.1 | 74.3 | 71.4 | 65.7 | 62.9 | 57.1 |
361
+ | where | 80 | 77.1 | 74.3 | 74.3 | 62.9 | 60 | 54.3 |
362
+
363
+ ## Using SQLCoder
364
+ You can use SQLCoder via the `transformers` library by downloading our model weights from the Hugging Face repo. We have added sample code for [inference](./inference.py) on a [sample database schema](./metadata.sql).
365
+ ```bash
366
+ python inference.py -q "Question about the sample database goes here"
367
+
368
+ # Sample question:
369
+ # Do we get more revenue from customers in New York compared to customers in San Francisco? Give me the total revenue for each city, and the difference between the two.
370
+ ```
371
+
372
+ You can also use a demo on our website [here](https://defog.ai/sqlcoder-demo), or run SQLCoder in Colab [here](https://colab.research.google.com/drive/13BIKsqHnPOBcQ-ba2p77L5saiepTIwu0#scrollTo=ZpbVgVHMkJvC)
373
+
374
+ ## Hardware Requirements
375
+ SQLCoder has been tested on an A100 40GB GPU with `bfloat16` weights. You can also load an 8-bit and 4-bit quantized version of the model on consumer GPUs with 20GB or more of memory – like RTX 4090, RTX 3090, and Apple M2 Pro, M2 Max, or M2 Ultra Chips with 20GB or more of memory.
376
+
377
+ ## Todo
378
+
379
+ - [x] Open-source the v1 model weights
380
+ - [x] Train the model on more data, with higher data variance
381
+ - [ ] Tune the model further with Reward Modelling and RLHF
382
+ - [ ] Pretrain a model from scratch that specializes in SQL analysis
383
+
384
+ <!-- original-model-card end -->