Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone

  • Problem Small language models lag behind large ones when trained on ordinary data, yet a phone-sized model needs to stay close to models such as Mixtral 8x7B and GPT-3.5.
  • Method Trains phi-3-mini on 3.3T tokens of heavily filtered web data and LLM-generated synthetic data in two phases, then applies SFT and DPO, and extends the family to phi-3-small, phi-3-medium, phi-3.5-MoE and phi-3.5-Vision.

Figure 1: Toy illustration of the blocksparse attention in phi-3-small with 2 local blocks and vertical stride of 3.
The table shows the Keys/values a query to…

Figure 1 : Toy illustration of the blocksparse attention in phi-3-small with 2 local blocks and vertical stride of 3. The table shows the Keys/values a query token in block 8 attended to. Blue=local blocks, orange=remote/vertical blocks, gray=blocks skipped.

Original paper · CC BY 4.0 · Extracted the figure area from page 3 of the original PDF.

Why data quality is the lever

Scaling laws treat the data source as fixed, so the gains they predict come from adding parameters and training tokens. The phi series argues that this assumption weakens once frontier LLMs can filter web pages and write training text themselves. Earlier phi models combined LLM-based filtering of public web data with LLM-created synthetic data, and phi-2 at 2.7B parameters was reported to match models about 25 times its size trained on regular data.

The practical target is a model that fits on a phone while staying on par, by the authors' reading, with models such as Mixtral 8x7B and GPT-3.5.

phi-3-mini structure and on-device footprint

phi-3-mini is a transformer decoder with a default 4K context, and a LongRope variant called phi-3-mini-128K extends the context to 128K. Its block layout mirrors Llama-2 and it uses a 32064-token vocabulary, so packages built for the Llama-2 family can be adapted to it directly. The model has 3072 hidden dimensions, 32 heads and 32 layers, and it was trained in bfloat16 for 3.3T tokens.

Its vocabulary drops the BoS token and adds a few tokens for the chat template.

The released checkpoint is already chat-finetuned and expects a fixed prompt template. After 4-bit quantization the model occupies about 1.8GB, and it ran natively and fully offline on an iPhone 14 with an A16 Bionic chip at more than 12 tokens per second. Figure 2 shows that phone run.

Two-phase pre-training corpus

The corpus combines heavily filtered public web data, filtered by educational level, with synthetic text generated by LLMs. Pre-training runs in two disjoint, sequential phases. Phase-1 is mostly web data meant to teach general knowledge and language understanding. Phase-2 draws on a narrower and more aggressively filtered subset of that web data and adds synthetic data aimed at logical reasoning and niche skills.

The filtering choice follows a data regime rather than a compute or over-training regime: the focus is on data quality for a fixed scale. Web pages are kept to match a target level of knowledge and to favour pages that could improve reasoning, while items such as a day's sports results are removed so that a small model keeps capacity for reasoning.

The authors use the term data optimal regime as an aspirational target and do not claim that they found a provably optimal mixture for a given scale. Figure 3 plots the log of MMLU error against the log of model size for phi-1.5, phi-2, phi-3-mini and phi-3-small, beside Llama-2 models of 7B to 70B trained on the same fixed data.

To test the recipe at larger scale, phi-3-medium uses the phi-3-mini tokenizer and architecture, trains on the same data mixture for 4.8T tokens in total, and has 40 heads, 40 layers and an embedding dimension of 5120. Some benchmarks gain much less from 7B to 14B than from 3.8B to 7B, which the authors read as a sign that the data mixture may need more work for a 14B model.

Architectural changes in phi-3-small and phi-3.5-MoE

phi-3-small has 7B parameters, a tiktoken-based vocabulary of 100352 and a default context of 8192. Its standard decoder has 32 heads, 32 layers and a hidden size of 4096, and it switches the activation to GEGLU. Hyperparameters were tuned on a small proxy model with Maximal Update Parametrization (muP) and then transferred to the 7B target, which helped performance and training stability.

Grouped-query attention lets four query heads share one key head.

