🚀 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 |