# TinyLlama

**TinyLlama** 是一个开放权重的11亿参数小型语言模型，复制了Meta的[Llama 2](https://www.edgepedia.org/zh/llama-2)的架构和分词器，由新加坡科技设计大学（Singapore University of Technology and Design，SUTD）的一个四人团队在最多3万亿公开数据token上进行预训练，训练于2023年9月1日开始<sup>[1](https://arxiv.org/abs/2401.02385)</sup><sup> • </sup><sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。团队成员包括副教授陆伟（Lu Wei）、研究助理张培源（Zhang Peiyuan），以及博士生曾广涛（Zeng Guangtao）和王天铎（Wang Tianduo），其公开目标是让较小的公司和实验室也能构建自己的模型，从而实现语言模型的民主化<sup>[3](https://www.sutd.edu.sg/media-releases-listing/sutd-launches-first-of-its-kind-mini-ai-model-with-three-trillion-token-punch/)</sup>。代码和权重均以[Apache License](https://www.edgepedia.org/zh/apache-license) 2.0发布<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。

| 关键事实 | 详情 |
|---|---|
| 规模与数据 | 11亿参数；v1.0在3万亿token上预训练（对约9500亿token的SlimPajama加Starcoderdata训练略超过3轮）<sup>[1](https://arxiv.org/abs/2401.02385)</sup><sup> • </sup><sup>[2](https://github.com/jzhang38/TinyLlama/)</sup> |
| 架构 | Llama 2设计：RoPE、SwiGLU、分组查询注意力，32个查询头、4个键值组、22层、2,048 token上下文、32,000 token词表<sup>[1](https://arxiv.org/abs/2401.02385)</sup> |
| 算力 | 据代码仓库为16块A100-40G GPU（论文则描述为16个节点、每节点四块GPU）；每GPU每秒24,000 token，模型FLOPs利用率56%<sup>[1](https://arxiv.org/abs/2401.02385)</sup><sup> • </sup><sup>[2](https://github.com/jzhang38/TinyLlama/)</sup> |
| 训练效率 | 每3000亿token消耗3,456 A100 GPU小时，而Pythia-1.0B为4,830小时、MPT-1.3B为7,920小时<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup> |
| 常识得分 | 七项基准平均52.99（v1.0）和53.63（v1.1），而OPT-1.3B为51.44、Pythia-1.4B为51.33<sup>[1](https://arxiv.org/abs/2401.02385)</sup> |
| 占用与速度 | 4比特权重占用637 MB；在16 GB的Mac M2上用llama.cpp达到每秒71.8 token；在A40上用vLLM、批大小100时达到每秒7,094.5 token<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup> |
| 许可证 | 代码和权重均为Apache License 2.0；仓库现已归档<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup> |

## 架构与训练

TinyLlama采用Llama 2的架构和分词器，因此与建立在Llama之上的庞大开源项目生态即插即用兼容<sup>[1](https://arxiv.org/abs/2401.02385)</sup><sup> • </sup><sup>[4](https://huggingface.co/TinyLlama/TinyLlama_v1.1)</sup>。三项Llama设计选择被继承下来。旋转位置嵌入（Rotary Positional Embedding，RoPE）将位置信息注入注意力，PaLM和Qwen也使用这一方法<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。SwiGLU取代了传统的ReLU激活<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。[分组查询注意力](https://www.edgepedia.org/zh/grouped-query-attention)使用32个查询头，仅由4组键值头服务，从而降低内存带宽开销并加速推理<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。完整规格为：隐藏维度2,048、SwiGLU中间维度5,632、2,048 token上下文长度、22层、32,000 token词表<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。

训练数据为[SlimPajama](https://www.edgepedia.org/zh/slimpajama)（排除其GitHub子集）加Starcoderdata，合计约9500亿token，自然语言与代码比例为7:3，训练略超过3轮，学习率4e-4，采用余弦调度并预热2,000步<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。效率来自开源系统工作：[FlashAttention](https://www.edgepedia.org/zh/flashattention)和Lit-GPT训练框架<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。代码库在每块A100-40G GPU上达到每秒24,000 token，在不使用激活检查点的情况下模型FLOPs利用率达56%；按此速率，一个Chinchilla最优的11亿参数模型（220亿token）在8块A100上训练32小时即可完成，预训练甚至可以在消费级RTX 3090/4090显卡上进行<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。

论文与代码仓库在集群规模上存在分歧。论文描述“一个由16个节点组成的集群，每个节点配备四块A100-40G GPU”，批大小约180万token<sup>[1](https://arxiv.org/abs/2401.02385)</sup>；而代码仓库称总共16块A100-40G GPU，批大小200万token<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。两个来源均未解决这一差异。

论文摘要称该模型“在约1万亿token上预训练最多3轮”，而代码仓库记录了一个最终3万亿token的检查点（第1431k步），于2023年12月28日发布，常识平均分为52.99<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>；项目和新加坡科技设计大学新闻稿通篇使用的是3万亿这一数字<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup><sup> • </sup><sup>[3](https://www.sutd.edu.sg/media-releases-listing/sutd-launches-first-of-its-kind-mini-ai-model-with-three-trillion-token-punch/)</sup>。

## 变体与衍生

**对话检查点。** 在预训练进行期间，团队发布了在openassistant-guanaco数据集上微调的对话版本：V0.1于2023年9月16日在5030亿token时发布，V0.3于10月1日在1万亿时发布，V0.4于11月4日在1.5万亿时发布<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。其七项基准平均分随预训练量上升，从49.57（v0.1）升至51.36（v0.3）和52.30（v0.4），[HellaSwag](https://www.edgepedia.org/zh/hellaswag)从53.81攀升至58.59<sup>[5](https://github.com/jzhang38/TinyLlama/blob/main/EVAL.md)</sup>。作者将微调后的大幅提升归因于两个因素：基座模型尚未经历学习率冷却，而微调实际上提供了这一过程；监督微调更好地激发了模型的内部知识<sup>[5](https://github.com/jzhang38/TinyLlama/blob/main/EVAL.md)</sup>。

**v1.1。** 在开放预训练阶段发现学习率调度器和数据加载的实现问题后，团队从零重新训练了一个新模型<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。TinyLlama v1.1将总预训练量从3万亿削减至2万亿token，但在下游任务上仍有小幅提升，并引入了三阶段配方：基础预训练、针对特定领域的持续预训练，以及冷却阶段<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。v1.1发布包含三个专用版本：通用标准模型、数学与代码能力增强的TinyLlama_v1.1_Math&Code，以及具备中文理解能力的TinyLlama_v1.1_Chinese<sup>[4](https://huggingface.co/TinyLlama/TinyLlama_v1.1)</sup>。中文变体在七项基准常识平均分上为53.41，标准v1.1为53.63，其BoolQ得分更高，为61.41对55.99<sup>[6](https://huggingface.co/TinyLlama/TinyLlama_v1.1_chinese)</sup>。

## 性能与对比

作者声称TinyLlama显著优于同等规模的现有开源模型，在各种下游任务上超过OPT-1.3B和Pythia-1.4B<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。在其七项任务常识平均分上，v1.0为52.99，v1.1为53.63，而OPT-1.3B为51.44、Pythia-1.4B为51.33、Pythia-1.0B为48.30；v1.1在HellaSwag上得分61.47，ARC-challenge上32.68，WinoGrande上59.43<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。

独立评估给出的图景更为复杂。2025年一项IEEE研究测得TinyLlama 1.1B在MMLU上为24.42%，远低于Qwen2 1.5B的51.44%和Phi-3 Mini 3.8B的67.16%（后者仅使用7.6 GB GPU内存）；一个分层多智能体系统将TinyLlama提升至35.55%<sup>[7](https://doi.org/10.1109/aibthings66987.2025.11296175)</sup>。专项评估发现TinyLlama在所有任务上大体不如Llama 2 7B，尽管速度显著更快（约每秒多32 token）且仅使用4 GB内存；对于至少6 GB显存的GPU，4比特量化的Llama 2 7B是更好的选择<sup>[8](https://kaitchup.substack.com/p/tinyllama-pre-training-a-small-llama)</sup>。因此，作者的优越性主张在同尺寸的2022年前后模型（OPT、Pythia）面前成立，但在更新的小型模型或更大的量化模型面前不成立。

在占用方面，一项独立比较显示，TinyLlama 1.1B在FP16下占用约2.2 GB显存，在A100上速度约为每秒1,300至1,600 token，对比之下，其他模型的数据为：Qwen 2.5 0.5B（约1.0 GB，每秒1,800至2,200 token）、StableLM 2 1.6B（约3.2 GB，每秒950至1,150 token）、Phi-2 2.7B（约5.4 GB，每秒650至850 token）<sup>[9](https://www.generalcompute.com/blog/the-1b-and-under-club-tinyllama-vs-phi-2-vs-stablelm-vs-qwen-0-5b)</sup>。

## 数字一览

- 11亿参数；22层；32个注意力头分4个键值组<sup>[1](https://arxiv.org/abs/2401.02385)</sup>
- v1.0预训练3万亿token（v1.1为2万亿）<sup>[1](https://arxiv.org/abs/2401.02385)</sup>
- 每3000亿token消耗3,456 A100 GPU小时，而Pythia-1.0B为4,830小时、MPT-1.3B为7,920小时<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>
- 4比特量化权重占用637 MB<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>
- 在16 GB的Mac M2上每秒71.8 token（llama.cpp，4比特，批大小1）<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>
- 在[Hugging Face](https://www.edgepedia.org/zh/hugging-face)超过46万个模型中排名第一的热门代码，从2024年1月3日起持续约一周<sup>[3](https://www.sutd.edu.sg/media-releases-listing/sutd-launches-first-of-its-kind-mini-ai-model-with-three-trillion-token-punch/)</sup>

## 许可与获取

GitHub仓库以Apache License 2.0许可；仓库现已归档，检索时拥有9,009颗星和633次复刻<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。模型检查点和代码在GitHub上公开可用，模型托管于Hugging Face<sup>[1](https://arxiv.org/abs/2401.02385)</sup><sup> • </sup><sup>[4](https://huggingface.co/TinyLlama/TinyLlama_v1.1)</sup>。

## 用途、影响与局限

**边缘部署。** 4比特量化权重仅占用637 MB，项目称这使其能够用于离线任务的边缘部署，如实时机器翻译、辅助更大模型的推测解码，以及电子游戏中的实时对话生成<sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。新加坡科技设计大学的新闻稿称该模型仅占用550 MB内存并在16块GPU上运行，可实现移动部署；而代码仓库自己的数字是量化后637 MB、FP16约2.2 GB<sup>[3](https://www.sutd.edu.sg/media-releases-listing/sutd-launches-first-of-its-kind-mini-ai-model-with-three-trillion-token-punch/)</sup><sup> • </sup><sup>[2](https://github.com/jzhang38/TinyLlama/)</sup>。一项涵盖[Raspberry Pi 5](https://www.edgepedia.org/zh/raspberry-pi-5)、Jetson AGX Orin和Mac Mini M1的边缘设备基准测试，使用llama.cpp和mlx-lm，发现TinyLlama是Raspberry Pi等低功耗设备上最高效的小型语言模型，且4比特量化在受限硬件上将速度提升最多60%，精度损失极小<sup>[11](https://digitalcommons.kennesaw.edu/cgi/viewcontent.cgi?article=1600&context=cday)</sup>。

**研究试验台。** Sea AI Lab研究员刘倩（Liu Qian）描述了将TinyLlama用作灵活高效的试验台：其优化增强将GPU利用率提升至Hugging Face transformers库之上，且多个10亿级检查点的获取让研究人员能比使用Llama-7B模型更快地验证假设<sup>[3](https://www.sutd.edu.sg/media-releases-listing/sutd-launches-first-of-its-kind-mini-ai-model-with-three-trillion-token-punch/)</sup>。论文本身将这项工作定位为探索在远超Chinchilla式缩放定律所建议的token量上训练小型模型，据称是首个在最多3万亿token上训练的10亿参数模型<sup>[1](https://arxiv.org/abs/2401.02385)</sup>。2024年一项涵盖100M至5B参数范围内57个小型语言模型的调查，覆盖从智能手表到智能手机的设备，将TinyLlama的规模级别纳入其常识推理、数学、上下文学习和长上下文任务的基准测试中<sup>[10](https://arxiv.org/html/2409.15790v3)</sup>。

**局限。** 有记录的弱点是推理质量：2025年IEEE研究中MMLU为24.42%，远低于更新的小型模型，且在独立测试中所有任务上均不如Llama 2 7B<sup>[7](https://doi.org/10.1109/aibthings66987.2025.11296175)</sup><sup> • </sup><sup>[8](https://kaitchup.substack.com/p/tinyllama-pre-training-a-small-llama)</sup>。同一IEEE研究得出结论，小型语言模型通常以显著更低的计算开销达到有竞争力的准确率，支持其作为大型LLM的可持续替代方案<sup>[7](https://doi.org/10.1109/aibthings66987.2025.11296175)</sup>。

## References

1. [TinyLlama: An Open-Source Small Language Model (arXiv preprint by the authors)](https://arxiv.org/abs/2401.02385)
2. [jzhang38/TinyLlama, official GitHub repository](https://github.com/jzhang38/TinyLlama/)
3. [SUTD Launches First-of-Its-Kind Mini AI Model With Three Trillion-Token Punch, SUTD press release](https://www.sutd.edu.sg/media-releases-listing/sutd-launches-first-of-its-kind-mini-ai-model-with-three-trillion-token-punch/)
4. [TinyLlama/TinyLlama_v1.1, Hugging Face model page](https://huggingface.co/TinyLlama/TinyLlama_v1.1)
5. [EVAL.md, TinyLlama chat model evaluations, official repository](https://github.com/jzhang38/TinyLlama/blob/main/EVAL.md)
6. [TinyLlama/TinyLlama_v1.1_chinese, Hugging Face model page](https://huggingface.co/TinyLlama/TinyLlama_v1.1_chinese)
7. [From Large to Small Language Models for Balanced Performance and Benchmarking, IEEE (2025)](https://doi.org/10.1109/aibthings66987.2025.11296175)
8. [TinyLlama: Pre-training a Small Llama 2 from Scratch, Kaitchup](https://kaitchup.substack.com/p/tinyllama-pre-training-a-small-llama)
9. [The 1B-and-Under Club: TinyLlama vs Phi-2 vs StableLM vs Qwen 0.5B, General Compute](https://www.generalcompute.com/blog/the-1b-and-under-club-tinyllama-vs-phi-2-vs-stablelm-vs-qwen-0-5b)
10. [Small Language Models: Survey, Measurements, and Insights (arXiv)](https://arxiv.org/html/2409.15790v3)
11. [GRP-134: Characterizing and Understanding the Performance of Small Language Models on Edge Devices, Kennesaw State University](https://digitalcommons.kennesaw.edu/cgi/viewcontent.cgi?article=1600&context=cday)

---
*Initially written Oct 15, 2026 · Edited: Oct 21, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Model families and named models › Large language model families › Open-weight model families

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/tinyllama

English original: https://www.edgepedia.org/tinyllama