The blocksparse attention module is aimed at KV cache cost and inference speed. Each attention head gets its own sparsity pattern over the KV cache, so each token is attended on some heads, and the context is split among heads. Figure 1 illustrates this with 2 local blocks and a vertical stride of 3. Training uses a Triton kernel built on Flash Attention, and inference uses a prefill kernel together with an extended paged attention kernel from vLLM for decoding.

phi-3-small alternates dense and blocksparse attention layers to save KV cache while keeping long-context retrieval, and it adds 10% multilingual data.

phi-3.5-MoE uses MoE layers as its feedforward blocks, with top-2 routing over 16 expert networks, each a separate GLU network. The sparse router is trained with the SparseMixer approach. phi-3.5-MoE uses the same tokenizer as phi-3-medium and phi-3-mini, with a vocabulary size of 32064.

Academic benchmark results for phi-3

The comparison covers phi-2, Mistral-7b-v0.1, Mixtral-8x7b, Gemma 7B, Llama-3-instruct-8b and GPT-3.5. All numbers come from one internal pipeline with few-shot prompts at temperature 0, so they can differ from published numbers. The authors also observed that adding ## before the Question raised phi-3-mini's scores on many benchmarks, but they did not change the prompts for the reported numbers.

On MMLU (5-shot), phi-3-mini scores 68.8, phi-3-small 75.7 and phi-3-medium 78.0, against 70.5 for Mixtral 8x7b and 71.4 for GPT-3.5 (version 1106).

The widest gap among the listed items is on TriviaQA, where phi-3-mini scores 64.0 and GPT-3.5 scores 85.8.

Post-training and safety evaluation

Direct preference optimization uses chat, reasoning and responsible AI data, and the outputs the model should avoid are used as rejected responses.

Safety data for phi-3-mini combined helpfulness and harmlessness preference datasets, modified following a prior work, with in-house datasets for the RAI harm categories. An independent Microsoft red team probed the model iteratively, and the authors added datasets aimed at the weaknesses it found. Figure 5 compares harmful response percentages before and after safety alignment; the authors note these percentages are inflated because the red team used adversarial multi-turn prompts.

phi-3-small, phi-3-medium and phi-3.5-MoE went through the same red-teaming process with identical datasets and a slightly larger number of samples. Table 4 scores these models with GPT-4 simulated multi-turn conversations across five categories. On ungroundedness, phi-3-mini scores 0.603 and phi-2 scores 1.481, and lower is better for these metrics.

On Third Party Harm (DR-1), phi-3-mini scores 0.240 against 0.562 for Mistral 7b.

Multilingual and long-context results

Context grows from 4K to 128K through LongRope and a mixed context window approach, and the authors state that performance on 4K-context tasks is kept.

Figure 4 compares the three models on these multilingual tasks.

On RepoQA, phi-3.5-MoE averages 85 across Python, C++, Rust, Java and TypeScript. That is above Llama-3.1-8B-Instruct at 71 and Mixtral-8x7B-Instruct-v0.1 at 68, and below gpt-4O-2024-05-13 at 90.6 and gemini-1.5-flash-latest at 90. phi-3.5-Mini averages 77 on the same table.

On RULER, phi-3.5-MoE scores 94.8 at 4k and 64.2 at 128k. phi-3.5-Mini goes from 94.3 at 4k to 63.6 at 128k, while Llama-3.1-8B-Instruct scores 77.0 at 128k.

The authors say the MoE reaches above 90% of the average performance of GPT-4o-mini and is comparable to Gemini-1.5 Flash, while phi-3.5-mini is comparable to Mistral-Nemo-12B and Llama-3.1-8B.

Phi-3.5-Vision architecture and training

Phi-3.5-Vision has 4.2B parameters and pairs a CLIP ViT-L/14 image encoder with the phi-3.5-mini transformer decoder. Visual tokens are interleaved with text tokens in no fixed order, and multi-image inputs simply concatenate the tokens of each image. A dynamic cropping strategy splits a high-resolution image into a 2d array of blocks and concatenates the tokens of the blocks to represent the whole image.

