afrideva commited on
Commit
59a5e3b
1 Parent(s): 4e03c7a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +197 -0
README.md ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: microsoft/phi-2
3
+ inference: false
4
+ language:
5
+ - en
6
+ license: other
7
+ license_link: https://huggingface.co/microsoft/phi-2/resolve/main/LICENSE
8
+ license_name: microsoft-research-license
9
+ model_creator: microsoft
10
+ model_name: phi-2
11
+ pipeline_tag: text-generation
12
+ quantized_by: afrideva
13
+ tags:
14
+ - nlp
15
+ - code
16
+ - gguf
17
+ - ggml
18
+ - quantized
19
+ - q2_k
20
+ - q3_k_m
21
+ - q4_k_m
22
+ - q5_k_m
23
+ - q6_k
24
+ - q8_0
25
+ ---
26
+ # microsoft/phi-2-GGUF
27
+
28
+ Quantized GGUF model files for [phi-2](https://huggingface.co/microsoft/phi-2) from [microsoft](https://huggingface.co/microsoft)
29
+
30
+
31
+ | Name | Quant method | Size |
32
+ | ---- | ---- | ---- |
33
+ | [phi-2.fp16.gguf](https://huggingface.co/afrideva/phi-2-GGUF/resolve/main/phi-2.fp16.gguf) | fp16 | 5.56 GB |
34
+ | [phi-2.q2_k.gguf](https://huggingface.co/afrideva/phi-2-GGUF/resolve/main/phi-2.q2_k.gguf) | q2_k | 1.17 GB |
35
+ | [phi-2.q3_k_m.gguf](https://huggingface.co/afrideva/phi-2-GGUF/resolve/main/phi-2.q3_k_m.gguf) | q3_k_m | 1.48 GB |
36
+ | [phi-2.q4_k_m.gguf](https://huggingface.co/afrideva/phi-2-GGUF/resolve/main/phi-2.q4_k_m.gguf) | q4_k_m | 1.79 GB |
37
+ | [phi-2.q5_k_m.gguf](https://huggingface.co/afrideva/phi-2-GGUF/resolve/main/phi-2.q5_k_m.gguf) | q5_k_m | 2.07 GB |
38
+ | [phi-2.q6_k.gguf](https://huggingface.co/afrideva/phi-2-GGUF/resolve/main/phi-2.q6_k.gguf) | q6_k | 2.29 GB |
39
+ | [phi-2.q8_0.gguf](https://huggingface.co/afrideva/phi-2-GGUF/resolve/main/phi-2.q8_0.gguf) | q8_0 | 2.96 GB |
40
+
41
+
42
+
43
+ ## Original Model Card:
44
+ ## Model Summary
45
+
46
+ Phi-2 is a Transformer with **2.7 billion** parameters. It was trained using the same data sources as [Phi-1.5](https://huggingface.co/microsoft/phi-1.5), augmented with a new data source that consists of various NLP synthetic texts and filtered websites (for safety and educational value). When assessed against benchmarks testing common sense, language understanding, and logical reasoning, Phi-2 showcased a nearly state-of-the-art performance among models with less than 13 billion parameters.
47
+
48
+ Our model hasn't been fine-tuned through reinforcement learning from human feedback. The intention behind crafting this open-source model is to provide the research community with a non-restricted small model to explore vital safety challenges, such as reducing toxicity, understanding societal biases, enhancing controllability, and more.
49
+
50
+ ## Intended Uses
51
+
52
+ Phi-2 is intended for research purposes only. Given the nature of the training data, the Phi-2 model is best suited for prompts using the QA format, the chat format, and the code format.
53
+
54
+ ### QA Format:
55
+
56
+ You can provide the prompt as a standalone question as follows:
57
+
58
+ ```markdown
59
+ Write a detailed analogy between mathematics and a lighthouse.
60
+ ```
61
+ where the model generates the text after "." .
62
+ To encourage the model to write more concise answers, you can also try the following QA format using "Instruct: \<prompt\>\nOutput:"
63
+ ```markdown
64
+ Instruct: Write a detailed analogy between mathematics and a lighthouse.
65
+ Output: Mathematics is like a lighthouse. Just as a lighthouse guides ships safely to shore, mathematics provides a guiding light in the world of numbers and logic. It helps us navigate through complex problems and find solutions. Just as a lighthouse emits a steady beam of light, mathematics provides a consistent framework for reasoning and problem-solving. It illuminates the path to understanding and helps us make sense of the world around us.
66
+ ```
67
+ where the model generates the text after "Output:".
68
+
69
+ ### Chat Format:
70
+
71
+ ```markdown
72
+ Alice: I don't know why, I'm struggling to maintain focus while studying. Any suggestions?
73
+ Bob: Well, have you tried creating a study schedule and sticking to it?
74
+ Alice: Yes, I have, but it doesn't seem to help much.
75
+ Bob: Hmm, maybe you should try studying in a quiet environment, like the library.
76
+ Alice: ...
77
+ ```
78
+
79
+ where the model generates the text after the first "Bob:".
80
+
81
+ ### Code Format:
82
+
83
+ ```python
84
+ def print_prime(n):
85
+ """
86
+ Print all primes between 1 and n
87
+ """
88
+ primes = []
89
+ for num in range(2, n+1):
90
+ is_prime = True
91
+ for i in range(2, int(math.sqrt(num))+1):
92
+ if num % i == 0:
93
+ is_prime = False
94
+ break
95
+ if is_prime:
96
+ primes.append(num)
97
+ print(primes)
98
+ ```
99
+ where the model generates the text after the comments.
100
+
101
+ **Notes:**
102
+ * Phi-2 is intended for research purposes. The model-generated text/code should be treated as a starting point rather than a definitive solution for potential use cases. Users should be cautious when employing these models in their applications.
103
+ * Direct adoption for production tasks is out of the scope of this research project. As a result, the Phi-2 model has not been tested to ensure that it performs adequately for any production-level application. Please refer to the limitation sections of this document for more details.
104
+ * If you are using `transformers>=4.36.0`, always load the model with `trust_remote_code=True` to prevent side-effects.
105
+
106
+ ## Sample Code
107
+
108
+ There are four types of execution mode:
109
+
110
+ 1. FP16 / Flash-Attention / CUDA:
111
+ ```python
112
+ model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype="auto", flash_attn=True, flash_rotary=True, fused_dense=True, device_map="cuda", trust_remote_code=True)
113
+ ```
114
+ 2. FP16 / CUDA:
115
+ ```python
116
+ model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype="auto", device_map="cuda", trust_remote_code=True)
117
+ ```
118
+ 3. FP32 / CUDA:
119
+ ```python
120
+ model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype=torch.float32, device_map="cuda", trust_remote_code=True)
121
+ ```
122
+ 4. FP32 / CPU:
123
+ ```python
124
+ model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype=torch.float32, device_map="cpu", trust_remote_code=True)
125
+ ```
126
+
127
+ To ensure the maximum compatibility, we recommend using the second execution mode (FP16 / CUDA), as follows:
128
+
129
+ ```python
130
+ import torch
131
+ from transformers import AutoModelForCausalLM, AutoTokenizer
132
+
133
+ torch.set_default_device("cuda")
134
+
135
+ model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype="auto", trust_remote_code=True)
136
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", trust_remote_code=True)
137
+
138
+ inputs = tokenizer('''def print_prime(n):
139
+ """
140
+ Print all primes between 1 and n
141
+ """''', return_tensors="pt", return_attention_mask=False)
142
+
143
+ outputs = model.generate(**inputs, max_length=200)
144
+ text = tokenizer.batch_decode(outputs)[0]
145
+ print(text)
146
+ ```
147
+
148
+ **Remark:** In the generation function, our model currently does not support beam search (`num_beams > 1`).
149
+ Furthermore, in the forward pass of the model, we currently do not support outputting hidden states or attention values, or using custom input embeddings.
150
+
151
+ ## Limitations of Phi-2
152
+
153
+ * Generate Inaccurate Code and Facts: The model may produce incorrect code snippets and statements. Users should treat these outputs as suggestions or starting points, not as definitive or accurate solutions.
154
+
155
+ * Limited Scope for code: Majority of Phi-2 training data is based in Python and use common packages such as "typing, math, random, collections, datetime, itertools". If the model generates Python scripts that utilize other packages or scripts in other languages, we strongly recommend users manually verify all API uses.
156
+
157
+ * Unreliable Responses to Instruction: The model has not undergone instruction fine-tuning. As a result, it may struggle or fail to adhere to intricate or nuanced instructions provided by users.
158
+
159
+ * Language Limitations: The model is primarily designed to understand standard English. Informal English, slang, or any other languages might pose challenges to its comprehension, leading to potential misinterpretations or errors in response.
160
+
161
+ * Potential Societal Biases: Phi-2 is not entirely free from societal biases despite efforts in assuring trainig data safety. There's a possibility it may generate content that mirrors these societal biases, particularly if prompted or instructed to do so. We urge users to be aware of this and to exercise caution and critical thinking when interpreting model outputs.
162
+
163
+ * Toxicity: Despite being trained with carefully selected data, the model can still produce harmful content if explicitly prompted or instructed to do so. We chose to release the model for research purposes only -- We hope to help the open-source community develop the most effective ways to reduce the toxicity of a model directly after pretraining.
164
+
165
+ * Verbosity: Phi-2 being a base model often produces irrelevant or extra text and responses following its first answer to user prompts within a single turn. This is due to its training dataset being primarily textbooks, which results in textbook-like responses.
166
+
167
+ ## Training
168
+
169
+ ### Model
170
+
171
+ * Architecture: a Transformer-based model with next-word prediction objective
172
+
173
+ * Context length: 2048 tokens
174
+
175
+ * Dataset size: 250B tokens, combination of NLP synthetic data created by AOAI GPT-3.5 and filtered web data from Falcon RefinedWeb and SlimPajama, which was assessed by AOAI GPT-4.
176
+
177
+ * Training tokens: 1.4T tokens
178
+
179
+ * GPUs: 96xA100-80G
180
+
181
+ * Training time: 14 days
182
+
183
+ ### Software
184
+
185
+ * [PyTorch](https://github.com/pytorch/pytorch)
186
+
187
+ * [DeepSpeed](https://github.com/microsoft/DeepSpeed)
188
+
189
+ * [Flash-Attention](https://github.com/HazyResearch/flash-attention)
190
+
191
+ ### License
192
+
193
+ The model is licensed under the [microsoft-research-license](https://huggingface.co/microsoft/phi-2/resolve/main/LICENSE).
194
+
195
+ ## Trademarks
196
+
197
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.