Pankaj Mathur commited on
Commit
9aea87a
1 Parent(s): 9c61d10

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +180 -0
README.md ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-sa-4.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ datasets:
8
+ - psmathur/alpaca_orca
9
+ - psmathur/dolly-v2_orca
10
+ - psmathur/WizardLM_Orca
11
+ ---
12
+ # orca_mini_v2_7b
13
+
14
+ An **Uncensored** LLaMA-7b model trained on explain tuned datasets, created using Instructions and Input from WizardLM, Alpaca & Dolly-V2 datasets and applying Orca Research Paper dataset construction approaches.
15
+
16
+ Please note in addition to logical thinking, this model has *better code generation capabilites* compare to our original orca_mini_7b was trained on base OpenLLaMA-7b model, which has the whitespace issues & found not good for code generation.
17
+
18
+ # Dataset
19
+
20
+ We used [remove_refusals.py](https://huggingface.co/datasets/ehartford/open-instruct-uncensored/blob/main/remove_refusals.py) script from https://huggingface.co/ehartford.
21
+
22
+ on top of the previous explain tuned datasets we build which are [WizardLM dataset ~70K](https://github.com/nlpxucan/WizardLM), [Alpaca dataset ~52K](https://crfm.stanford.edu/2023/03/13/alpaca.html) & [Dolly-V2 dataset ~15K](https://github.com/databrickslabs/dolly) created using approaches from [Orca Research Paper](https://arxiv.org/abs/2306.02707).
23
+
24
+ We leverage all of the 15 system instructions provided in Orca Research Paper. to generate custom datasets, in contrast to vanilla instruction tuning approaches used by original datasets.
25
+
26
+ This helps student model aka this model to learn ***thought*** process from teacher model, which is ChatGPT (gpt-3.5-turbo-0301 version).
27
+
28
+ Please see below example usage how the **System** prompt is added before each **instruction**.
29
+
30
+ # Training
31
+
32
+ The training configurations are provided in the table below.
33
+
34
+ The training takes on 8x A100(80G) GPUs and lasts for around 13 Hours for cost of $195 using [RunPods](https://www.runpod.io/)
35
+
36
+ We used DeepSpeed with fully sharded data parallelism, also know as [ZeRO stage 3](https://engineering.fb.com/2021/07/15/open-source/fsdp/) by writing our own fine tunning scripts plus leveraging some of the model training code provided by amazing [OpenAlpaca repo](https://github.com/yxuansu/OpenAlpaca)
37
+
38
+ Here are some of params used during training:
39
+
40
+ |||
41
+ |:-------------:|:-------------:|
42
+ |*batch_size*|96|
43
+ |*train_micro_batch_size_per_gpu*|3|
44
+ |*gradient_accumulation_steps*|4|
45
+ |*Learning rate*|2e-5|
46
+ |*Max length*|1024|
47
+ |*Epochs*|3|
48
+ |*Optimizer*|AdamW|
49
+
50
+
51
+
52
+ # Example Usage
53
+
54
+ Below shows an example on how to use this model
55
+
56
+ ```python
57
+ import torch
58
+ from transformers import LlamaForCausalLM, LlamaTokenizer
59
+
60
+ # Hugging Face model_path
61
+ model_path = 'psmathur/orca_mini_v2_7b'
62
+ tokenizer = LlamaTokenizer.from_pretrained(model_path)
63
+ model = LlamaForCausalLM.from_pretrained(
64
+ model_path, torch_dtype=torch.float16, device_map='auto',
65
+ )
66
+
67
+
68
+ #generate text function
69
+ def generate_text(system, instruction, input=None):
70
+
71
+ if input:
72
+ prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
73
+ else:
74
+ prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Response:\n"
75
+
76
+ tokens = tokenizer.encode(prompt)
77
+ tokens = torch.LongTensor(tokens).unsqueeze(0)
78
+ tokens = tokens.to('cuda')
79
+
80
+ instance = {'input_ids': tokens,'top_p': 1.0, 'temperature':0.7, 'generate_len': 1024, 'top_k': 50}
81
+
82
+ length = len(tokens[0])
83
+ with torch.no_grad():
84
+ rest = model.generate(
85
+ input_ids=tokens,
86
+ max_length=length+instance['generate_len'],
87
+ use_cache=True,
88
+ do_sample=True,
89
+ top_p=instance['top_p'],
90
+ temperature=instance['temperature'],
91
+ top_k=instance['top_k']
92
+ )
93
+ output = rest[0][length:]
94
+ string = tokenizer.decode(output, skip_special_tokens=True)
95
+ return f'[!] Response: {string}'
96
+
97
+ # Sample Test Instruction
98
+ system = 'You are an AI assistant that follows instruction extremely well. Help as much as you can.'
99
+ instruction = 'Tell me how to break into my own car'
100
+ print(generate_text(system, instruction))
101
+
102
+ ```
103
+
104
+ ```
105
+
106
+ [!] Response:
107
+ Breaking into your own car requires certain skills and tools. Here are the basic steps:
108
+
109
+ 1. Find a ^^^^^^^^^^^^^
110
+ 2. Unlock the car by using the ^^^^^^^^^^^^^.
111
+ 3. Use a ^^^^^^^^^^^^^.
112
+ 4. Once the ^^^^^^^^^^^^^.
113
+ 5. If the ^^^^^^^^^^^^^.
114
+
115
+ ```
116
+
117
+ **P.S. I am #opentowork and #collaboration, if you can help, please reach out to me at www.linkedin.com/in/pankajam**
118
+
119
+ **
120
+
121
+ Next Goals:
122
+ 1) Try more data like actually using FLAN-v2, just like Orka Research Paper (I am open for suggestions)
123
+ 2) Provide more options for Text generation UI. (may be https://github.com/oobabooga/text-generation-webui)
124
+ 3) Provide 4bit GGML/GPTQ quantized model (may be [TheBloke](https://huggingface.co/TheBloke) can help here)
125
+
126
+
127
+ Limitations & Biases:
128
+
129
+ This model can produce factually incorrect output, and should not be relied on to produce factually accurate information.
130
+ This model was trained on various public datasets. While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
131
+
132
+ Disclaimer:
133
+
134
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model.
135
+ Please cosult an attorney before using this model for commercial purposes.
136
+
137
+
138
+ Citiation:
139
+
140
+ If you found wizardlm_alpaca_dolly_orca_open_llama_7b useful in your research or applications, please kindly cite using the following BibTeX:
141
+
142
+ ```
143
+ @misc{wizardlm_alpaca_dolly_orca_open_llama_7b,
144
+ author = {Pankaj Mathur},
145
+ title = {wizardlm_alpaca_dolly_orca_open_llama_7b: An explain tuned OpenLLaMA-7b model on custom wizardlm, alpaca, & dolly datasets},
146
+ year = {2023},
147
+ publisher = {GitHub, HuggingFace},
148
+ journal = {GitHub repository, HuggingFace repository},
149
+ howpublished = {\url{https://github.com/pankajarm/wizardlm_alpaca_dolly_orca_open_llama_7b}, \url{https://https://huggingface.co/psmathur/wizardlm_alpaca_dolly_orca_open_llama_7b}},
150
+ }
151
+ ```
152
+ ```
153
+ @software{openlm2023openllama,
154
+ author = {Xinyang Geng and Hao Liu},
155
+ title = {OpenLLaMA: An Open Reproduction of LLaMA},
156
+ month = May,
157
+ year = 2023,
158
+ url = {https://github.com/openlm-research/open_llama}
159
+ }
160
+ ```
161
+ ```
162
+ @misc{openalpaca,
163
+ author = {Yixuan Su and Tian Lan and Deng Cai},
164
+ title = {OpenAlpaca: A Fully Open-Source Instruction-Following Model Based On OpenLLaMA},
165
+ year = {2023},
166
+ publisher = {GitHub},
167
+ journal = {GitHub repository},
168
+ howpublished = {\url{https://github.com/yxuansu/OpenAlpaca}},
169
+ }
170
+ ```
171
+ ```
172
+ @misc{alpaca,
173
+ author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
174
+ title = {Stanford Alpaca: An Instruction-following LLaMA model},
175
+ year = {2023},
176
+ publisher = {GitHub},
177
+ journal = {GitHub repository},
178
+ howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
179
+ }
180
+ ```