text-2-sql text-generation 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 : https://github.com/akshayhedaoo1/Llama-2-7b-chat-finetune-for-text2sql/tree/Data-Science

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

QLoRA parameters

BitsAndBytes parameters

Training Arguments parameters

SFT parameters