๐ Natural Language to SQL
SLM Text-to-SQL
Translates natural language questions into valid SQL queries against custom database schemas offline.
๐ Overview & Capabilities
Translates natural language questions into valid SQL queries against custom database schemas offline.
Key Features
- Offline schema parsing and SQL translation
- Dialect support: PostgreSQL, SQLite, MySQL
- Guarantees valid syntax without leaking data to external servers
๐ป Installation
Install the local package using pip:
๐ Checkout from GitHub
Clone only this agent's folder from the monorepo using Git sparse-checkout โ no need to download the full repository:
Option 1 โ Sparse Checkout (Recommended)
Option 2 โ Full Repository Clone
๐ก Tip: After checkout, install the package locally with pip install -e ./slm_text_to_sql to run in editable mode without publishing to PyPI.
โ๏ธ Configuration API
Constructor Parameters
Instantiate SLMTextToSQL with performance and runtime options:
| Parameter | Type / Default | Description |
|---|---|---|
model_path | str | None | Path to local ONNX model. Default: None. |
temperature | float | 0.0 | Sampling temperature. Default: 0.0. |
top_p | float | 0.9 | Nucleus sampling threshold. Default: 0.9. |
max_tokens | int | 256 | Max token output limit. Default: 256. |
n_threads | int | 4 | CPU thread count. Default: 4. |
Methods
| Method Signature | Return Type | Description |
|---|---|---|
generate_sql(schema, query, ...) | str | Generates valid SQL query string from natural language prompt. |
Execution Parameters
Complete list of execution parameters accepted by the primary agent method:
| Parameter | Type / Default | Description |
|---|---|---|
schema | str | Database DDL creation schema string. |
query | str | Natural language user question. |
system_prompt | str | None | SQL dialect prompt override. Default: None. |
user_input | str | None | Additional SQL constraints. Default: None. |
temperature | float | 0.0 | Sampling temperature. Default: 0.0. |
top_p | float | 0.9 | Nucleus sampling probability. Default: 0.9. |
max_tokens | int | 256 | Maximum token limit. Default: 256. |
Quick Start
๐ Verified Output Logs
Diagnostic execution console output running locally on CPU: