Instructions to use fahmiaziz/qwen3-1.7B-text2sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fahmiaziz/qwen3-1.7B-text2sql with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fahmiaziz/qwen3-1.7B-text2sql") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("fahmiaziz/qwen3-1.7B-text2sql") model = AutoModelForCausalLM.from_pretrained("fahmiaziz/qwen3-1.7B-text2sql") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use fahmiaziz/qwen3-1.7B-text2sql with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fahmiaziz/qwen3-1.7B-text2sql" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fahmiaziz/qwen3-1.7B-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/fahmiaziz/qwen3-1.7B-text2sql
- SGLang
How to use fahmiaziz/qwen3-1.7B-text2sql with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "fahmiaziz/qwen3-1.7B-text2sql" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fahmiaziz/qwen3-1.7B-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "fahmiaziz/qwen3-1.7B-text2sql" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fahmiaziz/qwen3-1.7B-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use fahmiaziz/qwen3-1.7B-text2sql with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
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 fahmiaziz/qwen3-1.7B-text2sql to start chatting
Install Unsloth Studio (Windows)
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 fahmiaziz/qwen3-1.7B-text2sql to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for fahmiaziz/qwen3-1.7B-text2sql to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="fahmiaziz/qwen3-1.7B-text2sql", max_seq_length=2048, ) - Docker Model Runner
How to use fahmiaziz/qwen3-1.7B-text2sql with Docker Model Runner:
docker model run hf.co/fahmiaziz/qwen3-1.7B-text2sql
Fine-tuning Qwen3-1.7B for Text-to-SQL Task
This project demonstrates the fine-tuning of the Qwen3-1.7B language model using a combined and preprocessed dataset for Text-to-SQL generation. The goal is to train the model to generate SQL queries from natural language questions given database schemas.
Dataset
We used the fahmiaziz/text2sql-dataset, which merges examples from:
- Wikisql
- Bird
- Spider
- Synthetic SQL samples
Before training, the dataset was cleaned and filtered by:
- Removing DDL/DML examples (
INSERT,UPDATE,DELETE, etc.) - Deduplicating examples based on semantic hashing of both SQL and questions
- Filtering only SELECT-style analytical queries
Training Format
Since Qwen3 models require a two-part output (<think> + final answer), and our dataset does not contain intermediate reasoning, we left the <think> section empty during fine-tuning.
Example Format:
<|im_start|>system
Given the database schema and the user question, generate the corresponding SQL query.
<|im_end|>
<|im_start|>user
\[SCHEMA]
CREATE TABLE Inclusive\_Housing (Property\_ID INT, Inclusive VARCHAR(10), Property\_Size INT);
INSERT INTO Inclusive\_Housing (Property\_ID, Inclusive, Property\_Size)
VALUES (1, 'Yes', 900), (2, 'No', 1100), (3, 'Yes', 800), (4, 'No', 1200);
\[QUESTION]
What is the average property size in inclusive housing areas?
<|im_end|>
<|im_start|>assistant
<think>
</think>
SELECT AVG(Property\_Size) FROM Inclusive\_Housing WHERE Inclusive = 'Yes';
<|im_end|>
Training Configuration
Due to hardware limitations, full model training was not possible. Instead, we applied LoRA (Low-Rank Adaptation) with the following configuration:
- LoRA rank (
r): 128 - LoRA alpha: 256
- Hardware: Kaggle T4 x2 GPUs
Training Hyperparameters
per_device_train_batch_size = 6,
gradient_accumulation_steps = 2,
warmup_steps = 5,
max_steps = 500,
num_train_epochs = 3,
learning_rate = 1e-4,
fp16 = not is_bf16_supported(),
bf16 = is_bf16_supported(),
logging_steps = 25,
optim = "adamw_8bit",
weight_decay = 0.01,
lr_scheduler_type = "linear",
seed = 3407,
output_dir = "outputs_v4",
dataset_text_field = "text",
max_seq_length = 1024,
Training Results
global_step=500,
training_loss=0.5783241882324218
Evaluation
We evaluated the model using Exact Match (EM) score on a manually selected sample of 100 examples. We get score 50%
Notes
In future iterations, we plan to:
- Add complex/long context schema
- Full Finetuning
Uploaded finetuned model
- Developed by: fahmiaziz
- License: apache-2.0
- Finetuned from model : unsloth/Qwen3-1.7B
This qwen3 model was trained 2x faster with Unsloth and Huggingface's TRL library.
- Downloads last month
- 12
