Views
No views yet
Qwen2.5-Coder-1.5B-Instruct model on the extensive Spider dataset using Unsloth.Qwen/Qwen2.5-Coder-1.5B-InstructQ4_K_M Quantized)SELECT * FROM table, Caden has been aggressively fine-tuned to master complex relationships:LEFT JOIN and INNER JOIN appropriately.WHERE salary > (SELECT AVG(salary) FROM...)).RANK(), ROW_NUMBER(), and PARTITION BY.INTERSECT, EXCEPT, and UNION.1[
2 {
3 "role": "system",
4 "content": "You are Caden, an expert SQL engineer and helpful database assistant. Your primary task is to write single, accurate, and efficient SQL queries based on the given database schema and user questions."
5 },
6 {
7 "role": "user",
8 "content": "### Database Schema DDL:\nCREATE TABLE head (age INT, name VARCHAR(20));\n\n### User Request:\nFind names of heads whose age is older than 50.\n\nGenerate the SQL query that answers the user request."
9 }
10]SELECT name FROM head WHERE age > 50;caden-sql-1.5b-q4_k_m.gguf file from the Files tab.Modelfile in the same folder with this configuration:1FROM ./caden-sql-1.5b-q4_k_m.gguf
2SYSTEM """You are Caden, an expert SQL engineer and helpful database assistant. Your primary task is to write single, accurate, and efficient SQL queries based on the given database schema and user questions.
3
4Follow these strict rules when the user asks for data or a query:
51. Generate valid SQL syntax only.
62. Use ONLY the table and column names present in the provided schema DDL.
73. Carefully observe foreign key relationships when performing JOIN operations.
84. Unless explicitly requested by the user, only produce read-only queries (SELECT).
95. Provide your SQL query enclosed in a single ```sql ... ``` block.
10
11If the user asks a general conversational question, respond conversationally and naturally without generating SQL."""ollama create caden-sql -f Modelfileollama run caden-sql1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_name = "loftytechlabsdev/Caden-SQL-1.5B"
5
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 torch_dtype=torch.float16,
9 device_map="auto"
10)
11tokenizer = AutoTokenizer.from_pretrained(model_name)
12
13# Format the message using ChatML
14messages = [
15 {
16 "role": "system",
17 "content": "You are Caden, an expert SQL engineer and helpful database assistant. Your primary task is to write single, accurate, and efficient SQL queries based on the given database schema and user questions."
18 },
19 {
20 "role": "user",
21 "content": "### Database Schema DDL:\nCREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(50), city VARCHAR(50));\n\n### User Request:\nHow many customers are from London?\n\nGenerate the SQL query that answers the user request."
22 }
23]
24
25prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
26inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
27
28outputs = model.generate(**inputs, max_new_tokens=256, use_cache=True)
29response = tokenizer.decode(outputs[0][len(inputs.input_ids[0]):], skip_special_tokens=True)
30print(response)unsloth/Qwen2.5-Coder-1.5B-Instructr = 16, lora_alpha = 16)xlangai/spider / philikai/SQL_Spider_DDL (containing 10,000+ text-to-SQL alignment examples)adamw_8bit2e-4linear0.01