Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: onekq-ai/OneSQL-v0.1-Qwen-7B
|
| 3 |
+
tags:
|
| 4 |
+
- text-generation-inference
|
| 5 |
+
- transformers
|
| 6 |
+
- qwen2
|
| 7 |
+
- mlx
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
language:
|
| 10 |
+
- en
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Introduction
|
| 14 |
+
|
| 15 |
+
This model is the MLX version of [OneSQL-v0.1-Qwen-7B](https://huggingface.co/onekq-ai/OneSQL-v0.1-Qwen-7B). It is made for Apple Silicon.
|
| 16 |
+
|
| 17 |
+
# Performances
|
| 18 |
+
|
| 19 |
+
The self-evaluation EX score of the original model is **56.19** (compared to **63.33** by the 32B model on the [BIRD leaderboard](https://bird-bench.github.io/).
|
| 20 |
+
The self-evaluation EX score of this AWQ model is **51.69**.
|
| 21 |
+
|
| 22 |
+
# Quick start
|
| 23 |
+
|
| 24 |
+
To use this model, craft your prompt to start with your database schema in the form of **CREATE TABLE**, followed by your natural language query preceded by **--**.
|
| 25 |
+
Make sure your prompt ends with **SELECT** in order for the model to finish the query for you. There is no need to set other parameters like temperature or max token limit.
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from mlx_lm import load, generate
|
| 29 |
+
|
| 30 |
+
model, tokenizer = load("model="onekq-ai/OneSQL-v0.1-Qwen-7B-MLX-4bit")
|
| 31 |
+
|
| 32 |
+
prompt="""CREATE TABLE students (
|
| 33 |
+
id INTEGER PRIMARY KEY,
|
| 34 |
+
name TEXT,
|
| 35 |
+
age INTEGER,
|
| 36 |
+
grade TEXT
|
| 37 |
+
);
|
| 38 |
+
|
| 39 |
+
-- Find the three youngest students
|
| 40 |
+
SELECT """
|
| 41 |
+
|
| 42 |
+
response = generate(model, tokenizer, f"<|im_start|>system\nYou are a SQL expert. Return code only.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n")
|
| 43 |
+
print(response)
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
The model response is the finished SQL query without **SELECT**
|
| 47 |
+
```sql
|
| 48 |
+
* FROM students ORDER BY age ASC LIMIT 3
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
# User Experience
|
| 52 |
+
|
| 53 |
+
Speed benchmark of this model is obtained on a MacBook Air with M1 processor and 8GB of RAM, the lower bound of Apple Silicon.
|
| 54 |
+
On average, it took 16 seconds to generate a SQL query at 9 characters per second.
|