mav23 commited on
Commit
1a2d178
·
verified ·
1 Parent(s): 629fc49

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +70 -0
  3. sqlcoder2.Q4_0.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ sqlcoder2.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - code
8
+ ---
9
+ # Defog SQLCoder
10
+ Defog's SQLCoder is a state-of-the-art LLM for converting natural language questions to SQL queries.
11
+
12
+ [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)
13
+
14
+ ## TL;DR
15
+ 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`
16
+
17
+ SQLCoder is fine-tuned on a base StarCoder model.
18
+
19
+ ## Results on novel datasets not seen in training
20
+ | model | perc_correct |
21
+ |-|-|
22
+ | gpt4-2023-10-04 | 82.0 |
23
+ | defog-sqlcoder2 | 77.5 |
24
+ | gpt4-2023-08-28 | 74.0 |
25
+ | defog-sqlcoder-7b | 71.0 |
26
+ | gpt-3.5-2023-10-04 | 66.0 |
27
+ | claude-2 | 64.5 |
28
+ | gpt-3.5-2023-08-28 | 61.0 |
29
+ | claude_instant_1 | 61.0 |
30
+ | text-davinci-003 | 52.5 |
31
+
32
+ ## License
33
+ 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.
34
+
35
+ ## Training
36
+ 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.
37
+
38
+ 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/).
39
+
40
+ ## Results by question category
41
+ 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.
42
+ | query_category | gpt-4 | sqlcoder2-15b | sqlcoder-7b | gpt-3.5 | claude-2 | claude-instant | gpt-3 |
43
+ |:-----------------|--------:|----------------:|--------------:|----------:|-----------:|-----------------:|--------:|
44
+ | date | 72 | 80 | 64 | 68 | 52 | 48 | 32 |
45
+ | group_by | 91.4 | 82.9 | 82.9 | 77.1 | 71.4 | 71.4 | 71.4 |
46
+ | order_by | 82.9 | 77.1 | 74.3 | 68.6 | 74.3 | 74.3 | 68.6 |
47
+ | ratio | 80 | 74.3 | 54.3 | 37.1 | 57.1 | 45.7 | 25.7 |
48
+ | join | 82.9 | 74.3 | 74.3 | 71.4 | 65.7 | 62.9 | 57.1 |
49
+ | where | 80 | 77.1 | 74.3 | 74.3 | 62.9 | 60 | 54.3 |
50
+
51
+ ## Using SQLCoder
52
+ 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](https://github.com/defog-ai/sqlcoder/blob/main/inference.py) on a [sample database schema](https://github.com/defog-ai/sqlcoder/blob/main/metadata.sql).
53
+ ```bash
54
+ python inference.py -q "Question about the sample database goes here"
55
+
56
+ # Sample question:
57
+ # 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.
58
+ ```
59
+
60
+ 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)
61
+
62
+ ## Hardware Requirements
63
+ 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.
64
+
65
+ ## Todo
66
+
67
+ - [x] Open-source the v1 model weights
68
+ - [x] Train the model on more data, with higher data variance
69
+ - [ ] Tune the model further with Reward Modelling and RLHF
70
+ - [ ] Pretrain a model from scratch that specializes in SQL analysis
sqlcoder2.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2cf46b0b09c4e00f4b7eab53df9b963010f74b08bde6467a80e960df0d5944fa
3
+ size 9160427264