commit 66ae41ef6b9d700d4ef600425434e28fe7e6597b Author: ModelHub XC Date: Wed Jul 8 15:09:11 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: gabriellarson/Phi-mini-MoE-instruct-GGUF Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a11b12f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,60 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ2_S.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ2_XS.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ2_XXS.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q4_0.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q5_0.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-F16.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ1_M.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ1_S.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ2_M.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q2_K.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ3_M.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ3_S.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ3_XXS.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q2_K_S.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ3_XS.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-IQ4_XS.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text +Phi-mini-MoE-instruct-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..700edcc --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +Microsoft. +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/NOTICE.md b/NOTICE.md new file mode 100644 index 0000000..ee58e83 --- /dev/null +++ b/NOTICE.md @@ -0,0 +1,38 @@ +NOTICES AND INFORMATION +Do Not Translate or Localize + +This software incorporates material from third parties. + +**Component.** https://github.com/Dao-AILab/flash-attention + +**Open Source License/Copyright Notice.** + +BSD 3-Clause License + +Copyright (c) 2022, the respective contributors, as shown by the AUTHORS file. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/Phi-mini-MoE-instruct-F16.gguf b/Phi-mini-MoE-instruct-F16.gguf new file mode 100644 index 0000000..96b7b64 --- /dev/null +++ b/Phi-mini-MoE-instruct-F16.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce9c9b134d52b441c39d8f08c6da8e4f400ebd3a46ec9620a5f13763908f94ae +size 15302001184 diff --git a/Phi-mini-MoE-instruct-IQ1_M.gguf b/Phi-mini-MoE-instruct-IQ1_M.gguf new file mode 100644 index 0000000..344317d --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ1_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b5eaae25dad1db4bcbbe396c084360baf0e5870fc59081853a6c40c35aed789 +size 2520077120 diff --git a/Phi-mini-MoE-instruct-IQ1_S.gguf b/Phi-mini-MoE-instruct-IQ1_S.gguf new file mode 100644 index 0000000..e60270e --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ1_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c9aa4008f88502c4ba15695051fc8eb1b284f9e9188165e794986dd452df501 +size 2409976640 diff --git a/Phi-mini-MoE-instruct-IQ2_M.gguf b/Phi-mini-MoE-instruct-IQ2_M.gguf new file mode 100644 index 0000000..5ecc6c7 --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ2_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f73905efa8c020627652a6f68097881b253f05fd2a94dcb1044036f01aa5662 +size 3102792512 diff --git a/Phi-mini-MoE-instruct-IQ2_S.gguf b/Phi-mini-MoE-instruct-IQ2_S.gguf new file mode 100644 index 0000000..229a9d2 --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ2_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1c3537f9bc5b9ea4c9239f288a0f257b5acc8c4aabb32065fae9a2535dc4c9a +size 2955991872 diff --git a/Phi-mini-MoE-instruct-IQ2_XS.gguf b/Phi-mini-MoE-instruct-IQ2_XS.gguf new file mode 100644 index 0000000..888d5d5 --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ2_XS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:61a167545e8ef6341e7d15e987cf131d60283a82a9c864dad39137533a9860fa +size 2867155776 diff --git a/Phi-mini-MoE-instruct-IQ2_XXS.gguf b/Phi-mini-MoE-instruct-IQ2_XXS.gguf new file mode 100644 index 0000000..f8e3772 --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ2_XXS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb8bacc4dd67fea9630d0359064b621d5932208ed69c227b947861a634644e5f +size 2703577920 diff --git a/Phi-mini-MoE-instruct-IQ3_M.gguf b/Phi-mini-MoE-instruct-IQ3_M.gguf new file mode 100644 index 0000000..b2e54c3 --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ3_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11874b84bcc1b922423e55303b4eedaa2e540547170de3e94e08c9204321bcf1 +size 3736798016 diff --git a/Phi-mini-MoE-instruct-IQ3_S.gguf b/Phi-mini-MoE-instruct-IQ3_S.gguf new file mode 100644 index 0000000..6d79b9a --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ3_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4dee7118898c993e7b737181238e23b5c2321da7200af8e6cbc22ec01fbd7cf1 +size 3634037568 diff --git a/Phi-mini-MoE-instruct-IQ3_XS.gguf b/Phi-mini-MoE-instruct-IQ3_XS.gguf new file mode 100644 index 0000000..43384ba --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ3_XS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b616c0db3efa294f2c2556d44859dc487412441f1bc264675d9dd6a83b783dd +size 3461022528 diff --git a/Phi-mini-MoE-instruct-IQ3_XXS.gguf b/Phi-mini-MoE-instruct-IQ3_XXS.gguf new file mode 100644 index 0000000..5d62ad5 --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ3_XXS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1dd75e1c9531ca921f95269fbc515fd690b8755cc207662d18958e3cb2de9655 +size 3354450752 diff --git a/Phi-mini-MoE-instruct-IQ4_XS.gguf b/Phi-mini-MoE-instruct-IQ4_XS.gguf new file mode 100644 index 0000000..9b02609 --- /dev/null +++ b/Phi-mini-MoE-instruct-IQ4_XS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8bacd30fbce34bee568e472ce94efa5eaa0c3f749f7c8a3798c7252e6e517882 +size 4195781440 diff --git a/Phi-mini-MoE-instruct-Q2_K.gguf b/Phi-mini-MoE-instruct-Q2_K.gguf new file mode 100644 index 0000000..d9f2127 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q2_K.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a9bf58f8e17008e38b76722077eec661dc70ac6ab8e81c2f039d4bdd5468f14 +size 3143596864 diff --git a/Phi-mini-MoE-instruct-Q2_K_S.gguf b/Phi-mini-MoE-instruct-Q2_K_S.gguf new file mode 100644 index 0000000..f092c91 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q2_K_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:763b8042ad96989e8920d0bf153af9f1150b3d80be53371ac90beb1cd956686e +size 3120528192 diff --git a/Phi-mini-MoE-instruct-Q3_K_L.gguf b/Phi-mini-MoE-instruct-Q3_K_L.gguf new file mode 100644 index 0000000..fe3fd8e --- /dev/null +++ b/Phi-mini-MoE-instruct-Q3_K_L.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e38ecc74e5ff5375d3d97713ccce6c449344f9ed5bbd2f9fc8d7d7d02ed976a7 +size 4166714176 diff --git a/Phi-mini-MoE-instruct-Q3_K_M.gguf b/Phi-mini-MoE-instruct-Q3_K_M.gguf new file mode 100644 index 0000000..251e5e6 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q3_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04ac2a9585cdeb72416e7e48f3021339b5098c0415c7264f2c1c60a224bee0b2 +size 3965911872 diff --git a/Phi-mini-MoE-instruct-Q3_K_S.gguf b/Phi-mini-MoE-instruct-Q3_K_S.gguf new file mode 100644 index 0000000..c66e873 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q3_K_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c02006bb1a8cc880cd6cc20c2089b9dbe4a3ae022ef866c78287274d6d4dabff +size 3616211776 diff --git a/Phi-mini-MoE-instruct-Q4_0.gguf b/Phi-mini-MoE-instruct-Q4_0.gguf new file mode 100644 index 0000000..5536aac --- /dev/null +++ b/Phi-mini-MoE-instruct-Q4_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93cb72b72727fb1dbff69fc0f8adb5e47c6cdad28842c1cbdd7a4d2da208cbfe +size 4362414912 diff --git a/Phi-mini-MoE-instruct-Q4_K_M.gguf b/Phi-mini-MoE-instruct-Q4_K_M.gguf new file mode 100644 index 0000000..c981b97 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q4_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cefb2a4e727322509dac921ee68735ecd4b3546ef28b4366ddab0efdeda1f42 +size 4993133376 diff --git a/Phi-mini-MoE-instruct-Q4_K_S.gguf b/Phi-mini-MoE-instruct-Q4_K_S.gguf new file mode 100644 index 0000000..708616a --- /dev/null +++ b/Phi-mini-MoE-instruct-Q4_K_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e622e7cfb934773c214ab5ab8079d85e367f2312a83166bbe9ee6d61476c1a3d +size 4616170304 diff --git a/Phi-mini-MoE-instruct-Q5_0.gguf b/Phi-mini-MoE-instruct-Q5_0.gguf new file mode 100644 index 0000000..7148fdf --- /dev/null +++ b/Phi-mini-MoE-instruct-Q5_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b77bd6844a8b4d5e6779f0b31ea5d937061a24d963a054ea8c78acfeb2d2d1eb +size 5301578560 diff --git a/Phi-mini-MoE-instruct-Q5_K_M.gguf b/Phi-mini-MoE-instruct-Q5_K_M.gguf new file mode 100644 index 0000000..52263e1 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q5_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d96e976395ccbac1a873c1474bb7ff4414b939e1c1ea70266b26c41d219de182 +size 5735164736 diff --git a/Phi-mini-MoE-instruct-Q5_K_S.gguf b/Phi-mini-MoE-instruct-Q5_K_S.gguf new file mode 100644 index 0000000..8e7b248 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q5_K_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f62d77bdb601b8d4bb767105eb9d90c9607467d7afb12dd209d0db8cfb1aedb +size 5411679040 diff --git a/Phi-mini-MoE-instruct-Q6_K.gguf b/Phi-mini-MoE-instruct-Q6_K.gguf new file mode 100644 index 0000000..f6ea423 --- /dev/null +++ b/Phi-mini-MoE-instruct-Q6_K.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4dfec6cc802585e5e1478c35649a5b25e09790ac5892d4153ce8d3f0de8538d +size 6771299136 diff --git a/Phi-mini-MoE-instruct-Q8_0.gguf b/Phi-mini-MoE-instruct-Q8_0.gguf new file mode 100644 index 0000000..a10d54d --- /dev/null +++ b/Phi-mini-MoE-instruct-Q8_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4784fad3cf824d235693341c305e5c9a9b60c25c7879710cca5672c24939c51f +size 8135148352 diff --git a/README.md b/README.md new file mode 100644 index 0000000..435c511 --- /dev/null +++ b/README.md @@ -0,0 +1,168 @@ +--- +license: mit +language: +- en +context_length: +- 4k +pipeline_tag: text-generation +base_model: +- microsoft/Phi-mini-MoE-instruct +--- + +## my suggested samplers: + +--repeat-penalty 1.05 --temp 0.0 --top-p 1.0 --top-k 1 + +## Model Summary + +Phi-mini-MoE is a lightweight Mixture of Experts (MoE) model with 7.6B total parameters and 2.4B activated parameters. It is compressed and distilled from the base model shared by [Phi-3.5-MoE](https://huggingface.co/microsoft/Phi-3.5-MoE-instruct) and [GRIN-MoE](https://huggingface.co/microsoft/GRIN-MoE) using the [SlimMoE](https://arxiv.org/pdf/2506.18349) approach, then post-trained via supervised fine-tuning and direct preference optimization for instruction following and safety. The model is trained on Phi-3 synthetic data and filtered public documents, with a focus on high-quality, reasoning-dense content. It is part of the SlimMoE series, which includes a smaller variant, [Phi-tiny-MoE](https://huggingface.co/microsoft/Phi-tiny-MoE-instruct), with 3.8B total and 1.1B activated parameters. + + +References:
+📖 [SlimMoE](https://arxiv.org/pdf/2506.18349)
+📖 [Phi-3 Technical Report](https://arxiv.org/abs/2404.14219)
+📖 [GRIN-MoE](https://arxiv.org/abs/2409.12136)
+ +## Intended Uses + +### Primary Use Cases + +The model is intended for commercial and research use in English. The model provides uses for general purpose AI systems and applications which require memory/compute constrained environments and latency bound scenarios. + +### Use Case Considerations + +Our models are not specifically designed or evaluated for all downstream purposes. Developers should consider common limitations of language models as they select use cases, and evaluate and mitigate for accuracy, safety, and fariness before using within a specific downstream use case, particularly for high risk scenarios. 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. + +***Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.*** + +## Usage + +### Input Formats +Given the nature of the training data, the Phi-mini-MoE model is best suited for prompts using the chat format as follows: + +``` +<|system|> +You are a helpful assistant.<|end|> +<|user|> +How to explain Internet for a medieval knight?<|end|> +<|assistant|> +``` + +### Loading the model locally +After obtaining the Phi-mini-MoE model checkpoints, users can use this sample code for inference. + +```python +import torch +from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline +torch.random.manual_seed(0) +model = AutoModelForCausalLM.from_pretrained( + "microsoft/Phi-mini-MoE-instruct", + device_map="cuda", + torch_dtype="auto", + trust_remote_code=True, +) +tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-mini-MoE-instruct") +messages = [ + {"role": "system", "content": "You are a helpful AI assistant."}, + {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"}, + {"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."}, + {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"}, +] +pipe = pipeline( + "text-generation", + model=model, + tokenizer=tokenizer, +) +generation_args = { + "max_new_tokens": 500, + "return_full_text": False, + "temperature": 0.0, + "do_sample": False, +} +output = pipe(messages, **generation_args) +print(output[0]['generated_text']) +``` + +## Benchmarks + +To understand the capabilities, we compare Phi-mini-MoE with a set of models over a variety of benchmarks using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness). Detailed evaluation settings can be found in the SlimMoE paper. + +| Model | # Total param | # Act. param | MMLU | MMLU pro | BBH | Arc-C (chat) | Human-eval | GSM8K | MT-bench | +|----------------------|---------------|--------------|-------|----------|-------|---------------|-------------|--------|----------| +| **MoE Models** ||||||||||| +| Phi-3.5-MoE | 42B | 6.6B | 78.36 | 59.38 | 63.93 | 91.38 | 81.70 | 87.87 | 8.34 | +| Qwen 1.5 MoE | 14B | 2.7B | 60.73 | 26.49 | 42.65 | 67.24 | 46.30 | 53.07 | 6.55 | +| DeepSeek V2 Lite | 16B | 2.4B | 56.69 | 17.89 | 36.30 | 61.09 | 54.40 | 63.23 | 6.82 | +| OL-MoE | 7B | 1.3B | 54.27 | 20.87 | 38.00 | 55.63 | 37.80 | 71.49 | 6.60 | +| Granite 3.0 MoE | 3.4B | 0.8B | 50.06 | 4.82 | 39.65 | 56.06 | 51.80 | 60.12 | 6.91 | +| **Dense Models** ||||||||||| +| LLaMA 3.1 8B | 8B | 8B | 68.71 | 45.28 | 50.86 | 82.42 | 69.50 | 84.84 | 8.03 | +| Qwen 2.5 7B | 7.6B | 7.6B | 73.47 | 56.24 | 53.74 | 88.82 | 81.70 | 84.84 | 8.34 | +| Phi 3 small | 7.4B | 7.4B | 75.35 | 52.06 | 62.07 | 84.30 | 70.10 | 84.84 | 8.03 | +| Gemma 3 4B | 4B | 4B | 59.49 | 40.13 | 49.45 | 75.85 | 67.10 | 78.92 | 8.28 | +| Phi 3 mini | 3.8B | 3.8B | 69.94 | 45.65 | 54.94 | 85.58 | 72.60 | 84.61 | 7.46 | +| LLaMA 3.2 3B | 3.2B | 3.2B | 61.73 | 36.70 | 45.46 | 75.77 | 52.40 | 77.41 | 7.46 | +| Qwen 2.5 3B | 3B | 3B | 65.06 | 41.00 | 46.61 | 80.20 | 73.80 | 76.57 | 7.60 | +| Gemma 3 1B | 1B | 1B | 40.80 | 14.70 | 34.80 | 37.46 | 41.50 | 41.77 | 6.67 | +| LLaMA 3.2 1B | 1B | 1B | 46.30 | 18.67 | 35.18 | 49.91 | 35.40 | 44.96 | 5.23 | +| **SlimMoE Models** ||||||||||| +| Phi-mini-MoE | 7.6B | 2.4B | 70.68 | 49.68 | 55.27 | 84.91 | 73.80 | 84.89 | 7.59 | +| Phi-tiny-MoE | 3.8B | 1.1B | 60.83 | 36.34 | 45.58 | 76.37 | 58.50 | 78.47 | 7.05 | + + +## Training + +### Model + +**Architecture:** Phi-mini-MoE has 7.6B total parameters with **2.4B active parameters**. The model is a mixture-of-expert decoder-only Transformer model using the tokenizer with vocabulary size of 32,064.
+**Inputs:** Text. It is best suited for prompts using chat format.
+**Context length:** 4k tokens
+**GPUs:** 64 A100-80G
+**Training time:** 11 days
+**Training data:** 400B tokens
+**Outputs:** Generated text in response to the input
+**Dates:** Trained between September 2024 and March 2025
+**Status:** This is a static model trained on an offline dataset with cutoff date October 2023 for publicly available data.
+ +### Training Datasets +Our training data is a subset with 400B tokens of Phi-3 datasets, which includes a wide variety of sources and is a combination of +1) publicly available documents filtered rigorously for quality, selected high-quality educational data, and code; +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.); +3) high quality chat format supervised data covering various topics to reflect human preferences on different aspects such as instruct-following, truthfulness, honesty and helpfulness. + +More details about data can be found in the [Phi-3 Technical Report](https://arxiv.org/pdf/2404.14219). + +## Responsible AI Considerations + +Like other language models, Phi-mini-MoE can potentially behave in ways that are unfair, unreliable, or offensive. Some of the limiting behaviors to be aware of include: +* Quality of Service: The models are trained primarily on English text and some additional multilingual text. Languages other than English will experience worse performance as well as performance disparities across non-English. English language varieties with less representation in the training data might experience worse performance than standard American English. +* 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, cultural contexts, or prevalence of examples of negative stereotypes in training data that reflect real-world patterns and societal biases. +* 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. +* Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated. +* Limited Scope for Code: Majority of Phi-3 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. +* The High ECI: The model has an elevated defect rate when responding to election-critical queries, which may result in incorrect or unauthoritative election critical information being presented. Users should verify information related to elections with the election authority in their region. +* Long Conversation: Phi-3 models, like other models, can in some cases generate responses that are repetitive, unhelpful, or inconsistent in very long chat sessions in both English and non-English languages. Developers are encouraged to place appropriate mitigations, like limiting conversation turns to account for the possible conversational drift + +Developers should apply responsible AI best practices, including mapping, measuring, and mitigating risks associated with their specific use case and cultural, linguistic context. Important areas for consideration include: +* 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. +* High-Risk Scenarios: Developers should assess the 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. +* 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). +* Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case. +* 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. + +## Software +* [PyTorch](https://github.com/pytorch/pytorch) +* [Transformers](https://github.com/huggingface/transformers) +* [Flash-Attention](https://github.com/HazyResearch/flash-attention) + +## Hardware +Note that by default, the Phi-mini-MoE model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types: +* NVIDIA A100 +* NVIDIA A6000 +* NVIDIA H100 + +## License +The model is licensed under the [MIT license](./LICENSE). + +## Trademarks +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. \ No newline at end of file