ApX logoApX logo
CalculatorCoursesPricing

Phi-2

Open Source
Open Weights

Parameters

2.7B

Context Length

2K

Modality

Text

Architecture

Dense

KV Cache Rate

256 KB/tok

License

MIT License

Release Date

12 Oct 2023

Knowledge Cutoff

-

API Pricing (per 1M)

Self-hosted only

Hardware & System Requirements

Precision

Context

Workload Memory: 4.26 GB

vLLM

INT4 · 2048 context · 1 user

Base Weights: 1.26 GB

KV Cache: 0.50 GB

Runtime & Graphs: 2.50 GB

Minimum Required Hardware

1x NVIDIA L4 24GB

vLLM

4.3 / 21.6 GB

1x RTX 3060 12GB

llama.cpp

4.3 / 11.2 GB

Apple M4 24GB

llama.cpp

4.3 / 18.0 GB

Determine requirements for your specific workload:

Runtime requirements

Checkpoint format

FP16

CUDA

>= 11.8

PyTorch

>= 2.1

Transformers

>= 4.37.0

ArchitecturePrecisionAttention kernel

Blackwell, Hopper

Native FP16

FlashAttention-3

Ada Lovelace, Ampere

Native FP16

FlashAttention-2

Architecture Diagram

Input TokensToken EmbeddingPosition: RoPEHidden: 2k · Context: 2K · Vocab: 51.2kx 32 layersLayerNormPre-AttentionMulti-Head Attention32Q / 32KV headsHead dim: 64+LayerNormPre-FFNFeed-Forward NetworkGELUIntermediate: 10.2k+Final LayerNormOutput Logits

Evaluation Benchmarks

No evaluation benchmarks for Phi-2 available.

Rankings

Overall Rank

-

Coding Rank

-

About Phi-2

Phi-2 is Microsoft's 2.7B parameter small language model engineered for advanced reasoning, mathematical logic, and code generation. Trained on 1.4T textbook-quality tokens, it delivers benchmark performance rivaling significantly larger models.

Specifications

Attention

Attention Structure

Multi-Head Attention

Attention Heads

32

Key-Value Heads

32

Position Embedding

ROPE

RoPE Theta

10,000

Normalization

Layer Normalization

Activation Function

GELU

Dimensions

Base Precision

FP16

Hidden Dimension Size

2,048

Number of Layers

32

FFN Intermediate Size (Dense)

10,240

Tokenizer

Vocabulary Size

51,200

About Phi-2

Microsoft's Phi-2 is a 2.7 billion parameter Transformer-based model, developed for efficient language understanding and reasoning. Its technical innovations include training on "textbook-quality" synthetic and filtered web data, alongside scaled knowledge transfer from its predecessor, Phi-1.5, facilitating emergent capabilities within a compact architecture.


Other Phi-2 Models
  • No related models available