Instructions to use distil-labs/distil-qwen3-4b-text2sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use distil-labs/distil-qwen3-4b-text2sql with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="distil-labs/distil-qwen3-4b-text2sql") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("distil-labs/distil-qwen3-4b-text2sql") model = AutoModelForCausalLM.from_pretrained("distil-labs/distil-qwen3-4b-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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use distil-labs/distil-qwen3-4b-text2sql with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "distil-labs/distil-qwen3-4b-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": "distil-labs/distil-qwen3-4b-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/distil-labs/distil-qwen3-4b-text2sql
- SGLang
How to use distil-labs/distil-qwen3-4b-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 "distil-labs/distil-qwen3-4b-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": "distil-labs/distil-qwen3-4b-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 "distil-labs/distil-qwen3-4b-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": "distil-labs/distil-qwen3-4b-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use distil-labs/distil-qwen3-4b-text2sql with Docker Model Runner:
docker model run hf.co/distil-labs/distil-qwen3-4b-text2sql
Distillation approach and SQL dialect coverage
Interesting work on Text2SQL distillation β the synthetic dataset approach (distil-labs/text2sql-synthetic) is a smart way to get training scale without manual annotation overhead.
I'm curious about the SQL dialect coverage. Does the model handle dialect-specific syntax (PostgreSQL JSON operators, MySQL LIMIT OFFSET, T-SQL TOP)? We've seen that models trained on generic SQL often struggle with production databases where query patterns differ significantly from textbook examples.
Also, have you evaluated on cross-domain schemas? The Text2SQL generalization gap is usually most visible when table names and relationships don't match training distribution β would be useful to know how this distillation approach handles schema shifts.
Thanks for the questions!
Dialect coverage: this model is SQLite-only for now. The distillation approach is dialect-agnostic though - you'd just need seed examples and a teacher that handles the target dialect, and the pipeline generates dialect-specific synthetic data the same way. Haven't done it yet, but it's on our radar.
Cross-domain schemas: the eval set uses schemas unseen during training, so the reported numbers (80% LLM-as-a-Judge, 60% exact match) do reflect some schema shift robustness. We haven't broken it down by domain distance yet.
If you have a specific dialect or domain you'd like to test, happy to collaborate. Always good to see where things break!
Thanks for your reply,
The 80% LLM-judge vs 60% exact match gap is interesting β that delta usually comes from queries that are structurally valid but fail on execution. Have you measured execution accuracy against a live SQLite instance? That's the most unforgiving signal.
On collaboration.. I'm building a Text2SQL layer for sudanese Arabic-annotated schemas. Dialect isn't the problem there, cross-lingual schema grounding is. If PostgreSQL support is on your roadmap, happy to stress-test it against that kind of distribution shift.
Thanks in advance
Good point on execution accuracy - we haven't run generated queries against a live SQLite instance yet. Right now the eval is LLM-as-a-Judge and exact match only. You're right that the gap between the two likely includes structurally valid but non-executable queries, and execution accuracy would be the cleanest signal. It's on our list.
The cross-lingual schema grounding problem sounds really interesting - that's a distribution shift we haven't explored at all. To clarify though, PostgreSQL support isn't on our roadmap as a built-in feature. But you could train a dialect-specific model yourself using our platform (distillabs.ai) with the right seed examples and teacher. If you'd like to try it for your Arabic-annotated schema use case, happy to give you free training credits.
Feel free to reach out directly - jacek@distillabs.ai - and we can set that up.