sha-codes commited on
Commit
86a7564
·
verified ·
1 Parent(s): b1bd63c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -32
README.md CHANGED
@@ -1,41 +1,44 @@
1
- ## About
2
-
3
  # Problem Statement
4
- The objective of fine-tuning the CodeLlama model for the SQL dataset was to enhance its ability to generate accurate SQL queries based on given prompts. The initial model performance was suboptimal, prompting the need for fine-tuning to improve query generation accuracy.
5
-
6
- # Dataset and Model
7
- Dataset: ChrisHayduk/Llama-2-SQL-Dataset
8
-
9
- Model: CodeLlama, a pre-trained language model tailored for code generation tasks, was chosen as the base model for fine-tuning. The model's architecture and extensive pre-training on code-related tasks provided a strong foundation for this specialized fine-tuning.
10
 
11
- # Training Procedure
12
- The fine-tuning process involved several key steps and configurations to optimize model performance:
13
 
14
- Library and Tools: PEFT was utilized for the fine-tuning process, leveraging its capabilities to adjust model parameters and improve inference accuracy.
15
 
16
- Quantization Configuration: The bitsandbytes quantization method was employed with the following configuration:
17
 
18
- quant_method: bitsandbytes
19
- load_in_8bit: False
20
- load_in_4bit: True
21
- llm_int8_threshold: 6.0
22
- llm_int8_skip_modules: None
23
- llm_int8_enable_fp32_cpu_offload: False
24
- llm_int8_has_fp16_weight: False
25
- bnb_4bit_quant_type: nf4
26
- bnb_4bit_use_double_quant: True
27
- bnb_4bit_compute_dtype: float32
28
- This configuration aimed to optimize model performance by reducing memory usage and improving inference speed while maintaining acceptable accuracy levels for SQL query generation.
29
 
30
- # Results and Evaluation
31
- The fine-tuning process aimed to address the initial performance issues observed in the model's ability to generate SQL queries accurately. Post-fine-tuning evaluation involved measuring the model's accuracy, speed of query generation, and overall efficiency in handling various query complexities.
32
 
 
33
 
34
- ## Training procedure
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  import torch
37
  from transformers import AutoModelForCausalLM, BitsAndBytesConfig, AutoTokenizer
38
- #!pip install accelerate
 
39
  base_model = "codellama/CodeLlama-7b-hf"
40
  model = AutoModelForCausalLM.from_pretrained(
41
  base_model,
@@ -44,9 +47,10 @@ model = AutoModelForCausalLM.from_pretrained(
44
  device_map="auto",
45
  )
46
  tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-hf")
47
- from peft import PeftModel
48
  output_dir = "model/output/path"
49
  model = PeftModel.from_pretrained(model, output_dir)
 
50
  eval_prompt = """You are a powerful text-to-SQL model. Your job is to answer questions about a database and explain your answer in detail. You are given a question and context regarding one or more tables.
51
 
52
  You must output the SQL query that answers the question.
@@ -66,7 +70,3 @@ model_input = tokenizer(eval_prompt, return_tensors="pt").to("cuda")
66
  model.eval()
67
  with torch.no_grad():
68
  print(tokenizer.decode(model.generate(**model_input, max_new_tokens=100)[0], skip_special_tokens=True))
69
-
70
- ### Framework versions
71
-
72
- - PEFT 0.5.0
 
 
 
1
  # Problem Statement
 
 
 
 
 
 
2
 
3
+ The objective of fine-tuning the CodeLlama model for the SQL dataset was to enhance its ability to generate accurate SQL queries based on given prompts. The initial model performance was suboptimal, prompting the need for fine-tuning to improve query generation accuracy.
 
4
 
5
+ ---
6
 
7
+ # Dataset and Model
8
 
9
+ - **Dataset**: [ChrisHayduk/Llama-2-SQL-Dataset](https://huggingface.co/ChrisHayduk/Llama-2-SQL-Dataset)
10
+ - **Model**: CodeLlama, a pre-trained language model tailored for code generation tasks, was chosen as the base model for fine-tuning. The model's architecture and extensive pre-training on code-related tasks provided a strong foundation for this specialized fine-tuning.
 
 
 
 
 
 
 
 
 
11
 
12
+ ---
 
13
 
14
+ # Training Procedure
15
 
16
+ The fine-tuning process involved several key steps and configurations to optimize model performance:
17
 
18
+ - **Library and Tools**: PEFT was utilized for the fine-tuning process, leveraging its capabilities to adjust model parameters and improve inference accuracy.
19
+
20
+ - **Quantization Configuration**: The `bitsandbytes` quantization method was employed with the following configuration:
21
+
22
+ ```yaml
23
+ quant_method: bitsandbytes
24
+ load_in_8bit: False
25
+ load_in_4bit: True
26
+ llm_int8_threshold: 6.0
27
+ llm_int8_skip_modules: None
28
+ llm_int8_enable_fp32_cpu_offload: False
29
+ llm_int8_has_fp16_weight: False
30
+ bnb_4bit_quant_type: nf4
31
+ bnb_4bit_use_double_quant: True
32
+ bnb_4bit_compute_dtype: float32
33
+
34
+ # Result
35
+ The fine-tuning process aimed to address the initial performance issues observed in the model's ability to generate SQL queries accurately. Post-fine-tuning evaluation involved measuring the model's accuracy, speed of query generation, and overall efficiency in handling various query complexities.
36
+
37
+ ```bash
38
  import torch
39
  from transformers import AutoModelForCausalLM, BitsAndBytesConfig, AutoTokenizer
40
+ from peft import PeftModel
41
+
42
  base_model = "codellama/CodeLlama-7b-hf"
43
  model = AutoModelForCausalLM.from_pretrained(
44
  base_model,
 
47
  device_map="auto",
48
  )
49
  tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-hf")
50
+
51
  output_dir = "model/output/path"
52
  model = PeftModel.from_pretrained(model, output_dir)
53
+
54
  eval_prompt = """You are a powerful text-to-SQL model. Your job is to answer questions about a database and explain your answer in detail. You are given a question and context regarding one or more tables.
55
 
56
  You must output the SQL query that answers the question.
 
70
  model.eval()
71
  with torch.no_grad():
72
  print(tokenizer.decode(model.generate(**model_input, max_new_tokens=100)[0], skip_special_tokens=True))