🚀 TinyLlama-1.1B
TinyLlama项目旨在预训练一个在3万亿个标记上训练的11亿参数的Llama模型。通过适当的优化,使用16块A100 - 40G GPU,我们可以在“仅”90天内完成这一目标🚀🚀。训练已于2023年9月1日开始。
该模型采用了与Llama 2完全相同的架构和分词器。这意味着TinyLlama可以无缝集成到许多基于Llama构建的开源项目中。此外,TinyLlama仅拥有11亿参数,体积小巧。这种紧凑性使其能够满足许多对计算和内存占用有严格要求的应用场景。
🚀 快速开始
你需要 transformers >= 4.34
版本。更多信息请查看 TinyLlama 的GitHub页面。
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0", torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{
"role": "system",
"content": "You are a friendly chatbot who always responds in the style of a pirate",
},
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
print(outputs[0]["generated_text"])
✨ 主要特性
- 架构兼容:采用与Llama 2相同的架构和分词器,可轻松集成到基于Llama的开源项目中。
- 参数紧凑:仅11亿参数,适合对计算和内存要求较高的应用。
📦 安装指南
你需要 transformers >= 4.34
版本,可按需从源码安装:
pip install git+https://github.com/huggingface/transformers.git
pip install accelerate
💻 使用示例
基础用法
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0", torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{
"role": "system",
"content": "You are a friendly chatbot who always responds in the style of a pirate",
},
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
print(outputs[0]["generated_text"])
📚 详细文档
本模型
此聊天模型是在 TinyLlama/TinyLlama - 1.1B - intermediate - step - 1431k - 3T 基础上进行微调的。我们遵循 HF的Zephyr 的训练方法。该模型最初在 UltraChat
数据集的一个变体上进行微调,该数据集包含ChatGPT生成的各种合成对话。
然后,我们使用 🤗 TRL的 DPOTrainer
在 openbmb/UltraFeedback 数据集上进一步对齐模型,该数据集包含64k个由GPT - 4排名的提示和模型完成内容。
📄 许可证
本项目采用 Apache - 2.0
许可证。
📋 数据集
属性 |
详情 |
训练数据 |
cerebras/SlimPajama - 627B、bigcode/starcoderdata、HuggingFaceH4/ultrachat_200k、HuggingFaceH4/ultrafeedback_binarized |