NaturalSQL
NaturalSQL is a series of large language models fine tuned for Natural Language to SQL generation.
Benchmarks
NaturalSQL-6.7B-v0 surpasses comparable models in performance on the SQL-Eval benchmark, outshining even its peers in size and scope. NaturalSQL even beats models such as Claude and GPT-3.5-Turbo on Text to SQL instructions for novel datasets.
Percentage of Correct SQL Queries on Novel Schemas

NaturalSQL-6.7B-v0 outperforms Text to SQL models double its size in the categories of ratio, joins, and order_by, queries.

Date queries will be a strong area of focus in the next iteration.
SQL-Eval Results by Category

Complex SQL Instructions
NaturalSQL was finetuned on complex questions and shows great results for its size on multi-part questions that entail multiple joins, sub queries, etc. Here is a post comparing NaturalSQL-6.7B against a similar sized model with 5 compound questions.
Example Question
Determine the customer with the largest total order value last month, and list all the products and their quantities they ordered.
1WITH
2 LastMonthOrders AS (
3 SELECT
4 o.customerid,
5 o.orderid,
6 op.productid,
7 op.quantity,
8 p.productname,
9 op.quantity * p.unitprice AS total_order_value
10 FROM
11 orders o
12 JOIN order_details op ON o.orderid = op.orderid
13 JOIN products p ON op.productid = p.productid
14 WHERE
15 o.orderdate >= date_trunc('month', CURRENT_DATE) - INTERVAL '1 month'
16 AND o.orderdate < date_trunc('month', CURRENT_DATE)
17 ),
18 CustomerTotalOrderValue AS (
19 SELECT
20 customerid,
21 SUM(total_order_value) AS total_value
22 FROM
23 LastMonthOrders
24 GROUP BY
25 customerid
26 ORDER BY
27 total_value DESC
28 LIMIT
29 1
30 )
31SELECT
32 c.customerid,
33 c.companyname,
34 lm.productid,
35 lm.productname,
36 lm.quantity
37FROM
38 CustomerTotalOrderValue ctov
39 JOIN LastMonthOrders lm ON ctov.customerid = lm.customerid
40 JOIN customers c ON c.customerid = lm.customerid;