xlangai/spider
Viewer • Updated • 8.03k • 9.39k • 174
How to use AuricErgeson/Antelope-textTosql with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="AuricErgeson/Antelope-textTosql") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("AuricErgeson/Antelope-textTosql")
model = AutoModelForCausalLM.from_pretrained("AuricErgeson/Antelope-textTosql")How to use AuricErgeson/Antelope-textTosql with PEFT:
Task type is invalid.
How to use AuricErgeson/Antelope-textTosql with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "AuricErgeson/Antelope-textTosql"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AuricErgeson/Antelope-textTosql",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/AuricErgeson/Antelope-textTosql
How to use AuricErgeson/Antelope-textTosql with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "AuricErgeson/Antelope-textTosql" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AuricErgeson/Antelope-textTosql",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "AuricErgeson/Antelope-textTosql" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AuricErgeson/Antelope-textTosql",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use AuricErgeson/Antelope-textTosql with Docker Model Runner:
docker model run hf.co/AuricErgeson/Antelope-textTosql
Convert plain English questions into SQL queries instantly.
Lightweight, fast, and runs on CPU. No database expertise needed.
| Question | Database | Output |
|---|---|---|
| How many employees are there? | company | SELECT COUNT(*) FROM employees |
| List all customers from Germany | store | SELECT * FROM customers WHERE country = 'Germany' |
| What is the average salary by department? | hr | SELECT department, AVG(salary) FROM employees GROUP BY department |
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "AuricErgeson/Antelope-textTosql"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
def generate_sql(question, db=""):
prompt = (
f"### Task: Convert question to SQL. Use only what the question asks. Simple questions need simple SQL.\n"
f"### Database: {db}\n"
f"### Question: {question}\n"
f"### SQL:"
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=128,
temperature=0.1,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
decoded = tokenizer.decode(out[0], skip_special_tokens=True)
return decoded.split("### SQL:")[-1].strip().split("\n")[0]
print(generate_sql("How many employees are in each department?", db="company"))
# → SELECT department, COUNT(*) FROM employees GROUP BY department
transformers### Task: Convert question to SQL. Use only what the question asks. Simple questions need simple SQL.
### Database: {your_database_name}
### Question: {your_question}
### SQL:
import requests
API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2FAuricErgeson%2FAntelope-textTosql"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
response = requests.post(API_URL, headers=headers, json={
"inputs": "### Task: Convert question to SQL. Use only what the question asks. Simple questions need simple SQL.\n### Database: company\n### Question: How many employees?\n### SQL:"
})
print(response.json())
| Property | Value |
|---|---|
| Base model | microsoft/phi-2 (2.7B) |
| Method | QLoRA (4-bit + LoRA) |
| Dataset | Spider (7,000+ examples, 200+ databases) |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| Target modules | q_proj, v_proj |
| Learning rate | 2e-4 |
| Epochs | 3 |
| Hardware | NVIDIA A100 (Google Colab) |
| Training time | ~1.5 hours |
| Adapter size | ~21MB |
| Merged model size | ~5.56GB |
Auric Ergeson Nitonde
📧 auricergesonnitonde@gmail.com
🤗 HuggingFace Profile
If this model helped you, consider leaving a like ⭐ — it helps others find it.
Base model
microsoft/phi-2