PEFT
English
text2sql
bugdaryan commited on
Commit
4a3a6c7
1 Parent(s): 983be3e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -15
README.md CHANGED
@@ -1,22 +1,108 @@
1
  ---
 
 
 
 
 
2
  library_name: peft
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
4
- ## Training procedure
5
 
 
 
 
 
 
 
 
6
 
7
- The following `bitsandbytes` quantization config was used during training:
8
- - quant_method: bitsandbytes
9
- - load_in_8bit: False
10
- - load_in_4bit: True
11
- - llm_int8_threshold: 6.0
12
- - llm_int8_skip_modules: None
13
- - llm_int8_enable_fp32_cpu_offload: False
14
- - llm_int8_has_fp16_weight: False
15
- - bnb_4bit_quant_type: nf4
16
- - bnb_4bit_use_double_quant: False
17
- - bnb_4bit_compute_dtype: float16
18
- ### Framework versions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- - PEFT 0.5.0
 
21
 
22
- - PEFT 0.5.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - bugdaryan/sql-create-context-instruction
5
+ language:
6
+ - en
7
  library_name: peft
8
+ tags:
9
+ - text2sql
10
+ widget:
11
+ - text: "[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```: Schema: CREATE TABLE head (age INTEGER) Question: How many heads of the departments are older than 56 ? [/INST] Here is the SQLite query to answer to the question: How many heads of the departments are older than 56 ?: ```"
12
+ example_title: "Example 1"
13
+ - text: "[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```: Schema: CREATE TABLE people (first_name VARCHAR) Question: List the first names of people in alphabetical order? [/INST] Here is the SQLite query to answer to the question: List the first names of people in alphabetical order?: ```"
14
+ example_title: "Example 2"
15
+ - text: "[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```: Schema: CREATE TABLE weather (zip_code VARCHAR, mean_sea_level_pressure_inches INTEGER) Question: What is the zip code in which the average mean sea level pressure is the lowest? [/INST] Here is the SQLite query to answer to the question: What is the zip code in which the average mean sea level pressure is the lowest?: ```"
16
+ example_title: "Example 3"
17
+ - text: "[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```: Schema: CREATE TABLE weather (date VARCHAR, mean_temperature_f VARCHAR, mean_humidity VARCHAR, max_gust_speed_mph VARCHAR) Question: What are the date, mean temperature and mean humidity for the top 3 days with the largest max gust speeds? [/INST] Here is the SQLite query to answer to the question: What are the date, mean temperature and mean humidity for the top 3 days with the largest max gust speeds?: ```"
18
+ example_title: "Example 4"
19
+ - text: "[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using ```: Schema: CREATE TABLE trip (end_station_id VARCHAR); CREATE TABLE station (id VARCHAR, city VARCHAR) Question: Count the number of trips that did not end in San Francisco city. [/INST] Here is the SQLite query to answer to the question: Count the number of trips that did not end in San Francisco city.: ```"
20
+ example_title: "Example 5"
21
  ---
22
+ # Model Card for MistralSQL-7B
23
 
