gugarosa commited on
Commit
80c0ba9
1 Parent(s): a286f5c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -39
README.md CHANGED
@@ -6,21 +6,24 @@ license_link: https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20L
6
  language:
7
  - en
8
  pipeline_tag: text-generation
 
 
 
9
  ---
10
  ## Model Summary
11
 
12
- The language model phi-1.5 is a Transformer with **1.3 billion** parameters. It was trained using the same data sources as [phi-1](https://huggingface.co/microsoft/phi-1), augmented with a new data source that consists of various NLP synthetic texts. When assessed against benchmarks testing common sense, language understanding, and logical reasoning, phi-1.5 demonstrates a nearly state-of-the-art performance among models with less than 10 billion parameters.
13
 
14
- We **did not** fine-tune phi-1.5 either for **instruction following or 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.
15
 
16
  For a safer model release, we exclude generic web-crawl data sources such as common-crawl from the training. This strategy prevents direct exposure to potentially harmful online content, enhancing the model's safety without RLHF. However, the model is still vulnerable to generating harmful content. We hope the model can help the research community to further study the safety of language models.
17
 
18
- phi-1.5 can write poems, draft emails, create stories, summarize texts, write Python code (such as downloading a Hugging Face transformer model), etc.
19
 
20
  ## Intended Uses
21
- Given the nature of the training data, phi-1.5 is best suited for prompts using the QA format, the chat format, and the code format. Note that phi-1.5, being a base model, often produces irrelevant text following the main answer. In the following example, we've truncated the answer for illustrative purposes only.
22
 
23
- #### QA format:
24
 
25
  ```markdown
26
  Write a detailed analogy between mathematics and a lighthouse.
@@ -29,7 +32,7 @@ Answer: Mathematics is like a lighthouse, guiding us through the vast ocean of n
29
  ```
30
  where the model generates the text after "Answer:".
31
 
32
- #### Chat format:
33
 
34
  ```markdown
35
  Alice: I don't know why, I'm struggling to maintain focus while studying. Any suggestions?
@@ -52,7 +55,8 @@ Bob: Yeah, and remember that it's okay to ask for help if you need it. We're her
52
  ```
53
  where the model generates the text after the first "Bob:".
54
 
55
- #### Code format:
 
56
  ```python
57
  def print_prime(n):
58
  """
@@ -72,10 +76,36 @@ def print_prime(n):
72
  where the model generates the text after the comments.
73
 
74
  **Notes**
75
- * phi-1.5 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.
76
- * Direct adoption for production tasks is out of the scope of this research project. As a result, phi-1.5 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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
- ## Limitations of phi-1.5
79
 
80
  * Generate Inaccurate Code and Facts: The model often produces incorrect code snippets and statements. Users should treat these outputs as suggestions or starting points, not as definitive or accurate solutions.
81
  * Limited Scope for code: If the model generates Python scripts that utilize uncommon packages or scripts in other languages, we strongly recommend users manually verify all API uses.
@@ -97,39 +127,11 @@ where the model generates the text after the comments.
97
  ### Software
98
  * [PyTorch](https://github.com/pytorch/pytorch)
99
  * [DeepSpeed](https://github.com/microsoft/DeepSpeed)
100
- * [flash-attention](https://github.com/HazyResearch/flash-attention)
101
 
102
  ### License
103
  The model is licensed under the [Research License](https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20License.docx).
104
 
105
- ### Sample Code
106
- ```python
107
- import torch
108
- from transformers import AutoModelForCausalLM, AutoTokenizer
109
-
110
- torch.set_default_device("cuda")
111
- model = AutoModelForCausalLM.from_pretrained("microsoft/phi-1_5", trust_remote_code=True)
112
- tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1_5", trust_remote_code=True)
113
- inputs = tokenizer('''```python
114
- def print_prime(n):
115
- """
116
- Print all primes between 1 and n
117
- """''', return_tensors="pt", return_attention_mask=False)
118
-
119
- outputs = model.generate(**inputs, max_length=200)
120
- text = tokenizer.batch_decode(outputs)[0]
121
- print(text)
122
- ```
123
-
124
- If you need to use the model in a lower precision (e.g., FP16), please wrap the model's forward pass with `torch.autocast()`, as follows:
125
- ```python
126
- with torch.autocast(model.device.type, dtype=torch.float16, enabled=True):
127
- outputs = model.generate(**inputs, max_length=200)
128
- ```
129
-
130
- **Remark.** In the generation function, our model currently does not support beam search (`num_beams` > 1).
131
- Furthermore, in the forward pass of the model, we currently do not support outputting hidden states or attention values, or using custom input embeddings (instead of the model's).
132
-
133
  ### Citation
134
 
135
  You can find the paper at https://arxiv.org/abs/2309.05463
 
6
  language:
7
  - en
8
  pipeline_tag: text-generation
9
+ tags:
10
+ - nlp
11
+ - code
12
  ---
13
  ## Model Summary
14
 
15
+ The language model Phi-1.5 is a Transformer with **1.3 billion** parameters. It was trained using the same data sources as [phi-1](https://huggingface.co/microsoft/phi-1), augmented with a new data source that consists of various NLP synthetic texts. When assessed against benchmarks testing common sense, language understanding, and logical reasoning, Phi-1.5 demonstrates a nearly state-of-the-art performance among models with less than 10 billion parameters.
16
 
17
+ We **did not** fine-tune Phi-1.5 either for **instruction following or 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.
18
 
19
  For a safer model release, we exclude generic web-crawl data sources such as common-crawl from the training. This strategy prevents direct exposure to potentially harmful online content, enhancing the model's safety without RLHF. However, the model is still vulnerable to generating harmful content. We hope the model can help the research community to further study the safety of language models.
20
 
21
+ Phi-1.5 can write poems, draft emails, create stories, summarize texts, write Python code (such as downloading a Hugging Face transformer model), etc.
22
 
23
  ## Intended Uses
24
+ Given the nature of the training data, Phi-1.5 is best suited for prompts using the QA format, the chat format, and the code format. Note that Phi-1.5, being a base model, often produces irrelevant text following the main answer. In the following example, we've truncated the answer for illustrative purposes only.
25
 
26
+ ### QA Format:
27
 
28
  ```markdown
29
  Write a detailed analogy between mathematics and a lighthouse.
 
32
  ```
33
  where the model generates the text after "Answer:".
34
 
35
+ ### Chat Format:
36
 
37
  ```markdown
38
  Alice: I don't know why, I'm struggling to maintain focus while studying. Any suggestions?
 
55
  ```
56
  where the model generates the text after the first "Bob:".
57
 
58
+ ### Code Format:
59
+
60
  ```python
61
  def print_prime(n):
62
  """
 
76
  where the model generates the text after the comments.
77
 
78
  **Notes**
79
+ * Phi-1.5 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.
80
+ * Direct adoption for production tasks is out of the scope of this research project. As a result, Phi-1.5 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.
81
+ * If you are using `transformers>=4.36.0`, always load the model with `trust_remote_code=True` to prevent side-effects.
82
+
83
+ ## Sample Code
84
+
85
+ ```python
86
+ import torch
87
+ from transformers import AutoModelForCausalLM, AutoTokenizer
88
+
89
+ torch.set_default_device("cuda")
90
+
91
+ model = AutoModelForCausalLM.from_pretrained("microsoft/phi-1_5", torch_dtype="auto", trust_remote_code=True)
92
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1_5", trust_remote_code=True)
93
+
94
+ inputs = tokenizer('''```python
95
+ def print_prime(n):
96
+ """
97
+ Print all primes between 1 and n
98
+ """''', return_tensors="pt", return_attention_mask=False)
99
+
100
+ outputs = model.generate(**inputs, max_length=200)
101
+ text = tokenizer.batch_decode(outputs)[0]
102
+ print(text)
103
+ ```
104
+
105
+ **Remark.** In the generation function, our model currently does not support beam search (`num_beams > 1`).
106
+ Furthermore, in the forward pass of the model, we currently do not support outputting hidden states or attention values, or using custom input embeddings.
107
 
108
+ ## Limitations of Phi-1.5
109
 
110
  * Generate Inaccurate Code and Facts: The model often produces incorrect code snippets and statements. Users should treat these outputs as suggestions or starting points, not as definitive or accurate solutions.
111
  * Limited Scope for code: If the model generates Python scripts that utilize uncommon packages or scripts in other languages, we strongly recommend users manually verify all API uses.
 
127
  ### Software
128
  * [PyTorch](https://github.com/pytorch/pytorch)
129
  * [DeepSpeed](https://github.com/microsoft/DeepSpeed)
130
+ * [Flash-Attention](https://github.com/HazyResearch/flash-attention)
131
 
132
  ### License
133
  The model is licensed under the [Research License](https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20License.docx).
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  ### Citation
136
 
137
  You can find the paper at https://arxiv.org/abs/2309.05463