Instructions to use giangkh19/qwen3.5-4b-sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Local Apps Settings
- Unsloth Desktop
Qwen3.5-4B-Text2SQL: DeepSeek-Style Reasoning & Multi-Table Specialist (GGUF & LoRA)
Mรด hรฌnh chuyรชn sรขu vแป Text-to-SQL phแปฉc tแบกp, ฤฦฐแปฃc fine-tune tแปซ Qwen/Qwen3.5-4B bแบฑng cรดng nghแป QLoRA 4-bit (Unsloth) trรชn tแบญp dแปฏ liแปu tuyแปn chแปn 17.000 mแบซu nรขng cao (kแบฟt hแปฃp tแปซ Gretel AI, Spider, vร BIRD-Bench).
Mรด hรฌnh hแป trแปฃ Native Reasoning (<think> ... </think>), tแปฑ ฤแปng suy luแบญn cแบฅu trรบc bแบฃng, liรชn kแบฟt khรณa ngoแบกi vร ฤiแปu kiแปn logic trฦฐแปc khi sinh cรขu lแปnh SQL chuแบฉn SQLite.
๐ Cรกch Chแบกy Nhanh Bแบฑng Ollama (1 Dรฒng Lแปnh)
Khรดng cแบงn tแบฃi file thแปง cรดng, Ollama hแป trแปฃ kรฉo trแปฑc tiแบฟp tแปซ Hugging Face:
ollama run hf.co/giangkh19/qwen3.5-4b-sql-gguf:Q4_K_M
Yรชu cแบงu phแบงn cแปฉng: Chแบกy siรชu mฦฐแปฃt trรชn mรกy tรญnh cรก nhรขn (chแป cแบงn 4GB VRAM GPU nhฦฐ GTX 1650 hoแบทc 8GB RAM nแบฟu chแบกy CPU).
๐ฏ Cแบฅu Trรบc Prompt Chuแบฉn (ChatML Format)
<|im_start|>system
You are a SQLite expert. Given the database schema, write the correct SQL query.
### DATABASE SCHEMA:
CREATE TABLE customers (id INT PRIMARY KEY, name TEXT, tier TEXT);
CREATE TABLE orders (order_id INT, customer_id INT, amount REAL, FOREIGN KEY(customer_id) REFERENCES customers(id));
<|im_end|>
<|im_start|>user
Find top 3 VIP customers with total spent over 500?
<|im_end|>
<|im_start|>assistant
<think>
1. Identify target tables: 'customers' and 'orders'.
2. Join condition: customers.id = orders.customer_id.
3. Filter conditions: tier = 'VIP'.
4. Aggregation: SUM(amount) grouped by customers.id having sum > 500.
5. Sort descending and limit to 3.
</think>
SELECT c.name, SUM(o.amount) AS total_spent
FROM customers c
JOIN orders o ON c.id = o.customer_id
WHERE c.tier = 'VIP'
GROUP BY c.id, c.name
HAVING total_spent > 500
ORDER BY total_spent DESC
LIMIT 3;
<|im_end|>
๐ ฤแบทc ฤiแปm Tแบญp Dแปฏ Liแปu Huแบฅn Luyแปn (17.000 Mแบซu Khรณ)
ฤรฃ loแบกi bแป 100% cรกc cรขu ฤฦกn giแบฃn (1 bแบฃng). Toร n bแป dแปฏ liแปu ฤฦฐแปฃc chแปn lแปc khแบฏt khe:
- Multi-table JOINs (70%+): Liรชn kแบฟt khรณa ngoแบกi tแปซ 2 ฤแบฟn 4 bแบฃng lแปng nhau.
- Multi-conditions: Tแปi thiแปu 2 ฤiแปu kiแปn lแปc logic (
AND/OR), xแปญ lรฝ ngร y thรกng (strftime), tรญnh toรกn tแปท lแป. - Hร m nรขng cao:
GROUP BY,HAVING,CASE WHEN,UNION,EXCEPT,WINDOW functionsvรCTEs.
โ๏ธ Cแบฅu Hรฌnh Fine-Tuning (Unsloth QLoRA)
- Base Model:
Qwen/Qwen3.5-4B(4-bit NF4 Quantization) - LoRA Parameters: Rank $r = 16$, $lpha = 32$, Target 7 modules (
q, k, v, o, gate, up, down) - Loss Masking:
train_on_responses_only(chแป tรญnh ฤiแปm phแบกt trรชn cรขu lแปnh SQL, khรดng phแบกt trรชn Schema) - Hardware: Huแบฅn luyแปn trรชn NVIDIA RTX 3080 Ti (12GB) vแปi BF16 native trong ~2 giแป.
- Final Loss: ฤแบกt mแปฉc ~0.35 (Loss cแปฑc kแปณ ฤแบนp, khรดng overfitting).