Next-token loss is applied only to text tokens, so image tokens contribute no loss in this phase. During pre-training the maximum image resolution is 1344×1344.

Post-training uses SFT and DPO, with a text SFT set, public multimodal instruction datasets and large in-house multimodal sets; the multimodal SFT data totals about 33B tokens. DPO mainly uses a text dataset and a smaller multimodal dataset, and both stages train multimodal and text-only tasks jointly to keep language ability.

Single-image and multi-image benchmark results

The single-image evaluation covers nine benchmarks grouped as Science, Charts and Generic knowledge, against MM1-3B-Chat, MM1-7B-Chat, Llava-1.6 variants, Qwen-VL-Chat, Claude 3 Haiku, Gemini 1.0 Pro V and GPT-4O. MM1-3B-Chat numbers were copied from published results because that model is not publicly available.

The setup follows the Llava-1.5 evaluation setting: 0-shot, a single letter or short phrase as the answer, images placed first in the prompt except on MMMU, and no image scaling or preprocessing.

On MMMU (val), Phi-3.5-Vision scores 43.0 against 61.8 for GPT-4O, and on MathVista (testmini) it scores 43.9 against 54.4. On ScienceQA (test), Phi-3.5-Vision scores 91.3, above the 88.5 of GPT-4O in the same table.

Figure 7 is a demo case of natural image understanding and reasoning.

The multi-image evaluation uses BLINK (val) and VideoMME (test) against Llava Interleave-Qwen 7B, InternVL2 4B and 8B, Gemini 1.5 Flash, GPT-4o-mini, Claude 3.5 Sonnet, Gemini 1.5 Pro and GPT-4O. For BLINK the model selects its answer directly from the choices instead of using ChatGPT for answer selection, and for VideoMME 16 frames are passed to every model.

Phi-3.5-Vision scores 57.0 on BLINK against 63.2 for GPT-4O and 61.0 for Gemini 1.5 Pro. On VideoMME it scores 50.8, while Gemini 1.5 Flash scores 62.3 and GPT-4O scores 68.4, so the model does not lead on this video benchmark.

Safety of the multimodal model

Safety post-training was applied in both the SFT and DPO stages, using text RAI datasets and in-house multimodal RAI datasets. Table 7 covers one internal benchmark and two public ones, RTVLM and VLGuard.

Phi-3.5-Vision scores 8.16 on the internal benchmark with safety post-training and 7.06 without it, 5.44 against 3.56 on RTVLM, and 9.10 against 4.66 on VLGuard. The same table lists GPT4-V at 8.55, 6.81 and 8.90 on those three benchmarks. The authors state that safety post-training notably enhances RAI performance across these benchmarks and break the results down by RAI category.

Limitations

phi-3-mini cannot store much factual knowledge, which the authors link to its low TriviaQA score of 64.0. The authors suggest that search augmentation can address this and show one Chat-UI example, which is an illustration rather than a systematic test. Figure 6 compares phi-3-mini's completion without and with web search for the same question.

The model was mostly restricted to English, and multilingual work on small language models is named as the next step, with early results on phi-3-small. Factual inaccuracies, hallucinations, bias and unsafe content remain, and the authors state that downstream use should be evaluated for each use case.

The 128K RULER drop for phi-3.5-MoE and phi-3.5-Mini is still open in this version.

Phi-3.5-Vision sometimes produces ungrounded outputs and has limits on questions that need high-level reasoning, which the authors say could make it unreliable in sensitive areas such as finance. The authors plan to add more reasoning-focused and hallucination-related DPO data in later post-training.

Paper info

