nnul commited on
Commit
408699b
·
verified ·
1 Parent(s): b6a6964

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -41
README.md CHANGED
@@ -1,36 +1,34 @@
1
- nnul/sqlchat: A Conversational AI for SQL Generation
2
 
3
- This repository contains sqlchat, a powerful and efficient language model designed specifically for Text-to-SQL tasks. It can understand natural language questions and database schemas to generate accurate SQL queries, including complex statements for creating and managing tables (Data Definition Language).
4
 
5
- This model is provided as a standalone 4-bit quantized model, optimized for easy deployment and high-performance, low-resource inference. It was built using the Unsloth library to ensure maximum speed and memory efficiency.
6
 
7
- Model Capabilities
8
 
9
- Natural Language to SQL: Translates complex English questions into executable SQL queries.
 
 
 
10
 
11
- Schema-Aware: Understands CREATE TABLE contexts provided in the prompt to generate relevant queries.
12
 
13
- DDL Generation: Capable of generating CREATE TABLE statements, including constraints like PRIMARY KEY and FOREIGN KEY relationships.
14
 
15
- Complex Query Logic: Successfully handles JOINs, aggregations (COUNT, MAX), and sorting (ORDER BY ... LIMIT).
16
-
17
- How to Use
18
-
19
- The easiest way to use sqlchat is with the Unsloth library, which will ensure you get the best performance.
20
-
21
- Prerequisites
22
 
23
  First, install the necessary libraries.
24
 
25
- Generated bash
26
- pip install unsloth
27
  pip install "torch>=2.3.1"
 
28
 
29
- Running Inference
30
 
31
  Here is a simple, reusable Python script to run inference with the model.
32
 
33
- Generated python
34
  import torch
35
  from unsloth import FastLanguageModel
36
  from transformers import TextStreamer
@@ -92,14 +90,11 @@ CREATE TABLE students (student_id INTEGER PRIMARY KEY, student_name VARCHAR(255)
92
  CREATE TABLE courses (course_id INTEGER PRIMARY KEY, course_title VARCHAR(255));
93
  """
94
  )
95
- IGNORE_WHEN_COPYING_START
96
- content_copy
97
- download
98
- Use code with caution.
99
- Python
100
- IGNORE_WHEN_COPYING_END
101
- Expected Output
102
- Generated code
103
  User Instruction: Which department has the most number of employees?
104
 
105
  Model Output:
@@ -113,22 +108,19 @@ Model Output:
113
  ---------------------------------
114
  CREATE TABLE student_enrollment (student_id INTEGER, course_id INTEGER, PRIMARY KEY (student_id, course_id), FOREIGN KEY (student_id) REFERENCES students(student_id), FOREIGN KEY (course_id) REFERENCES courses(course_id));
115
  ---------------------------------
116
- IGNORE_WHEN_COPYING_START
117
- content_copy
118
- download
119
- Use code with caution.
120
- IGNORE_WHEN_COPYING_END
121
- Performance
122
 
123
- The model was benchmarked on an NVIDIA A40 GPU. In a batch-processing scenario, it achieves a throughput of ~55-70 tokens/second. Single-prompt latency is well within real-time requirements for interactive applications.
124
 
125
- Peak VRAM Usage (Inference): ~6.1 GB
126
 
127
- Prompt Template
128
 
129
  To get the best results, your prompts should follow this structure:
130
 
131
- Generated code
132
  <|im_start|>system
133
  You are a helpful assistant that generates SQL queries based on natural language questions and database schemas.<|im_end|>
134
  <|im_start|>user
@@ -138,8 +130,4 @@ You are a helpful assistant that generates SQL queries based on natural language
138
  ### Context:
139
  {The CREATE TABLE statements for the relevant tables}<|im_end|>
140
  <|im_start|>assistant
141
- IGNORE_WHEN_COPYING_START
142
- content_copy
143
- download
144
- Use code with caution.
145
- IGNORE_WHEN_COPYING_END
 
1
+ # `nnul/sqlchat`: A Conversational AI for SQL Generation
2
 
3
+ This repository contains `sqlchat`, a powerful and efficient language model designed specifically for **Text-to-SQL** tasks. It can understand natural language questions and database schemas to generate accurate SQL queries, including complex statements for creating and managing tables (Data Definition Language).
4
 
5
+ This model is provided as a standalone 4-bit quantized model, optimized for easy deployment and high-performance, low-resource inference. It was built using the [Unsloth](https://github.com/unslothai/unsloth) library to ensure maximum speed and memory efficiency.
6
 
7
+ ## Model Capabilities
8
 
9
+ * **Natural Language to SQL:** Translates complex English questions into executable SQL queries.
10
+ * **Schema-Aware:** Understands `CREATE TABLE` contexts provided in the prompt to generate relevant queries.
11
+ * **DDL Generation:** Capable of generating `CREATE TABLE` statements, including constraints like `PRIMARY KEY` and `FOREIGN KEY` relationships.
12
+ * **Complex Query Logic:** Successfully handles `JOIN`s, aggregations (`COUNT`, `MAX`), and sorting (`ORDER BY ... LIMIT`).
13
 
14
+ ## How to Use
15
 
16
+ The easiest way to use `sqlchat` is with the Unsloth library, which will ensure you get the best performance.
17
 
18
+ ### Prerequisites
 
 
 
 
 
 
19
 
20
  First, install the necessary libraries.
21
 
22
+ ```bash
23
+ pip install "unsloth[conda]"
24
  pip install "torch>=2.3.1"
25
+ ```
26
 
27
+ ### Running Inference
28
 
29
  Here is a simple, reusable Python script to run inference with the model.
30
 
31
+ ```python
32
  import torch
33
  from unsloth import FastLanguageModel
34
  from transformers import TextStreamer
 
90
  CREATE TABLE courses (course_id INTEGER PRIMARY KEY, course_title VARCHAR(255));
91
  """
92
  )
93
+ ```
94
+
95
+ ### Expected Output
96
+
97
+ ```
 
 
 
98
  User Instruction: Which department has the most number of employees?
99
 
100
  Model Output:
 
108
  ---------------------------------
109
  CREATE TABLE student_enrollment (student_id INTEGER, course_id INTEGER, PRIMARY KEY (student_id, course_id), FOREIGN KEY (student_id) REFERENCES students(student_id), FOREIGN KEY (course_id) REFERENCES courses(course_id));
110
  ---------------------------------
111
+ ```
112
+
113
+ ## Performance
 
 
 
114
 
115
+ The model was benchmarked on an NVIDIA A40 GPU. In a batch-processing scenario, it achieves a throughput of **~55-70 tokens/second**. Single-prompt latency is well within real-time requirements for interactive applications.
116
 
117
+ * **Peak VRAM Usage (Inference):** ~6.1 GB
118
 
119
+ ## Prompt Template
120
 
121
  To get the best results, your prompts should follow this structure:
122
 
123
+ ```
124
  <|im_start|>system
125
  You are a helpful assistant that generates SQL queries based on natural language questions and database schemas.<|im_end|>
126
  <|im_start|>user
 
130
  ### Context:
131
  {The CREATE TABLE statements for the relevant tables}<|im_end|>
132
  <|im_start|>assistant
133
+ ```