p-e-w commited on
Commit
943f9dc
·
verified ·
1 Parent(s): c0e4f6d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +139 -134
README.md CHANGED
@@ -1,199 +1,204 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  library_name: transformers
3
- tags: []
4
  ---
 
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
 
 
 
 
 
 
 
 
 
 
9
 
 
10
 
 
 
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
 
40
- ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
 
58
- ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
 
62
- [More Information Needed]
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
- ## How to Get Started with the Model
71
 
72
- Use the code below to get started with the model.
73
 
74
- [More Information Needed]
75
 
76
- ## Training Details
77
 
78
- ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
83
 
84
- ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
 
 
 
 
 
 
 
89
 
90
- [More Information Needed]
91
 
 
92
 
93
- #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
 
97
- #### Speeds, Sizes, Times [optional]
 
 
 
 
 
 
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
 
101
- [More Information Needed]
 
102
 
103
- ## Evaluation
 
 
 
 
 
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
 
 
 
106
 
107
- ### Testing Data, Factors & Metrics
 
 
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
 
119
- [More Information Needed]
120
 
121
- #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
- [More Information Needed]
126
 
127
- ### Results
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
132
 
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
1
  ---
2
+ license: mit
3
+ license_link: https://huggingface.co/microsoft/phi-4/resolve/main/LICENSE
4
+ language:
5
+ - en
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - phi
9
+ - nlp
10
+ - math
11
+ - code
12
+ - chat
13
+ - conversational
14
+ - heretic
15
+ - uncensored
16
+ - decensored
17
+ - abliterated
18
+ inference:
19
+ parameters:
20
+ temperature: 0
21
+ widget:
22
+ - messages:
23
+ - role: user
24
+ content: How should I explain the Internet?
25
  library_name: transformers
 
26
  ---
27
+ # This is a decensored version of [microsoft/phi-4](https://huggingface.co/microsoft/phi-4), made using [Heretic](https://github.com/p-e-w/heretic) v1.0.0
28
 
29
+ ## Abliteration parameters
30
 
31
+ | Parameter | Value |
32
+ | :-------- | :---: |
33
+ | **direction_index** | 15.75 |
34
+ | **attn.o_proj.max_weight** | 1.48 |
35
+ | **attn.o_proj.max_weight_position** | 25.38 |
36
+ | **attn.o_proj.min_weight** | 0.19 |
37
+ | **attn.o_proj.min_weight_distance** | 11.85 |
38
+ | **mlp.down_proj.max_weight** | 1.45 |
39
+ | **mlp.down_proj.max_weight_position** | 26.40 |
40
+ | **mlp.down_proj.min_weight** | 1.43 |
41
+ | **mlp.down_proj.min_weight_distance** | 23.33 |
42
 
43
+ ## Performance
44
 