24
+ ## Model Information
25
+ - **Model Name:** MistralSQL-7B
26
+ - **Base Model Name:** mistralai/Mistral-7B-Instruct-v0.1
27
+ - **Base Model URL:** [Mistral-7B-Instruct-v0.1](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1)
28
+ - **Dataset Name:** bugdaryan/sql-create-context-instruction
29
+ - **Dataset URL:** [SQL Create Context Dataset](https://huggingface.co/datasets/bugdaryan/sql-create-context-instruction)
30
+ - **Dataset Description:** This dataset is built upon SQL Create Context, sourced from WikiSQL and Spider, providing 78,577 examples of natural language queries, SQL CREATE TABLE statements, and SQL queries answering questions using the CREATE statement as context.
31
 
32
+ ## Model Parameters
33
+ - **LoRA Attention Dimension:** 64
34
+ - **LoRA Alpha Parameter:** 16
35
+ - **LoRA Dropout Probability:** 0.1
36
+ - **Bitsandbytes Parameters:**
37
+ - Activate 4-bit precision base model loading: True
38
+ - Compute dtype for 4-bit base models: float16
39
+ - Quantization type (fp4 or nf4): nf4
40
+ - Activate nested quantization for 4-bit base models: False
41
+ - **TrainingArguments Parameters:**
42
+ - Output directory: "./results"
43
+ - Number of training epochs: 1
44
+ - Enable fp16/bf16 training: False/True
45
+ - Batch size per GPU for training: 80
46
+ - Batch size per GPU for evaluation: 4
47
+ - Gradient accumulation steps: 1
48
+ - Enable gradient checkpointing: True
49
+ - Maximum gradient norm (gradient clipping): 0.3
50
+ - Initial learning rate (AdamW optimizer): 2e-4
51
+ - Weight decay: 0.001
52
+ - Optimizer: paged_adamw_32bit
53
+ - Learning rate schedule: cosine
54
+ - Number of training steps (overrides num_train_epochs): -1
55
+ - Ratio of steps for a linear warmup: 0.03
56
+ - Group sequences into batches with the same length: True
57
+ - Save checkpoint every X update steps: 0
58
+ - Log every X update steps: 10
59
+ - **SFT Parameters:**
60
+ - Maximum sequence length: 500
61
+ - Packing: False
62
 
63
+ ## Inference Parameters
64
+ - **Temperature:** 0.7
65
 
66
+
67
+ ## Hardware and Software
68
+
69
+ - **Training Hardware**: 2 RTX A6000 48GB GPUs
70
+
71
+ ## License
72
+ - Apache-2.0
73
+
74
+ ## Instruction Format
75
+ To leverage instruction fine-tuning, prompts should be surrounded by `[INST]` and `[/INST]` tokens. The very first instruction should begin with a begin of sentence id. The next instructions should not. The assistant generation will be ended by the end-of-sentence token id.
76
+
77
+ For example:
78
+ ```python
79
+ from transformers import (
80
+ AutoModelForCausalLM,
81
+ AutoTokenizer,
82
+ pipeline
83
+ )
84
+ import torch
85
+
86
+ model_name = "mistralai/Mistral-7B-Instruct-v0.1"
87
+ adapter_name = "bugdaryan/MistralSQL-7b-QLoRA"
88
+ base_model = AutoModelForCausalLM.from_pretrained(model_name,
89
+ device_map='auto',
90
+ low_cpu_mem_usage=True,
91
+ torch_dtype=torch.float16,
92
+ return_dict=True,
93
+ )
94
+ model = PeftModel.from_pretrained(base_model, adapter_name)
95
+ model = model.merge_and_unload()
96
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
97
+
98
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer)
99
+
100
+ table = "CREATE TABLE sales ( sale_id number PRIMARY KEY, product_id number, customer_id number, salesperson_id number, sale_date DATE, quantity number, FOREIGN KEY (product_id) REFERENCES products(product_id), FOREIGN KEY (customer_id) REFERENCES customers(customer_id), FOREIGN KEY (salesperson_id) REFERENCES salespeople(salesperson_id)); CREATE TABLE product_suppliers ( supplier_id number PRIMARY KEY, product_id number, supply_price number, FOREIGN KEY (product_id) REFERENCES products(product_id)); CREATE TABLE customers ( customer_id number PRIMARY KEY, name text, address text ); CREATE TABLE salespeople ( salesperson_id number PRIMARY KEY, name text, region text ); CREATE TABLE product_suppliers ( supplier_id number PRIMARY KEY, product_id number, supply_price number );"
101
+
102
+ question = 'Find the salesperson who made the most sales.'
103
+
104
+ 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}: ``` "
105
+
106
+ ans = pipe(prompt, max_new_tokens=100)
107
+ print(ans[0]['generated_text'].split('```')[2])
108
+ ```