davide221 commited on
Commit
8051784
Β·
1 Parent(s): 8aa14c6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +139 -0
README.md ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: text-generation
4
+ ---
5
+ # πŸ₯· Safurai-Csharp-34B
6
+
7
+ πŸ“ [Article](https://www.safurai.com/blog/introducing-safurai-csharp)
8
+ πŸ“„ [Paper](https://www.safurai.com/)
9
+
10
+ <center><img src="https://i.imgur.com/REPqbYM.png" width="300"></center>
11
+
12
+ This is a [`codellama/CodeLlama-34b-hf`](https://huggingface.co/codellama/CodeLlama-34b-hf) model fine-tuned using QLoRA (4-bit precision) on 13B tokens of csharp evolved Q&A
13
+
14
+ We obtained state-of-the-art performance on the MultiPL-E code LLM benchmark for csharp, reaching 56% at pass@1 with n=5.
15
+
16
+ ## πŸ’» Quantization
17
+
18
+ This the AWQ quantized version of Safurai-Csharp-34B, it has been made by using the amazing [`AutoAWQ`](https://github.com/casper-hansen/AutoAWQ) library.
19
+
20
+ ## πŸ”§ Training
21
+
22
+ It was trained on 2 x NVIDIA A100 PCIe 80GB in 7h 40m with the following configuration file:
23
+
24
+ ```yaml
25
+ base_model: codellama/CodeLlama-34b-hf
26
+ base_model_config: codellama/CodeLlama-34b-hf
27
+ model_type: LlamaForCausalLM
28
+ tokenizer_type: CodeLlamaTokenizer
29
+ is_llama_derived_model: true
30
+ hub_model_id: "Safurai/Evol-csharp-v1"
31
+
32
+ load_in_8bit: false
33
+ load_in_4bit: true
34
+ strict: false
35
+
36
+ datasets:
37
+ - path: Safurai/EvolInstruct-csharp-16k-13B-Alpaca
38
+ type: alpaca
39
+ dataset_prepared_path: last_run_prepared
40
+ val_set_size: 0.01
41
+ output_dir: ./qlora-out
42
+
43
+ sequence_len: 4096
44
+ sample_packing: true
45
+ pad_to_sequence_len: true
46
+
47
+ adapter: lora
48
+ lora_model_dir:
49
+ lora_r: 32
50
+ lora_alpha: 16
51
+ lora_dropout: 0.05
52
+ lora_target_linear: true
53
+ lora_fan_in_fan_out:
54
+
55
+ wandb_project: codellama-csharp
56
+ wandb_entity:
57
+ wandb_watch:
58
+ wandb_run_id:
59
+ wandb_log_model:
60
+
61
+ gradient_accumulation_steps: 4
62
+ micro_batch_size: 2
63
+ num_epochs: 3
64
+ optimizer: adamw_bnb_8bit
65
+ lr_scheduler: cosine
66
+ learning_rate: 0.0003
67
+
68
+ train_on_inputs: false
69
+ group_by_length: false
70
+ bf16: true
71
+ fp16: false
72
+ tf32: false
73
+
74
+ gradient_checkpointing: true
75
+ early_stopping_patience:
76
+ resume_from_checkpoint:
77
+ local_rank:
78
+ logging_steps: 1
79
+ xformers_attention:
80
+ flash_attention: true
81
+
82
+ warmup_steps: 40
83
+ eval_steps: 40
84
+ save_steps:
85
+ debug:
86
+ deepspeed:
87
+ weight_decay: 0.0
88
+ fsdp:
89
+ fsdp_config:
90
+ special_tokens:
91
+ bos_token: "<s>"
92
+ eos_token: "</s>"
93
+ unk_token: "<unk>"
94
+ ```
95
+
96
+ ## πŸ“‰ Training loss curve:
97
+
98
+ ![](https://i.imgur.com/rp1htuf.png)
99
+
100
+ ## πŸ“Š Dataset composition:
101
+
102
+ ![](https://i.imgur.com/kTNXgGX.png)
103
+
104
+
105
+ ## πŸ’» Usage for AWQ
106
+
107
+ ``` python
108
+ from awq import AutoAWQForCausalLM
109
+ from transformers import AutoTokenizer, TextStreamer
110
+
111
+ quant_path = "Safurai/Safurai-Csharp-34B-AWQ"
112
+ quant_file = "awq_model_w4_g128.pt"
113
+
114
+ # Load model
115
+ model = AutoAWQForCausalLM.from_quantized(quant_path, quant_file, fuse_layers=True)
116
+ tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True)
117
+ streamer = TextStreamer(tokenizer, skip_special_tokens=True)
118
+
119
+ # Convert prompt to tokens
120
+ prompt_template = """\
121
+ A chat between a developer and an AI assistant. The assistant is an expert csharp programmer that can give useful and complete code responses.
122
+
123
+ USER: {prompt}
124
+ ASSISTANT:"""
125
+
126
+ tokens = tokenizer(
127
+ prompt_template.format(prompt="How are you today?"),
128
+ return_tensors='pt'
129
+ ).input_ids.cuda()
130
+
131
+ # Generate output
132
+ generation_output = model.generate(
133
+ tokens,
134
+ streamer=streamer,
135
+ max_new_tokens=1024
136
+ )
137
+ ```
138
+
139
+ [<img src="https://raw.githubusercontent.com/OpenAccess-AI-Collective/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/OpenAccess-AI-Collective/axolotl)