Text Generation
PEFT
Safetensors
MLX
English
text-to-sql
sql
sqlite
lora
bird
spider
Eval Results (legacy)
Instructions to use Felamity-Technologies/sqlant-1b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Felamity-Technologies/sqlant-1b with PEFT:
Task type is invalid.
- MLX
How to use Felamity-Technologies/sqlant-1b with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("Felamity-Technologies/sqlant-1b") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use Felamity-Technologies/sqlant-1b with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "Felamity-Technologies/sqlant-1b" --prompt "Once upon a time"
- Atomic Chat
Download code/sqlant/schema_format.py from Felamity-Technologies/sqlant-1b: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/Felamity-Technologies/sqlant-1b/resolve/main/code/sqlant/schema_format.py
- Command line
-
hf download hf://Felamity-Technologies/sqlant-1b/code/sqlant/schema_format.py
-
curl -L -o schema_format.py https://huggingface.co/Felamity-Technologies/sqlant-1b/resolve/main/code/sqlant/schema_format.py
1.6 kB
| """Prompt schema format (copied from the SQLant repository, scripts/build_eval_set.py).""" | |
| import sqlite3 | |
| from pathlib import Path | |
| N_EXAMPLE_ROWS = 3 | |
| MAX_VAL_CHARS = 40 | |
| def _fmt(v): | |
| s = repr(v) if isinstance(v, str) else str(v) | |
| return s if len(s) <= MAX_VAL_CHARS else s[:MAX_VAL_CHARS] + "...'" | |
| def schema_text(db_path: Path) -> str: | |
| con = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True) | |
| con.text_factory = lambda b: b.decode(errors="replace") | |
| cur = con.cursor() | |
| parts = [] | |
| tables = cur.execute( | |
| "SELECT name, sql FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'" | |
| ).fetchall() | |
| for name, ddl in tables: | |
| block = ddl.strip() + ";" | |
| try: | |
| rows = cur.execute(f'SELECT * FROM "{name}" LIMIT {N_EXAMPLE_ROWS}').fetchall() | |
| cols = [d[0] for d in cur.description] | |
| if rows: | |
| lines = [" | ".join(cols)] + [" | ".join(_fmt(v) for v in r) for r in rows] | |
| block += f"\n/* {len(rows)} example rows from {name}:\n" + "\n".join(lines) + "\n*/" | |
| except sqlite3.Error: | |
| pass | |
| parts.append(block) | |
| con.close() | |
| return "\n\n".join(parts) | |
| def build_prompt(schema: str, question: str, evidence: str | None) -> str: | |
| p = f"Database schema (SQLite):\n{schema}\n\n" | |
| if evidence: | |
| p += f"External knowledge: {evidence}\n\n" | |
| p += ( | |
| f"Question: {question}\n\n" | |
| "Write one SQLite query that answers the question. " | |
| "Return only the SQL inside a ```sql code block, with no explanation." | |
| ) | |
| return p | |