Instructions to use support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ") model = AutoModelForCausalLM.from_pretrained("support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ
- SGLang
How to use support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ 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 "support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ" \ --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": "support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ", "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 "support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ" \ --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": "support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ with Docker Model Runner:
docker model run hf.co/support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ
'NoneType' object is not subscriptable` error
#1
by NitishKumar1999 - opened
I tried the below code and am facing a 'NoneType' object is not subscriptable error:
from transformers import AutoTokenizer
from auto_gptq import AutoGPTQForCausalLM
model_name = 'support-pvelocity/Code-Llama-2-13B-instruct-text2sql-GPTQ'
model = AutoGPTQForCausalLM.from_quantized(model_name, use_safetensors=True, device_map='auto')
tokenizer = AutoTokenizer.from_pretrained(model_name)
table = "CREATE TABLE sales (...); CREATE TABLE product_suppliers (...);"
question = 'Find the salesperson who made the most sales.'
prompt = f"[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```: Schema: {table} Question: {question} [/INST] Here is the SQLite query to answer to the question: {question}: ``` "
tokens = tokenizer(prompt, return_tensors="pt").to('cuda:0')
input_ids = tokens.input_ids
generated_ids = model.generate(input_ids=input_ids, max_length=4048, pad_token_id=tokenizer.eos_token_id)
output = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
output = output.split('```')[2]
print(output)
Below is the complete error:
TypeError Traceback (most recent call last)
Cell In[1], line 18
15 tokens = tokenizer(prompt, return_tensors="pt").to('cuda:0')
16 input_ids = tokens.input_ids
---> 18 generated_ids = model.generate(input_ids=input_ids, max_length=4048, pad_token_id=tokenizer.eos_token_id)
19 output = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
20 output = output.split('```')[2]
File ~/.local/lib/python3.10/site-packages/auto_gptq/modeling/_base.py:447, in BaseGPTQForCausalLM.generate(self, **kwargs)
...
TypeError: 'NoneType' object is not subscriptable
Can anyone help me understand why I am getting this error and how to fix it?