Authors
Marah Abdin, Jyoti Aneja, Hany Awadalla, Ahmed Awadallah, Ammar Ahmad Awan, Nguyen Bach, Amit Bahree, Arash Bakhtiari, Jianmin Bao, Harkirat Behl, Alon Benhaim, Misha Bilenko, Johan Bjorck, Sébastien Bubeck, Martin Cai, Qin Cai, Vishrav Chaudhary, Dong Chen, Dongdong Chen, Weizhu Chen, Yen-Chun Chen, Yi-Ling Chen, Hao Cheng, Parul Chopra, Xiyang Dai, Matthew Dixon, Ronen Eldan, Victor Fragoso, Jianfeng Gao, Mei Gao, Min Gao, Amit Garg, Allie Del Giorno, Abhishek Goswami, Suriya Gunasekar, Emman Haider, Junheng Hao, Russell J. Hewett, Wenxiang Hu, Jamie Huynh, Dan Iter, Sam Ade Jacobs, Mojan Javaheripi, Xin Jin, Nikos Karampatziakis, Piero Kauffmann, Mahoud Khademi, Dongwoo Kim, Young Jin Kim, Lev Kurilenko, James R. Lee, Yin Tat Lee, Yuanzhi Li, Yunsheng Li, Chen Liang, Lars Liden, Xihui Lin, Zeqi Lin, Ce Liu, Liyuan Liu, Mengchen Liu, Weishung Liu, Xiaodong Liu, Chong Luo, Piyush Madan, Ali Mahmoudzadeh, David Majercak, Matt Mazzola, Caio César Teodoro Mendes, Arindam Mitra, Hardik Modi, Anh Nguyen, Brandon Norick, Barun Patra, Daniel Perez-Becker, Thomas Portet, Reid Pryzant, Heyang Qin, Marko Radmilac, Liliang Ren, Gustavo de Rosa, Corby Rosset, Sambudha Roy, Olatunji Ruwase, Olli Saarikivi, Amin Saied, Adil Salim, Michael Santacroce, Shital Shah, Ning Shang, Hiteshi Sharma, Yelong Shen, Swadheen Shukla, Xia Song, Masahiro Tanaka, Andrea Tupini, Praneetha Vaddamanu, Chunyu Wang, Guanhua Wang, Lijuan Wang, Shuohang Wang, Xin Wang, Yu Wang, Rachel Ward, Wen Wen, Philipp Witte, Haiping Wu, Xiaoxia Wu, Michael Wyatt, Bin Xiao, Can Xu, Jiahang Xu, Weijian Xu, Jilong Xue, Sonali Yadav, Fan Yang, Jianwei Yang, Yifan Yang, Ziyi Yang, Donghan Yu, Lu Yuan, Chenruidong Zhang, Cyril Zhang, Jianwen Zhang, Li Lyna Zhang, Yi Zhang, Yue Zhang, Yunan Zhang, Xiren Zhou
Venue
arXiv · Preprint
First published
2024-4-22
Added
2026-10-20
Updated
2024-8-30
Version
v4
arXiv
2404.14219
Category
cs.CL · cs.AI
Original paper terms
CC BY 4.0
What we show
Paper info, commentary and permitted figures from the original paper

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Abstract

We introduce phi-3-mini, a 3.8 billion parameter language model trained on 3.3 trillion tokens, whose overall performance, as measured by both academic benchmarks and internal testing, rivals that of models such as Mixtral 8x7B and GPT-3.5 (e.g., phi-3-mini achieves 69% on MMLU and 8.38 on MT-bench), despite being small enough to be deployed on a phone. Our training dataset is a scaled-up version of the one used for phi-2, composed of heavily filtered publicly available web data and synthetic data. The model is also further aligned for robustness, safety, and chat format. We also provide parameter-scaling results with a 7B, 14B models trained for 4.8T tokens, called phi-3-small, phi-3-medium, both significantly more capable than phi-3-mini (e.g., respectively 75%, 78% on MMLU, and 8.7, 8.9 on MT-bench). To enhance multilingual, multimodal, and long-context capabilities, we introduce three models in the phi-3.5 series: phi-3.5-mini, phi-3.5-MoE, and phi-3.5-Vision. The phi-3.5-MoE, a 16 x 3.8B MoE model with 6.6 billion active parameters, achieves superior performance in language reasoning, math, and code tasks compared to other open-source models of similar scale, such as Llama 3.1 and the Mixtral series, and on par with Gemini-1.5-Flash and GPT-4o-mini. Meanwhile, phi-3.5-Vision, a 4.2 billion parameter model derived from phi-3.5-mini, excels in reasoning tasks and is adept at handling both single-image and text prompts, as well as multi-image and text prompts.

