Instructions to use NumbersStation/nsql-llama-2-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NumbersStation/nsql-llama-2-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NumbersStation/nsql-llama-2-7B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NumbersStation/nsql-llama-2-7B") model = AutoModelForCausalLM.from_pretrained("NumbersStation/nsql-llama-2-7B") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NumbersStation/nsql-llama-2-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NumbersStation/nsql-llama-2-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NumbersStation/nsql-llama-2-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/NumbersStation/nsql-llama-2-7B
- SGLang
How to use NumbersStation/nsql-llama-2-7B 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 "NumbersStation/nsql-llama-2-7B" \ --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": "NumbersStation/nsql-llama-2-7B", "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 "NumbersStation/nsql-llama-2-7B" \ --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": "NumbersStation/nsql-llama-2-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use NumbersStation/nsql-llama-2-7B with Docker Model Runner:
docker model run hf.co/NumbersStation/nsql-llama-2-7B
Query for week on week calculation is not even close to the expected output
After fine tuning on custom dataset, the model is not generating the expected output for the exact same query which in my training dataset.
Below query is part of my custom dataset
CREATE TABLE APPTABLE (
DATETIME DATE,
DURATION FLOAT,
RESPONSETIME VARCHAR() -- Using valid SQLite, answer the following questions for the tables provided above. -- sum of call duration week on week ?
)
My query which I have given the training dataset is
SELECT
TO_VARIANT(DATE_TRUNC('MONTH', DATE_TRUNC('WEEK', datetime)))::STRING AS month_start_date,
TO_VARIANT(EXTRACT(WEEK FROM datetime))::STRING AS week_number,
SUM(DURATION) AS monthly_weekly_call_duration
FROM
AppTable
GROUP BY
month_start_date,
week_number
ORDER BY
month_start_date, week_number
Now when I do the inference its giving me the following answer:
text = """
CREATE TABLE APPTABLE (
DATETIME DATE,
DURATION FLOAT,
RESPONSETIME VARCHAR
) -- Using valid SQL, answer the following questions for the tables provided above. -- sum of call duration week on week ?
"""
model_input = tokenizer(text, return_tensors="pt").to("cuda")
generated_ids = model.generate(**model_input, max_new_tokens=100)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
CREATE TABLE APPTABLE (
DATETIME DATE,
DURATION FLOAT,
RESPONSETIME VARCHAR
) -- Using valid SQL, answer the following questions for the tables provided above. -- sum of call duration week on week ?
SELECT SUM(DURATION) FROM APPTABLE;
Output Generated is incorrect. Can you please share some inputs to get a better output as mentioned in my training dataset used for fine tuning.
Attaching the csv screenshot for the record I want the model to predict the exact answer that I need:
@senwu -- Any inputs on this will be of great help.
