b-mc2/sql-create-context
Viewer • Updated • 78.6k • 3.74k • 497
How to use Artifact-io/toy-sql-28M with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Artifact-io/toy-sql-28M") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Artifact-io/toy-sql-28M")
model = AutoModelForCausalLM.from_pretrained("Artifact-io/toy-sql-28M")How to use Artifact-io/toy-sql-28M with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Artifact-io/toy-sql-28M"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Artifact-io/toy-sql-28M",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Artifact-io/toy-sql-28M
How to use Artifact-io/toy-sql-28M with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Artifact-io/toy-sql-28M" \
--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": "Artifact-io/toy-sql-28M",
"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 "Artifact-io/toy-sql-28M" \
--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": "Artifact-io/toy-sql-28M",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Artifact-io/toy-sql-28M with Docker Model Runner:
docker model run hf.co/Artifact-io/toy-sql-28M
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Artifact-io/toy-sql-28M")
model = AutoModelForCausalLM.from_pretrained("Artifact-io/toy-sql-28M")Toy model finetuned on the b-mc2/sql-create-context dataset.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = AutoModelForCausalLM.from_pretrained("Artifact-io/toy-sql-28M").to(device)
tokenizer = AutoTokenizer.from_pretrained("Artifact-io/toy-sql-28M")
inputs = tokenizer([
"""CREATE TABLE head (age INTEGER)
How many heads of the departments are older than 56?
"""
],
return_tensors="pt",
).to(device)
outputs = model.generate(**inputs, max_new_tokens=200, do_sample=True, top_k=50, top_p=0.95)
text = tokenizer.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0].split("---")[0]
print(text)
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Artifact-io/toy-sql-28M")