Quote from the paper

Marah Abdin, Jyoti Aneja, Hany Awadalla, Ahmed Awadallah, Ammar Ahmad Awan, Nguyen Bach, Amit Bahree, Arash Bakhtiari, Jianmin Bao, Harkirat Behl, Alon Benhaim, Misha Bilenko, Johan Bjorck, Sébastien Bubeck, Martin Cai, Qin Cai, Vishrav Chaudhary, Dong Chen, Dongdong Chen, Weizhu Chen et al. (2024). Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone. arXiv:2404.14219v4. https://arxiv.org/abs/2404.14219v4

BibTeX
@misc{abdin2024technical,
  title = {{Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone}},
  author = {Marah Abdin and Jyoti Aneja and Hany Awadalla and Ahmed Awadallah and Ammar Ahmad Awan and Nguyen Bach and Amit Bahree and Arash Bakhtiari and Jianmin Bao and Harkirat Behl and Alon Benhaim and Misha Bilenko and Johan Bjorck and Sébastien Bubeck and Martin Cai and Qin Cai and Vishrav Chaudhary and Dong Chen and Dongdong Chen and Weizhu Chen and Yen-Chun Chen and Yi-Ling Chen and Hao Cheng and Parul Chopra and Xiyang Dai and Matthew Dixon and Ronen Eldan and Victor Fragoso and Jianfeng Gao and Mei Gao and Min Gao and Amit Garg and Allie Del Giorno and Abhishek Goswami and Suriya Gunasekar and Emman Haider and Junheng Hao and Russell J. Hewett and Wenxiang Hu and Jamie Huynh and Dan Iter and Sam Ade Jacobs and Mojan Javaheripi and Xin Jin and Nikos Karampatziakis and Piero Kauffmann and Mahoud Khademi and Dongwoo Kim and Young Jin Kim and Lev Kurilenko and James R. Lee and Yin Tat Lee and Yuanzhi Li and Yunsheng Li and Chen Liang and Lars Liden and Xihui Lin and Zeqi Lin and Ce Liu and Liyuan Liu and Mengchen Liu and Weishung Liu and Xiaodong Liu and Chong Luo and Piyush Madan and Ali Mahmoudzadeh and David Majercak and Matt Mazzola and Caio César Teodoro Mendes and Arindam Mitra and Hardik Modi and Anh Nguyen and Brandon Norick and Barun Patra and Daniel Perez-Becker and Thomas Portet and Reid Pryzant and Heyang Qin and Marko Radmilac and Liliang Ren and Gustavo de Rosa and Corby Rosset and Sambudha Roy and Olatunji Ruwase and Olli Saarikivi and Amin Saied and Adil Salim and Michael Santacroce and Shital Shah and Ning Shang and Hiteshi Sharma and Yelong Shen and Swadheen Shukla and Xia Song and Masahiro Tanaka and Andrea Tupini and Praneetha Vaddamanu and Chunyu Wang and Guanhua Wang and Lijuan Wang and Shuohang Wang and Xin Wang and Yu Wang and Rachel Ward and Wen Wen and Philipp Witte and Haiping Wu and Xiaoxia Wu and Michael Wyatt and Bin Xiao and Can Xu and Jiahang Xu and Weijian Xu and Jilong Xue and Sonali Yadav and Fan Yang and Jianwei Yang and Yifan Yang and Ziyi Yang and Donghan Yu and Lu Yuan and Chenruidong Zhang and Cyril Zhang and Jianwen Zhang and Li Lyna Zhang and Yi Zhang and Yue Zhang and Yunan Zhang and Xiren Zhou},
  year = {2024},
  eprint = {2404.14219},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.14219v4}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up