Downloads · 30 days
6
4% of all-time downloads
sharadsin/Mixtral-8x7B-sql-ft-v1
Mixtral-8x7B-sql-ft-v1 is a machine learning model from sharadsin. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
<img src="project-9.png" width="50%" height="50%"
Downloads · 30 days
6
4% of all-time downloads
All-time downloads
161
Public
Repo size
2.2 GB
Likes
1
Public
Click a slice to open those files.
.safetensors2.2 GB · 100%
From the Hugging Face model README
Convert Natural Language to SQL
Mixtral-8x7B-sql-ft-v1 is fine-tuned from Mixtral 8x7B to convert natural language to SQL queries.
mistralai/Mixtral-8x7B-v0.1
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
base_model_id = 'mistralai/Mixtral-8x7B-v0.1'
adapter_id = 'sharadsin/Mixtral-8x7B-sql-ft-v1'
bnb_config = BitsAndBytesConfig(
load_in_4bit = True,
bnb_4bit_use_double_quant = True,
bnb_4bit_compute_dtype = torch.bfloat16,
bnb_4bit_quant_type = "nf4",
)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config = bnb_config,
device_map = "auto",
trust_remote_code = True,
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token = True, trust_remote_code = True)
ft_model = PeftModel.from_pretrained(base_model, adapter_id)
eval_prompt= """SYSTEM: Use the following contextual information to concisely answer the question.
USER: CREATE TABLE EmployeeInfo (EmpID INTEGER, EmpFname VARCHAR, EmpLname VARCHAR, Department VARCHAR, Project VARCHAR,Address VARCHAR, DOB DATE, Gender CHAR)
===
Write a query to fetch details of employees whose EmpLname ends with an alphabet 'A' and contains five alphabets?
ASSISTANT:"""
model_input = tokenizer(eval_prompt, return_tensors="pt").to("cuda")
ft_model.eval()
with torch.inference_mode():
print(tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=70,top_k=4, penalty_alpha = 0.6, repetition_penalty=1.15)[0], skip_special_tokens= False))