gregwdata/defog-sqlcoder-q8 🔢✓📝 → 📝
About
Defog's SQLCoder is a state-of-the-art LLM for converting natural language questions to SQL queries. SQLCoder is a 15B parameter fine-tuned on a base StarCoder model.

Example Output
Prompt:
"Which salesperson made the most sales?"
Output
SELECT salespeople.name,
sum(sales.quantity) AS total_sales
FROM salespeople join sales on salespeople.salesperson_id = sales.salesperson_id
GROUP BY salespeople.name
ORDER BY total_sales DESC
LIMIT 1;
sum(sales.quantity) AS total_sales
FROM salespeople join sales on salespeople.salesperson_id = sales.salesperson_id
GROUP BY salespeople.name
ORDER BY total_sales DESC
LIMIT 1;
Performance Metrics
22.27s
Prediction Time
473.86s
Total Time
All Input Parameters
{ "seed": -1, "debug": false, "prompt": "Which salesperson made the most sales?", "num_beams": 5, "max_length": 1200, "prompt_template": "### Instructions:\nYour task is convert a question into a SQL query, given a Postgres database schema.\nAdhere to these rules:\n- **Deliberately go through the question and database schema word by word** to appropriately answer the question\n- **Use Table Aliases** to prevent ambiguity. For example, `SELECT table1.col1, table2.col1 FROM table1 JOIN table2 ON table1.id = table2.id`.\n- When creating a ratio, always cast the numerator as float\n\n### Input:\nGenerate a SQL query that answers the question `{user_question}`.\nThis query will run on a database whose schema is represented in this string:\n{table_metadata_string}\n\n### Response:\nBased on your instructions, here is the SQL query I have generated to answer the question `{user_question}`:\n```sql", "schema_metadata": "CREATE TABLE products (\n product_id INTEGER PRIMARY KEY, -- Unique ID for each product\n name VARCHAR(50), -- Name of the product\n price DECIMAL(10,2), -- Price of each unit of the product\n quantity INTEGER -- Current quantity in stock\n);\n\nCREATE TABLE customers (\n customer_id INTEGER PRIMARY KEY, -- Unique ID for each customer\n name VARCHAR(50), -- Name of the customer\n address VARCHAR(100) -- Mailing address of the customer\n);\n\nCREATE TABLE salespeople (\n salesperson_id INTEGER PRIMARY KEY, -- Unique ID for each salesperson \n name VARCHAR(50), -- Name of the salesperson\n region VARCHAR(50) -- Geographic sales region \n);\n\nCREATE TABLE sales (\n sale_id INTEGER PRIMARY KEY, -- Unique ID for each sale\n product_id INTEGER, -- ID of product sold\n customer_id INTEGER, -- ID of customer who made purchase\n salesperson_id INTEGER, -- ID of salesperson who made the sale\n sale_date DATE, -- Date the sale occurred \n quantity INTEGER -- Quantity of product sold\n);\n\nCREATE TABLE product_suppliers (\n supplier_id INTEGER PRIMARY KEY, -- Unique ID for each supplier\n product_id INTEGER, -- Product ID supplied\n supply_price DECIMAL(10,2) -- Unit price charged by supplier\n);\n\n-- sales.product_id can be joined with products.product_id\n-- sales.customer_id can be joined with customers.customer_id \n-- sales.salesperson_id can be joined with salespeople.salesperson_id\n-- product_suppliers.product_id can be joined with products.product_id\n" }
Input Parameters
- seed
- Set seed for reproducible outputs. Set to -1 for random seed.
- debug
- provide debugging output in logs
- prompt (required)
- Text prompt
- num_beams
- Number of beams for beam search
- max_length
- Maximum number of tokens to generate. A word is generally 2-3 tokens
- prompt_template
- Prompt template for SQLcoder - see https://github.com/defog-ai/sqlcoder/blob/main/prompt.md . Must contain {user_question} and {table_metadata_string} parameters.
- schema_metadata
- Description of database schema. See https://github.com/defog-ai/sqlcoder/blob/main/metadata.sql
Output Schema
Output
Version Details
- Version ID
0a9abc0d143072fd5d8920ad90b8fbaafaf16b10ffdad24bd897b5bffacfce0b
- Version Created
- August 25, 2023