SQL-Assist

Natural Language to Executable SQL & Explanations

Base Model Dataset Method License


SQL-Assist

SQL-Assist is a lightweight, high-efficiency language model fine-tuned from Qwen/Qwen2.5-0.5B-Instruct. It translates natural language database prompts into executable SQL statements along with step-by-step query explanations, taking database schemas into context.

The adapter weights were trained using Low-Rank Adaptation (LoRA) and subsequently merged back into the full base model, enabling direct inference through Hugging Face transformers without needing additional PEFT wrapper dependencies.

Model Details

Model Description

  • Developed by: Anikolte
  • Model type: Causal Language Model (Fine-tuned & Merged)
  • Language(s) (NLP): English
  • License: Apache-2.0
  • Finetuned from model: Qwen/Qwen2.5-0.5B-Instruct

Model Sources

Uses

Direct Use

SQL-Assist is intended to take natural language text queries along with an optional or explicit database schema context and produce standard SQL code alongside a plain-language technical explanation of the generated query.

Out-of-Scope Use

  • Automatic execution of unvalidated DDL/DML queries on production database systems without human oversight.
  • General non-database conversation or multi-turn non-technical chat.

Bias, Risks, and Limitations

  • Context Window Limitation: The sequence length was truncated to 128 tokens during fine-tuning. Database schemas or queries exceeding this token limit might get truncated or lose structural context during generation.
  • SQL Dialect Scope: Outputs default primarily to standard ANSI SQL and SQLite syntax styles present in the training dataset distribution.

Recommendations

Users are strongly recommended to inspect generated SQL queries prior to running them against live production databases to prevent accidental data modification or query syntax errors.

How to Get Started with the Model

Since the adapter weights have been merged into the base architecture, you can load and run inference directly using transformers:

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "Anikolte/Sql_Assist"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

prompt = "Find the top 5 customers by total spending in 2023."
context = "CREATE TABLE orders (customer_id INT, amount FLOAT, order_date DATE);"

input_text = f"{prompt}\n{context}\n"
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens=150)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Downloads last month
35
Safetensors
Model size
0.5B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Anikolte/Sql_Assist

Adapter
(690)
this model

Dataset used to train Anikolte/Sql_Assist