Microsoft/Mixture of Experts

Phi-3.5 MoE 42B

chatcodingreasoningThinking
41.9B
Parameters (6.6B active)
128K
Context length
8
Benchmarks
4
Quantizations
200K
HF downloads
Architecture
MoE
Released
2024-08-20
Layers
32
KV Heads
8
Head Dim
128
Family
phi

Model Summary

Phi-3.5-MoE is a lightweight, state-of-the-art open model built upon datasets used for Phi-3 - synthetic data and filtered publicly available documents - with a focus on very high-quality, reasoning dense data. The model supports multilingual and comes with 128K context length (in tokens). The model underwent a rigorous enhancement process, incorporating supervised fine-tuning, proximal policy optimization, and direct preference optimization to ensure precise instruction adherence and robust safety measures.

šŸ” Phi-3 Portal

šŸ“° Phi-3 Microsoft Blog

šŸ“– Phi-3 Technical Report

šŸ‘©ā€šŸ³ Phi-3 Cookbook

šŸ–„ļø Try It

MoE references: šŸ“œPhi-3.5-MoE Blog | 😁GRIN MoE

Phi-3.5: [mini-instruct]; [MoE-instruct] ; [vision-instruct]

Intended Uses

Primary Use Cases

The model is intended for commercial and research use in multiple languages. The model provides uses for general purpose AI systems and applications which require:

  1. Memory/compute constrained environments
  2. Latency bound scenarios
  3. Strong reasoning (especially code, math and logic)

Our model is designed to accelerate research on language and multimodal models, for use as a building block for generative AI powered features.

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

Requirements

Phi-3.5-MoE-instruct is integrated in the official version of transformers starting from 4.46.0. The current transformers version can be verified with: pip list | grep transformers.

Examples of required packages:

flash_attn==2.5.8
torch==2.3.1
accelerate==0.31.0
transformers==4.46.0

Phi-3.5-MoE-instruct is also available in Azure AI Studio

Tokenizer

Phi-3.5-MoE-Instruct supports a vocabulary size of up to 32064 tokens. The tokenizer files already provide placeholder tokens that can be used for downstream fine-tuning, but they can also be extended up to the model's vocabulary size.

Input Formats

Given the nature of the training data, the Phi-3.5-MoE-instruct 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-3.5-MoE-instruct model checkpoints, users can use this sample code for inference.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline 

torch.random.manual_seed(0) 

model = AutoModelForCausalLM.from_pretrained( 
    "microsoft/Phi-3.5-MoE-instruct",  
    device_map="cuda",  
    torch_dtype="auto",  
    trust_remote_code=False,  
) 

tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-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-3.5-MoE with a set of models over a variety of benchmarks using our internal benchmark platform. At the high-level overview of the model quality on representative benchmarks:

CategoryBenchmarkPhi-3.5-MoE-instructMistral-Nemo-12B-instruct-2407Llama-3.1-8B-instructGemma-2-9b-ItGemini-1.5-FlashGPT-4o-mini-2024-07-18 (Chat)
Popular aggregated benchmarkArena Hard37.939.425.742.055.275.0
BigBench Hard CoT (0-shot)79.160.263.463.566.780.4
MMLU (5-shot)78.967.268.171.378.777.2
MMLU-Pro (0-shot, CoT)54.340.744.050.157.262.8
ReasoningARC Challenge (10-shot)91.084.883.189.892.893.5
BoolQ (2-shot)84.682.582.885.785.888.7
GPQA (0-shot, CoT)36.828.626.329.237.541.1
HellaSwag (5-shot)83.876.773.580.967.587.1
OpenBookQA (10-shot)89.684.484.889.689.090.0
PIQA (5-shot)88.683.581.283.787.588.7
Social IQA (5-shot)78.075.371.874.777.882.9
TruthfulQA (MC2) (10-shot)77.568.169.276.676.678.2
WinoGrande (5-shot)81.370.464.774.074.776.9
MultilingualMultilingual MMLU (5-shot)69.958.956.263.877.272.9
MGSM (0-shot CoT)58.763.356.775.175.881.7
MathGSM8K (8-shot, CoT)88.784.282.484.982.491.3
MATH (0-shot, CoT)59.531.247.650.938.070.2
Long contextQasper40.030.737.213.943.539.8
SQuALITY24.125.826.20.023.523.8
Code GenerationHumanEval (0-shot)70.763.466.561.074.486.6
MBPP (3-shot)80.868.169.469.377.584.1
Average69.261.361.063.368.574.9

