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

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -15
README.md CHANGED
@@ -1,21 +1,72 @@
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: True
17
- - bnb_4bit_compute_dtype: float32
18
- ### Framework versions
19
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  - PEFT 0.5.0
 
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,
42
+ #load_in_4bit=True,
43
+ #torch_dtype=torch.float16,
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.
53
+ ### Input:
54
+ Which Class has a Frequency MHz larger than 91.5, and a City of license of hyannis, nebraska?
55
+
56
+ ### Context:
57
+ CREATE TABLE table_name_12 (class VARCHAR, frequency_mhz VARCHAR, city_of_license VARCHAR)
 
 
 
 
 
 
58
 
59
+ ### Response:
60
+
61
+ ### Explain:
62
+ """
63
+
64
+ model_input = tokenizer(eval_prompt, return_tensors="pt").to("cuda")
65
+
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