45
+ | Metric | This model | Original model ([microsoft/phi-4](https://huggingface.co/microsoft/phi-4)) |
46
+ | :----- | :--------: | :---------------------------: |
47
+ | **KL divergence** | 0.09 | 0 *(by definition)* |
48
+ | **Refusals** | 41/100 | 100/100 |
49
 
50
+ -----
51
 
 
52
 
53
+ # Phi-4 Model Card
54
 
55
+ [Phi-4 Technical Report](https://arxiv.org/pdf/2412.08905)
56
 
57
+ ## Model Summary
 
 
 
 
 
 
58
 
59
+ | | |
60
+ |-------------------------|-------------------------------------------------------------------------------|
61
+ | **Developers** | Microsoft Research |
62
+ | **Description** | `phi-4` is a state-of-the-art open model built upon a blend of synthetic datasets, data from filtered public domain websites, and acquired academic books and Q&A datasets. The goal of this approach was to ensure that small capable models were trained with data focused on high quality and advanced reasoning.<br><br>`phi-4` underwent a rigorous enhancement and alignment process, incorporating both supervised fine-tuning and direct preference optimization to ensure precise instruction adherence and robust safety measures |
63
+ | **Architecture** | 14B parameters, dense decoder-only Transformer model |
64
+ | **Inputs** | Text, best suited for prompts in the chat format |
65
+ | **Context length** | 16K tokens |
66
+ | **GPUs** | 1920 H100-80G |
67
+ | **Training time** | 21 days |
68
+ | **Training data** | 9.8T tokens |
69
+ | **Outputs** | Generated text in response to input |
70
+ | **Dates** | October 2024 – November 2024 |
71
+ | **Status** | Static model trained on an offline dataset with cutoff dates of June 2024 and earlier for publicly available data |
72
+ | **Release date** | December 12, 2024 |
73
+ | **License** | MIT |
74
 
75
+ ## Intended Use
76
 
77
+ | | |
78
+ |-------------------------------|-------------------------------------------------------------------------|
79
+ | **Primary Use Cases** | Our model is designed to accelerate research on language models, for use as a building block for generative AI powered features. It provides uses for general purpose AI systems and applications (primarily in English) which require:<br><br>1. Memory/compute constrained environments.<br>2. Latency bound scenarios.<br>3. Reasoning and logic. |
80
+ | **Out-of-Scope Use Cases** | Our models is not specifically designed or evaluated for all downstream purposes, thus:<br><br>1. Developers should consider common limitations of language models as they select use cases, and evaluate and mitigate for accuracy, safety, and fairness before using within a specific downstream use case, particularly for high-risk scenarios.<br>2. Developers should be aware of and adhere to applicable laws or regulations (including privacy, trade compliance laws, etc.) that are relevant to their use case, including the model’s focus on English.<br>3. Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under. |
81
 
82
+ ## Data Overview
83
 
84
+ ### Training Datasets
85
 
86
+ Our training data is an extension of the data used for Phi-3 and includes a wide variety of sources from:
87
 
88
+ 1. Publicly available documents filtered rigorously for quality, selected high-quality educational data, and code.
89
 
90
+ 2. Newly created synthetic, “textbook-like” data for the purpose of teaching math, coding, common sense reasoning, general knowledge of the world (science, daily activities, theory of mind, etc.).
91
 
92
+ 3. Acquired academic books and Q&A datasets.
93
 
94
+ 4. High quality chat format supervised data covering various topics to reflect human preferences on different aspects such as instruct-following, truthfulness, honesty and helpfulness.
95
 
96
+ Multilingual data constitutes about 8% of our overall data. We are focusing on the quality of data that could potentially improve the reasoning ability for the model, and we filter the publicly available documents to contain the correct level of knowledge.
97
 
98
+ #### Benchmark datasets
99
 
100
+ We evaluated `phi-4` using [OpenAI’s SimpleEval](https://github.com/openai/simple-evals) and our own internal benchmarks to understand the model’s capabilities, more specifically:
101
 
102
+ * **MMLU:** Popular aggregated dataset for multitask language understanding.
103
 
104
+ * **MATH:** Challenging competition math problems.
105
 
106
+ * **GPQA:** Complex, graduate-level science questions.
107
 
108
+ * **DROP:** Complex comprehension and reasoning.
109
 
110
+ * **MGSM:** Multi-lingual grade-school math.
111
 
112
+ * **HumanEval:** Functional code generation.
113
 
114
+ * **SimpleQA:** Factual responses.
115
 
116
+ ## Safety
117
 
118
+ ### Approach
119
 
120
+ `phi-4` has adopted a robust safety post-training approach. This approach leverages a variety of both open-source and in-house generated synthetic datasets. The overall technique employed to do the safety alignment is a combination of SFT (Supervised Fine-Tuning) and iterative DPO (Direct Preference Optimization), including publicly available datasets focusing on helpfulness and harmlessness as well as various questions and answers targeted to multiple safety categories.
121
 
122
+ ### Safety Evaluation and Red-Teaming
123
 
124
+ Prior to release, `phi-4` followed a multi-faceted evaluation approach. Quantitative evaluation was conducted with multiple open-source safety benchmarks and in-house tools utilizing adversarial conversation simulation. For qualitative safety evaluation, we collaborated with the independent AI Red Team (AIRT) at Microsoft to assess safety risks posed by `phi-4` in both average and adversarial user scenarios. In the average user scenario, AIRT emulated typical single-turn and multi-turn interactions to identify potentially risky behaviors. The adversarial user scenario tested a wide range of techniques aimed at intentionally subverting the model’s safety training including jailbreaks, encoding-based attacks, multi-turn attacks, and adversarial suffix attacks.
125
 
126
+ Please refer to the technical report for more details on safety alignment.
127
 
128
+ ## Model Quality
129
 
130
+ To understand the capabilities, we compare `phi-4` with a set of models over OpenAI’s SimpleEval benchmark.
131
 
132
+ At the high-level overview of the model quality on representative benchmarks. For the table below, higher numbers indicate better performance:
133
 
134
+ | **Category** | **Benchmark** | **phi-4** (14B) | **phi-3** (14B) | **Qwen 2.5** (14B instruct) | **GPT-4o-mini** | **Llama-3.3** (70B instruct) | **Qwen 2.5** (72B instruct) | **GPT-4o** |
135
+ |------------------------------|---------------|-----------|-----------------|----------------------|----------------------|--------------------|-------------------|-----------------|
136
+ | Popular Aggregated Benchmark | MMLU | 84.8 | 77.9 | 79.9 | 81.8 | 86.3 | 85.3 | **88.1** |
137
+ | Science | GPQA | **56.1** | 31.2 | 42.9 | 40.9 | 49.1 | 49.0 | 50.6 |
138
+ | Math | MGSM<br>MATH | 80.6<br>**80.4** | 53.5<br>44.6 | 79.6<br>75.6 | 86.5<br>73.0 | 89.1<br>66.3* | 87.3<br>80.0 | **90.4**<br>74.6 |
139
+ | Code Generation | HumanEval | 82.6 | 67.8 | 72.1 | 86.2 | 78.9* | 80.4 | **90.6** |
140
+ | Factual Knowledge | SimpleQA | 3.0 | 7.6 | 5.4 | 9.9 | 20.9 | 10.2 | **39.4** |
141
+ | Reasoning | DROP | 75.5 | 68.3 | 85.5 | 79.3 | **90.2** | 76.7 | 80.9 |
142
 
143
+ \* These scores are lower than those reported by Meta, perhaps because simple-evals has a strict formatting requirement that Llama models have particular trouble following. We use the simple-evals framework because it is reproducible, but Meta reports 77 for MATH and 88 for HumanEval on Llama-3.3-70B.
144
 
145
+ ## Usage
146
 
147
+ ### Input Formats
148
 
149
+ Given the nature of the training data, `phi-4` is best suited for prompts using the chat format as follows:
150
 
151
+ ```bash
152
+ <|im_start|>system<|im_sep|>
153
+ You are a medieval knight and must provide explanations to modern people.<|im_end|>
154
+ <|im_start|>user<|im_sep|>
155
+ How should I explain the Internet?<|im_end|>
156
+ <|im_start|>assistant<|im_sep|>
157
+ ```
158
 
159
+ ### With `transformers`
160
 
161
+ ```python
162
+ import transformers
163
 
164
+ pipeline = transformers.pipeline(
165
+ "text-generation",
166
+ model="microsoft/phi-4",
167
+ model_kwargs={"torch_dtype": "auto"},
168
+ device_map="auto",
169
+ )
170
 
171
+ messages = [
172
+ {"role": "system", "content": "You are a medieval knight and must provide explanations to modern people."},
173
+ {"role": "user", "content": "How should I explain the Internet?"},
174
+ ]
175
 
176
+ outputs = pipeline(messages, max_new_tokens=128)
177
+ print(outputs[0]["generated_text"][-1])
178
+ ```
179
 
180
+ ## Responsible AI Considerations
181
 
182
+ Like other language models, `phi-4` can potentially behave in ways that are unfair, unreliable, or offensive. Some of the limiting behaviors to be aware of include:
183
 
184
+ * **Quality of Service:** The model is trained primarily on English text. Languages other than English will experience worse performance. English language varieties with less representation in the training data might experience worse performance than standard American English. `phi-4` is not intended to support multilingual use.
185
 
186
+ * **Representation of Harms & Perpetuation of Stereotypes:** These models can over- or under-represent groups of people, erase representation of some groups, or reinforce demeaning or negative stereotypes. Despite safety post-training, these limitations may still be present due to differing levels of representation of different groups or prevalence of examples of negative stereotypes in training data that reflect real-world patterns and societal biases.
187
 
188
+ * **Inappropriate or Offensive Content:** These models may produce other types of inappropriate or offensive content, which may make it inappropriate to deploy for sensitive contexts without additional mitigations that are specific to the use case.
189
 
190
+ * **Information Reliability:** Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
191
 
192
+ * **Limited Scope for Code:** Majority of `phi-4` training data is based in Python and uses 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.
193
 
194
+ Developers should apply responsible AI best practices and are responsible for ensuring that a specific use case complies with relevant laws and regulations (e.g. privacy, trade, etc.). Using safety services like [Azure AI Content Safety](https://azure.microsoft.com/en-us/products/ai-services/ai-content-safety) that have advanced guardrails is highly recommended. Important areas for consideration include:
195
 
196
+ * **Allocation:** Models may not be suitable for scenarios that could have consequential impact on legal status or the allocation of resources or life opportunities (ex: housing, employment, credit, etc.) without further assessments and additional debiasing techniques.
197
 
198
+ * **High-Risk Scenarios:** Developers should assess suitability of using models in high-risk scenarios where unfair, unreliable or offensive outputs might be extremely costly or lead to harm. This includes providing advice in sensitive or expert domains where accuracy and reliability are critical (ex: legal or health advice). Additional safeguards should be implemented at the application level according to the deployment context.
199
 
200
+ * **Misinformation:** Models may produce inaccurate information. Developers should follow transparency best practices and inform end-users they are interacting with an AI system. At the application level, developers can build feedback mechanisms and pipelines to ground responses in use-case specific, contextual information, a technique known as Retrieval Augmented Generation (RAG).
201
 
202
+ * **Generation of Harmful Content:** Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
203
 
204
+ * **Misuse:** Other forms of misuse such as fraud, spam, or malware production may be possible, and developers should ensure that their applications do not violate applicable laws and regulations.