Sharpaxis commited on
Commit
70dd417
·
verified ·
1 Parent(s): ee2805f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +103 -4
README.md CHANGED
@@ -3,7 +3,106 @@ datasets:
3
  - ekshat/text-2-sql-with-context
4
  language:
5
  - en
6
- metrics:
7
- - accuracy
8
- pipeline_tag: translation
9
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  - ekshat/text-2-sql-with-context
4
  language:
5
  - en
6
+ library_name: transformers
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - text-2-sql
10
+ - text-generation
11
+ - text2sql
12
+ ---
13
+ # Introduction
14
+ Our Model is fine-tuned on Llama-2 7B model on Text-2-SQL Dataset based on Alpaca format described by Stanford. We have used QLora, Bits&Bytes, Accelerate and Transformers Library to implement PEFT concept.
15
+ For more information, please visit [github.com/akshayhedaoo1](https://github.com/akshayhedaoo1/Llama-2-7b-chat-finetune-for-text2sql/tree/Data-Science)
16
+
17
+
18
+ # Inference
19
+ ```python
20
+ !pip install transformers accelerate xformers bitsandbytes
21
+
22
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
23
+
24
+ tokenizer = AutoTokenizer.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql")
25
+
26
+ # Loading model in 4 bit precision
27
+ model = AutoModelForCausalLM.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql", load_in_4bit=True)
28
+
29
+ context = "CREATE TABLE head (name VARCHAR, born_state VARCHAR, age VARCHAR)"
30
+ question = "List the name, born state and age of the heads of departments ordered by age."
31
+
32
+ prompt = f"""Below is an context that describes a sql query, paired with an question that provides further information. Write an answer that appropriately completes the request.
33
+ ### Context:
34
+ {context}
35
+ ### Question:
36
+ {question}
37
+ ### Answer:"""
38
+
39
+ pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200)
40
+ result = pipe(prompt)
41
+ print(result[0]['generated_text'])
42
+ ```
43
+
44
+
45
+ # Model Information
46
+ - **model_name = "NousResearch/Llama-2-7b-chat-hf"**
47
+
48
+ - **dataset_name = "ekshat/text-2-sql-with-context"**
49
+
50
+
51
+ # QLoRA parameters
52
+ - **lora_r = 64**
53
+
54
+ - **lora_alpha = 16**
55
+
56
+ - **lora_dropout = 0.1**
57
+
58
+
59
+ # BitsAndBytes parameters
60
+ - **use_4bit = True**
61
+
62
+ - **bnb_4bit_compute_dtype = "float16"**
63
+
64
+ - **bnb_4bit_quant_type = "nf4"**
65
+
66
+ - **use_nested_quant = False**
67
+
68
+
69
+ # Training Arguments parameters
70
+ - **num_train_epochs = 1**
71
+
72
+ - **fp16 = False**
73
+
74
+ - **bf16 = False**
75
+
76
+ - **per_device_train_batch_size = 8**
77
+
78
+ - **per_device_eval_batch_size = 4**
79
+
80
+ - **gradient_accumulation_steps = 1**
81
+
82
+ - **gradient_checkpointing = True**
83
+
84
+ - **max_grad_norm = 0.3**
85
+
86
+ - **learning_rate = 2e-4**
87
+
88
+ - **weight_decay = 0.001**
89
+
90
+ - **optim = "paged_adamw_32bit"**
91
+
92
+ - **lr_scheduler_type = "cosine"**
93
+
94
+ - **max_steps = -1**
95
+
96
+ - **warmup_ratio = 0.03**
97
+
98
+ - **group_by_length = True**
99
+
100
+ - **save_steps = 0**
101
+
102
+ - **logging_steps = 25**
103
+
104
+
105
+ # SFT parameters
106
+ - **max_seq_length = None**
107
+
108
+ - **packing = False**