b-mc2/sql-create-context
Viewer • Updated • 78.6k • 4.08k • 498
How to use vagmi/squeal with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="vagmi/squeal") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("vagmi/squeal")
model = AutoModelForCausalLM.from_pretrained("vagmi/squeal")How to use vagmi/squeal with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "vagmi/squeal"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "vagmi/squeal",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/vagmi/squeal
How to use vagmi/squeal with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "vagmi/squeal" \
--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": "vagmi/squeal",
"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 "vagmi/squeal" \
--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": "vagmi/squeal",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use vagmi/squeal with Docker Model Runner:
docker model run hf.co/vagmi/squeal
Please use the code below as an example for how to use this model.
import torch
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
def load_model(model_name):
# Load tokenizer and model with QLoRA configuration
compute_dtype = getattr(torch, 'float16')
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type='nf4',
bnb_4bit_compute_dtype=compute_dtype,
bnb_4bit_use_double_quant=False,
)
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map={"": 0},
quantization_config=bnb_config
)
# Load Tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "right"
return model, tokenizer
model, tokenizer = load_model('vagmi/squeal')
prompt = "<s>[INST] Output SQL for the given table structure \n \
CREATE TABLE votes (contestant_number VARCHAR, num_votes int); \
CREATE TABLE contestants (contestant_number VARCHAR, contestant_name VARCHAR); \
What is the contestant number and name of the contestant who got least votes?[/INST]"
pipe = pipeline(task="text-generation",
model=model,
tokenizer=tokenizer,
max_length=200,
device_map='auto', )
result = pipe(prompt)
print(result[0]['generated_text'][len(prompt):-1])
Watch me build this model.
https://www.youtube.com/watch?v=PNFhAfxR_d8
Here is the notebook I used to train this model.
https://colab.research.google.com/drive/1jYX8AlRMTY7F_dH3hCFM4ljg5qEmCoUe#scrollTo=IUILKaGWhBxS
docker model run hf.co/vagmi/squeal