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 functions vร  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).
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for giangkh19/qwen3.5-4b-sql

Finetuned
Qwen/Qwen3.5-4B
Finetuned
(607)
this model