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/run.py from Felamity-Technologies/sqlant-1b: direct link, hf CLI and curl.
- Browser
- Download file 4.27 kB
-
https://huggingface.co/Felamity-Technologies/sqlant-1b/resolve/main/code/run.py
- Command line
-
hf download hf://Felamity-Technologies/sqlant-1b/code/run.py
-
curl -L -o run.py https://huggingface.co/Felamity-Technologies/sqlant-1b/resolve/main/code/run.py
4.27 kB
| """SQLant-1B: BIRD-format inference with logging and resume. | |
| python run.py --data test.json --db_root test_databases --out predict_test.json \ | |
| [--base Qwen/Qwen2.5-Coder-1.5B-Instruct] [--generator adapters/generator] [--verifier adapters/verifier] \ | |
| [--backend torch|mlx] [--limit N] | |
| Progress is appended to <out>.progress.jsonl after every question; re-running the same command skips finished | |
| questions and continues from the first unfinished one. The final file maps the question's index in --data to | |
| "SQL\t----- bird -----\t<db_id>" (BIRD's prediction format). | |
| """ | |
| import argparse | |
| import json | |
| import logging | |
| import os | |
| import sys | |
| import time | |
| import traceback | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--data", required=True) | |
| ap.add_argument("--db_root", required=True) | |
| ap.add_argument("--out", required=True) | |
| ap.add_argument("--base", default="Qwen/Qwen2.5-Coder-1.5B-Instruct") | |
| here = Path(__file__).resolve().parent | |
| def default_adapter(name): # submission zip: ./adapters/<name>; Hugging Face repo: ../<name> next to code/ | |
| for p in (here / "adapters" / name, here.parent / name): | |
| if (p / "adapter_config.json").exists(): | |
| return str(p) | |
| return str(here / "adapters" / name) | |
| ap.add_argument("--generator", default=default_adapter("generator")) | |
| ap.add_argument("--verifier", default=default_adapter("verifier")) | |
| ap.add_argument("--backend", default="torch", choices=["torch", "mlx"]) | |
| ap.add_argument("--limit", type=int, default=None) | |
| ap.add_argument("--seed", type=int, default=0) | |
| a = ap.parse_args() | |
| out = Path(a.out) | |
| prog = out.with_suffix(out.suffix + ".progress.jsonl") | |
| logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s", | |
| handlers=[logging.StreamHandler(), logging.FileHandler(out.with_suffix(".log"))]) | |
| os.environ.setdefault("SQLANT_CACHE", str(out.parent / ".sqlant_cache")) | |
| from sqlant import pipeline # imported after SQLANT_CACHE is set: schema_tools reads it at import time | |
| data = json.loads(Path(a.data).read_text()) | |
| if a.limit: | |
| data = data[:a.limit] | |
| done = {} | |
| if prog.exists(): | |
| for line in prog.read_text().splitlines(): | |
| if line.strip(): | |
| r = json.loads(line) | |
| done[r["idx"]] = r | |
| logging.info("%d questions, %d already done (resuming)", len(data), len(done)) | |
| if a.backend == "torch": | |
| from sqlant.backend_torch import TorchBackend | |
| be = TorchBackend(a.base, a.generator, a.verifier, seed=a.seed) | |
| else: | |
| from sqlant.backend_mlx import MLXBackend | |
| be = MLXBackend(a.base, a.generator, a.verifier, seed=a.seed) | |
| t0 = time.time() | |
| n_new = 0 | |
| with prog.open("a") as f: | |
| for i, ex in enumerate(data): | |
| if i in done: | |
| continue | |
| db = str(Path(a.db_root) / ex["db_id"] / f"{ex['db_id']}.sqlite") | |
| try: | |
| r = pipeline.answer(be, db, ex["question"], ex.get("evidence") or "") | |
| rec = {"idx": i, "db_id": ex["db_id"], "sql": r["sql"], "groups": r["groups"], "draft": r["draft"], "candidates": r["candidates"]} | |
| except Exception: # noqa: BLE001 - log and fall back so one bad question can't stop the run | |
| logging.error("question %d failed:\n%s", i, traceback.format_exc()) | |
| rec = {"idx": i, "db_id": ex["db_id"], "sql": "SELECT 1", "error": True} | |
| f.write(json.dumps(rec) + "\n") | |
| f.flush() | |
| done[i] = rec | |
| n_new += 1 | |
| n = len(done) | |
| if n % 10 == 0 or n == len(data): | |
| rate = (time.time() - t0) / n_new | |
| logging.info("%d/%d done (%.1f s/question this session)", n, len(data), rate) | |
| preds = {str(i): f"{done[i]['sql']}\t----- bird -----\t{done[i]['db_id']}" for i in sorted(done)} | |
| out.write_text(json.dumps(preds, indent=2)) | |
| n_err = sum(1 for r in done.values() if r.get("error")) | |
| logging.info("wrote %s (%d predictions, %d failed questions)", out, len(preds), n_err) | |
| if __name__ == "__main__": | |
| main() | |