xlangai/spider
Viewer • Updated • 8.03k • 8.81k • 174
How to use Neeharika20/qwen3-4b-nl2sql with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Neeharika20/qwen3-4b-nl2sql to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Neeharika20/qwen3-4b-nl2sql to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Neeharika20/qwen3-4b-nl2sql to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="Neeharika20/qwen3-4b-nl2sql",
max_seq_length=2048,
)✅ This repository contains merged model weights and can be used directly with
AutoModelForCausalLM.from_pretrained.
This model is a fine-tuned version of Qwen3-4B, optimized to translate natural language questions into executable SQL queries using database schema context. It is designed for structured data querying and analytics use cases rather than open-ended conversation.
The model was trained using schema-aware instruction prompts:
### Instruction:
Convert the question into an SQL query.
### Database Schema:
<Table and column definitions>
### Question:
<User query>
### SQL:
from unsloth import FastLanguageModel
import torch
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="Neeharika20/qwen3-4b-nl2sql",
max_seq_length=2048,
load_in_4bit=True,
device_map="auto",
)
model.eval()
prompt = """### Instruction:
Convert the question into an SQL query.
### Database Schema:
CREATE TABLE students(
id INT,
name TEXT,
age INT
);
### Question:
List the names of all students.
### SQL:
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.2,
do_sample=False,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Base model
Qwen/Qwen3-4B-Instruct-2507