Views
No views yet
"""Question: what is What was the result of the election in the Florida 18 district?\nTable: table_1341598_10 (result VARCHAR, district VARCHAR)\nSQL: """"""SELECT * FROM table_1341598_10 WHERE district = "Florida 18""""1from peft import get_peft_config, get_peft_model, TaskType
2from peft import PeftConfig, PeftModel
3from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
4
5model_id = "jonathanjordan21/flan-alpaca-base-finetuned-lora-knowSQL"
6config = PeftConfig.from_pretrained(model_id)
7model_ = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path, return_dict=True)
8tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
9
10model = PeftModel.from_pretrained(model_, model_id)1question = "server of user id 11 with status active and server id 10"
2table = "table_name_77 ( user id INTEGER, status VARCHAR, server id INTEGER )"
3
4test = f"""Question: {question}\nTable: {table}\nSQL: """
5
6p = tokenizer(test, return_tensors='pt')
7
8device = "cuda" if torch.cuda.is_available() else "cpu"
9out = model.to(device).generate(**p.to(device),max_new_tokens=50)
10
11print("SQL Query :", tokenizer.batch_decode(out,skip_special_tokens=True)[0])
12