nps798 commited on
Commit
73a3589
1 Parent(s): a2f82fd

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # phi-1_5-qlora-alpaca-instruction Model Card
2
+
3
+ ## Model Description
4
+
5
+ This model is a causal language model based on the `microsoft/phi-1_5` and has been finetuned using QLORA technology on the `vicgalle/alpaca-gpt4` dataset.
6
+
7
+ ## Fine-tuning Details
8
+ - **Base Model**: `microsoft/phi-1_5`
9
+ - **Fine-tuning Dataset**: `vicgalle/alpaca-gpt4`
10
+ - **Hardware**: NVIDIA 3090ti
11
+ - **Training Duration**: 8 hours
12
+ - **VRAM Consumption**: Approx. 20 GB for 14 hours
13
+ - **Token Max Length**: 2048
14
+ - **Model Size**: 1.5billion + qlora weights merged
15
+
16
+ ### Hyperparameters
17
+
18
+ ```python
19
+ # Lora Configuration
20
+ config = LoraConfig(
21
+ r=16,
22
+ lora_alpha=16,
23
+ target_modules=["Wqkv", "out_proj"],
24
+ lora_dropout=0.05,
25
+ bias="none",
26
+ task_type="CAUSAL_LM"
27
+ )
28
+
29
+ # Training Hyperparameters
30
+ training_arguments = TrainingArguments(
31
+ output_dir=f"{local_path}/output_dir",
32
+ per_device_train_batch_size=4,
33
+ gradient_accumulation_steps=6,
34
+ learning_rate=2e-4,
35
+ lr_scheduler_type="cosine",
36
+ evaluation_strategy = "steps",
37
+ eval_steps=500,
38
+ save_strategy="epoch",
39
+ logging_steps=100,
40
+ num_train_epochs=6,
41
+ report_to = 'wandb',
42
+ run_name = run_name
43
+ )
44
+
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ```python
50
+ import torch
51
+ from transformers import AutoModelForCausalLM, AutoTokenizer
52
+
53
+ model_name = "nps798/phi-1_5-qlora-alpaca-instruction"
54
+
55
+ model = AutoModelForCausalLM.from_pretrained(
56
+ model_name,
57
+ device_map={"": 0},
58
+ trust_remote_code=True
59
+ )
60
+ tokenizer = AutoTokenizer.from_pretrained(
61
+ model_name,
62
+ trust_remote_code=True
63
+ )
64
+
65
+ prompt= """Below is an instruction that describes a task. Write a response that appropriately completes the request.
66
+
67
+ ### Instruction:
68
+ Choose three places you would like to visit and explain why.
69
+
70
+ ### Response:"""
71
+ inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False)
72
+ outputs = model.generate(**inputs, max_length=500)
73
+ text = tokenizer.batch_decode(outputs)[0]
74
+ print(text)
75
+
76
+ ```
77
+
78
+ ## License
79
+ Because the base model is microsoft phi-1.5b model, this fine-tuned model is provided under the MICROSOFT RESEARCH LICENSE and is meant for non-commercial use only.
80
+
81
+ ## Author
82
+ I am a medical doctor interested in ML/NLP field.
83
+ If you have any advice, suggestions, or opportunities, or simply want to discuss the fascinating intersection of medicine and technology, please don't hesitate to reach out.
84
+