A 1.3 bn SQL model that outperforms most SQL expert models and chatgpt on popular benchmarks.
This is a distilled model built on the deepseek base model.
Please refer to
https://huggingface.co/PipableAI/pip-library-etl-1.3b for our state of the art model.
We used softmax cross entropy and a modified form of policy grad along with Q loss, optimized in an EM set up.
Loss behaviour in the set up mentioned above -
For benchmarking purposes we are using Semantic Evaluation for Text-to-SQL with
Distilled Test Suites, an officially accepted evaluation framework for Spider, SParC, and CoSQL which was proposed by a research team of Yale and Berkeley.
The benchmark contains 2200 test data points
Here is the link to run the evaluation:
We have also benchmarked it on defog eval.
It contains 200 test data points handpicked by defog team.
Here is the link to it:
The model is open source under apache 2.0. License
1prompt = f"""<schema>{schema}</schema>
2<question>{question}</question>
3<sql>"""
1from transformers import AutoModelForCausalLM, AutoTokenizer
2device = "cuda"
3model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-sql-1.3b")
4tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-sql-1.3b")
5
6inputs = tokenizer(text, return_tensors="pt")
7outputs = model.generate(**inputs, max_new_tokens=200)
8print(tokenizer.decode(outputs[0], skip_special_tokens=True).split('<sql>')[1].split('</sql>')[0])
1from transformers import FlaxAutoModelForCausalLM, AutoTokenizer
2device = "cuda"
3model = FlaxAutoModelForCausalLM.from_pretrained("PipableAI/pip-sql-1.3b",from_pt=True)
4tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-sql-1.3b")
5
6inputs = tokenizer(text, return_tensors="jax")
7outputs = model.generate(**inputs, max_new_tokens=200)
8print(tokenizer.decode(outputs[0], skip_special_tokens=True).split('<sql>')[1].split('</sql>')[0])
1CREATE TABLE Products (
2 product_id number,
3 parent_product_id number,
4 product_name text,
5 product_price number,
6 product_color text,
7 product_size text,
8 product_description text);
9
10CREATE TABLE Customers (
11 customer_id number,
12 gender_code text,
13 customer_first_name text,
14 customer_middle_initial text,
15 customer_last_name text,
16 email_address text,
17 login_name text,
18 login_password text,
19 phone_number text,
20 address_line_1 text,
21 town_city text,
22 county text,
23 country text);
24
25CREATE TABLE Customer_Payment_Methods (
26 customer_id number,
27 payment_method_code text);
28
29CREATE TABLE Invoices (
30 invoice_number number,
31 invoice_status_code text,
32 invoice_date time);
33
34CREATE TABLE Orders (
35 order_id number,
36 customer_id number,
37 order_status_code text,
38 date_order_placed time);
39
40CREATE TABLE Order_Items (
41 order_item_id number,
42 product_id number,
43 order_id number,
44 order_item_status_code text);
45
46CREATE TABLE Shipments (
47 shipment_id number,
48 order_id number,
49 invoice_number number,
50 shipment_tracking_number text,
51 shipment_date time);
52
53CREATE TABLE Shipment_Items (
54 shipment_id number,
55 order_item_id number);
What are the email address, town and county of the customers who are of the least common gender?
What are the product price and the product size of the products whose price is above average?
Which customers did not make any orders? List the first name, middle initial and last name.