We take a closer look at different categories across 80 public benchmark datasets at the table below:

CategoryPhi-3.5-MoE-instructMistral-Nemo-12B-instruct-2407Llama-3.1-8B-instructGemma-2-9b-ItGemini-1.5-FlashGPT-4o-mini-2024-07-18 (Chat)
Popular aggregated benchmark62.651.950.356.764.573.9
Reasoning78.772.270.575.477.780.0
Language understanding71.867.062.972.866.676.8
Robustness75.665.259.864.768.977.5
Long context25.524.525.50.027.025.4
Math74.157.765.067.960.280.8
Code generation68.356.965.858.366.869.9
Multilingual65.855.347.559.664.376.6

...

Quantizations & VRAM

Q4_K_M4.5 bpw
25.0 GB
VRAM required
94%
Quality
Q6_K6.5 bpw
35.5 GB
VRAM required
97%
Quality
Q8_08 bpw
43.4 GB
VRAM required
100%
Quality
FP1616 bpw
85.3 GB
VRAM required
100%
Quality

Benchmarks (8)

IFEval79.0
HumanEval77.0
BBH72.0
MATH66.0
MMLU-PRO60.8
GPQA43.0
BigCodeBench38.2
MUSR17.3

GPUs that can run this model

At Q4_K_M quantization. Sorted by minimum VRAM.

AMD Radeon PRO V710
28 GB VRAM • 504 GB/s
AMD
NVIDIA RTX 5090
32 GB VRAM • 1792 GB/s
NVIDIA
$1999
Apple M1 Max (32GB)
32 GB VRAM • 400 GB/s
APPLE
$1499
Apple M2 Max (32GB)
32 GB VRAM • 400 GB/s
APPLE
$1799
NVIDIA V100 SXM2 32GB
32 GB VRAM • 900 GB/s
NVIDIA
$3500
Apple M2 Pro (32GB)
32 GB VRAM • 200 GB/s
APPLE
$1499
NVIDIA Tesla V100 DGXS 32 GB
32 GB VRAM • 897 GB/s
NVIDIA
NVIDIA Tesla V100 PCIe 32 GB
32 GB VRAM • 897 GB/s
NVIDIA
NVIDIA Tesla V100 SXM2 32 GB
32 GB VRAM • 898 GB/s
NVIDIA
NVIDIA Tesla V100 SXM3 32 GB
32 GB VRAM • 981 GB/s
NVIDIA
AMD Radeon Instinct MI60
32 GB VRAM • 1020 GB/s
AMD
NVIDIA Tesla V100S PCIe 32 GB
32 GB VRAM • 1130 GB/s
NVIDIA
AMD Radeon Instinct MI100
32 GB VRAM • 1230 GB/s
AMD
NVIDIA RTX 5000 Ada Generation
32 GB VRAM • 576 GB/s
NVIDIA
NVIDIA GeForce RTX 5090
32 GB VRAM • 1790 GB/s
NVIDIA
$1999
NVIDIA GeForce RTX 5090 D
32 GB VRAM • 1790 GB/s
NVIDIA
$1999
NVIDIA Jetson AGX Xavier 32 GB
32 GB VRAM • 136 GB/s
NVIDIA
NVIDIA Quadro GV100
32 GB VRAM • 868 GB/s
NVIDIA
NVIDIA TITAN V CEO Edition
32 GB VRAM • 868 GB/s
NVIDIA
NVIDIA Tesla PG500-216
32 GB VRAM • 1130 GB/s
NVIDIA
NVIDIA Tesla PG503-216
32 GB VRAM • 1130 GB/s
NVIDIA
AMD Radeon Pro Vega II
32 GB VRAM • 825 GB/s
AMD
AMD Radeon Pro Vega II Duo
32 GB VRAM • 1020 GB/s
AMD
AMD Radeon PRO V620
32 GB VRAM • 512 GB/s
AMD
AMD Radeon PRO W6800
32 GB VRAM • 512 GB/s
AMD
AMD Radeon Pro W6800X
32 GB VRAM • 512 GB/s
AMD
AMD Radeon Pro W6800X Duo
32 GB VRAM • 512 GB/s
AMD
AMD Radeon Pro W6900X
32 GB VRAM • 512 GB/s
AMD
NVIDIA Jetson AGX Orin 32 GB
32 GB VRAM • 205 GB/s
NVIDIA
AMD Radeon PRO W7800
32 GB VRAM • 576 GB/s
AMD

Find the best GPU for Phi-3.5 MoE 42B

Build Hardware for Phi-3.5 MoE 42B