Instructions to use defog/sqlcoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use defog/sqlcoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="defog/sqlcoder")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("defog/sqlcoder") model = AutoModelForCausalLM.from_pretrained("defog/sqlcoder") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use defog/sqlcoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "defog/sqlcoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "defog/sqlcoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/defog/sqlcoder
- SGLang
How to use defog/sqlcoder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "defog/sqlcoder" \ --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": "defog/sqlcoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
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 "defog/sqlcoder" \ --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": "defog/sqlcoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use defog/sqlcoder with Docker Model Runner:
docker model run hf.co/defog/sqlcoder
Interesting but needs more work?
Seems to work for generating a lot of queries, however, fails for following and many more similar scenarios
CREATE TABLE employee (
ID int(10) NOT NULL AUTO_INCREMENT,
name varchar(255) DEFAULT '',
tel1 varchar(255) DEFAULT NULL,
tel2 varchar(255) DEFAULT NULL,
pass varchar(255) DEFAULT '',
company varchar(256) DEFAULT NULL,
employee_code int(11) NOT NULL DEFAULT '0',
joining_date date DEFAULT NULL,
designation varchar(255) DEFAULT NULL,
) ENGINE=MyISAM AUTO_INCREMENT=211 DEFAULT CHARSET=latin1
And ran the following prompt
"for mysql database give me the number of employees joined in each designation on monthly basis for last 1 year "
Got the following response
SELECT employee.designation,
count(employee.id) AS number_of_employees
FROM employee
WHERE employee.joining_date >= (CURRENT_DATE - INTERVAL '1 year')
GROUP BY employee.designation
ORDER BY number_of_employees DESC;
Where as ChatGPT gives following, which seems more appropriate for the prompt
SELECT
DATE_FORMAT(joining_date, '%Y-%m') AS month_year,
designation,
COUNT(*) AS num_joined
FROM employee
WHERE joining_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR)
GROUP BY month_year, designation
ORDER BY month_year, num_joined DESC;
gpt-3.5-turbo-0613 gives me
SELECT MONTH(joining_date) AS month, designation, COUNT(*) AS num_employees
FROM employee
WHERE joining_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR)
GROUP BY MONTH(joining_date), designation
Thanks for trying out the model, and for the feedback!
Great point β our model is not instruction fine tuned yet (though we have an instruction fine-tuned update coming soon). While the model currently works well for generating queries, it often fails for questions that humans ask in a vague (to an LLM) way. ChatGPT and gpt-3.5-turbo are both instruction fine-tuned, and handle these slightly "human-language" questions better
In this case, asking How employees joined in each month and each designation over the last year? does give the correct response. We should get to parity or better results with gpt-3.5-turbo for these kinds of questions within the next month (mostly by asking a lot of contractors for their data labeling preferences).
Thanks again for trying this out β please keep the feedback coming!