许可证:apache-2.0
数据集:
- PipableAI/pip-txt-to-sql-spider-bird-dataset
语言:
- en
评估指标:
- accuracy
标签:
- sql
- code
- text2sql
- instruction_tuned
- basemodel
- jax
- pytorch
- text-generation-inference
库名称:transformers
流水线标签:text-generation
小部件示例:
- 文本:>
CREATE TABLE system(JobID: String,GID: String, UID: String,
Start:Time(yyyy/mm/dd), End: Time,ElapsedRaw: Time, CPUTimeRAW: Time,NCPUS:
Number,NNodes: Number, NodeList: List, State:String, Timelimit:
Time);获取2023年1月20日开始、2023年2月14日结束且作业ID为20的作业的UID和作业ID
示例标题:example
pipSQL-1.3b
pipableAi
colab笔记本
我们构建了什么?
一个13亿参数的SQL模型,在多个流行基准测试中超越了大多数SQL专家模型和ChatGPT。
这是基于deepseek基础模型提炼的模型。
请访问 https://huggingface.co/PipableAI/pip-library-etl-1.3b 查看我们的前沿模型。
如何构建的?
我们使用了softmax交叉熵、改进的策略梯度以及Q损失,并在EM框架下进行优化。
在上述框架中的损失行为如下:

基准测试:
我们使用“语义评估文本到SQL蒸馏测试套件”进行基准测试,这是耶鲁和伯克利研究团队提出的官方认可的Spider、SParC和CoSQL评估框架。
该基准包含2200个测试数据点。
以下是运行评估的链接:
测试套件SQL评估
模型 |
简单 |
中等 |
困难 |
额外 |
sqlcoder-7b-2 |
72.0 |
58.0 |
40.6 |
37.3 |
pipSQL-1.3b |
78.5 |
57.5 |
42.1 |
28.3 |
pipSQL-7b |
63.0 |
40.0 |
30.2 |
25.0 |
sqlcoder-7b |
60.6 |
48.2 |
28.3 |
20.4 |
gpt-3.5 |
58.8 |
44.7 |
31.0 |
28.4 |
我们还对defog评估进行了基准测试。
它包含defog团队手工挑选的200个测试数据点。
以下是链接:
Defog SQL评估
以下是结果:

许可证
该模型在apache 2.0许可证下开源。
使用方法
安装
pip install transformers
提示模板
prompt = f"""<schema>{schema}</schema>
<question>{question}</question>
<sql>"""
PyTorch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-sql-1.3b")
tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-sql-1.3b")
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split('<sql>')[1].split('</sql>')[0])
Flax
from transformers import FlaxAutoModelForCausalLM, AutoTokenizer
device = "cuda"
model = FlaxAutoModelForCausalLM.from_pretrained("PipableAI/pip-sql-1.3b",from_pt=True)
tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-sql-1.3b")
inputs = tokenizer(text, return_tensors="jax")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split('<sql>')[1].split('</sql>')[0])
示例
数据库模式
CREATE TABLE Products (
product_id number,
parent_product_id number,
product_name text,
product_price number,
product_color text,
product_size text,
product_description text);
CREATE TABLE Customers (
customer_id number,
gender_code text,
customer_first_name text,
customer_middle_initial text,
customer_last_name text,
email_address text,
login_name text,
login_password text,
phone_number text,
address_line_1 text,
town_city text,
county text,
country text);
CREATE TABLE Customer_Payment_Methods (
customer_id number,
payment_method_code text);
CREATE TABLE Invoices (
invoice_number number,
invoice_status_code text,
invoice_date time);
CREATE TABLE Orders (
order_id number,
customer_id number,
order_status_code text,
date_order_placed time);
CREATE TABLE Order_Items (
order_item_id number,
product_id number,
order_id number,
order_item_status_code text);
CREATE TABLE Shipments (
shipment_id number,
order_id number,
invoice_number number,
shipment_tracking_number text,
shipment_date time);
CREATE TABLE Shipment_Items (
shipment_id number,
order_item_id number);
问题与SQL查询
- 最少见性别的客户的电子邮件地址、城市和县是什么?
SELECT email_address, town_city, county FROM customers GROUP BY gender_code ORDER BY count(*) ASC LIMIT 1
- 价格高于平均水平的产品的产品价格和尺寸是什么?
SELECT product_price, product_size FROM products WHERE product_price > (SELECT avg(product_price) FROM products)
- 哪些客户没有下过订单?列出他们的名字、中间名首字母和姓氏。
SELECT T1.customer_first_name, T1.customer_middle_initial, T1.customer_last_name FROM Customers AS T1 WHERE T1.customer_id NOT IN (SELECT T2.customer_id FROM Orders AS T2)
团队
Avi Kothari, Pratham Gupta, Ritvik Aryan Kalra, Rohan Bhatial, Soham Acharya