--- license: apache-2.0 tags: [text-to-sql, in-context-learning, retrieval, small-language-model] base_model: microsoft/Phi-3-mini-4k-instruct datasets: [gretelai/synthetic_text_to_sql] --- # Light-SQL (Gretel): SLM + in-context learning with semantic retrieval Triển khai theo *Light-SQL: A Small Language Model Based Approach Using In-Context Learning for Natural Language to SQL* (Kieu-Trang Nguyen, Quang-Hung Le, ICCIES 2026). **Không fine-tune**: repo này chứa kho 49,969 ví dụ (câu hỏi, SQL, schema rút gọn) từ `gretelai/synthetic_text_to_sql` và các vector embedding (`BAAI/bge-small-en`, chuẩn hóa, float16) cho 3 chiến lược chọn ví dụ (QTSS / MQSS / QRSS). SLM nền: `microsoft/Phi-3-mini-4k-instruct` (tải từ Hugging Face, không đổi). Cách dùng: nạp `example_bank.jsonl` + `emb_question.npy`, embedding câu hỏi mới bằng `BAAI/bge-small-en`, lấy 3 ví dụ có tích vô hướng lớn nhất, dựng prompt `### Instruction / ### Schema / ### Few-shot Examples / ### Question / ### Response`, rồi để SLM sinh SQL (temperature 0). Mã đầy đủ nằm trong notebook đi kèm.