Instructions to use ekshat/Llama-2-7b-chat-finetune-for-text2sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ekshat/Llama-2-7b-chat-finetune-for-text2sql with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ekshat/Llama-2-7b-chat-finetune-for-text2sql")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql") model = AutoModelForCausalLM.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ekshat/Llama-2-7b-chat-finetune-for-text2sql with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ekshat/Llama-2-7b-chat-finetune-for-text2sql" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ekshat/Llama-2-7b-chat-finetune-for-text2sql", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ekshat/Llama-2-7b-chat-finetune-for-text2sql
- SGLang
How to use ekshat/Llama-2-7b-chat-finetune-for-text2sql 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 "ekshat/Llama-2-7b-chat-finetune-for-text2sql" \ --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": "ekshat/Llama-2-7b-chat-finetune-for-text2sql", "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 "ekshat/Llama-2-7b-chat-finetune-for-text2sql" \ --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": "ekshat/Llama-2-7b-chat-finetune-for-text2sql", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ekshat/Llama-2-7b-chat-finetune-for-text2sql with Docker Model Runner:
docker model run hf.co/ekshat/Llama-2-7b-chat-finetune-for-text2sql
Introduction
Our Model is fine-tuned on Llama-2 7B model on Text-2-SQL Dataset based on Alpaca format described by Stanford. We have used QLora, Bits&Bytes, Accelerate and Transformers Library to implement PEFT concept. For more information, please visit github.com/akshayhedaoo1
Inference
!pip install transformers accelerate xformers bitsandbytes
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
tokenizer = AutoTokenizer.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql")
# Loading model in 4 bit precision
model = AutoModelForCausalLM.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql", load_in_4bit=True)
context = "CREATE TABLE head (name VARCHAR, born_state VARCHAR, age VARCHAR)"
question = "List the name, born state and age of the heads of departments ordered by age."
prompt = f"""Below is an context that describes a sql query, paired with an question that provides further information. Write an answer that appropriately completes the request.
### Context:
{context}
### Question:
{question}
### Answer:"""
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200)
result = pipe(prompt)
print(result[0]['generated_text'])
Model Information
model_name = "NousResearch/Llama-2-7b-chat-hf"
dataset_name = "ekshat/text-2-sql-with-context"
QLoRA parameters
lora_r = 64
lora_alpha = 16
lora_dropout = 0.1
BitsAndBytes parameters
use_4bit = True
bnb_4bit_compute_dtype = "float16"
bnb_4bit_quant_type = "nf4"
use_nested_quant = False
Training Arguments parameters
num_train_epochs = 1
fp16 = False
bf16 = False
per_device_train_batch_size = 8
per_device_eval_batch_size = 4
gradient_accumulation_steps = 1
gradient_checkpointing = True
max_grad_norm = 0.3
learning_rate = 2e-4
weight_decay = 0.001
optim = "paged_adamw_32bit"
lr_scheduler_type = "cosine"
max_steps = -1
warmup_ratio = 0.03
group_by_length = True
save_steps = 0
logging_steps = 25
SFT parameters
max_seq_length = None
packing = False
- Downloads last month
- 13