HuggingFace镜像/TinyLlama-1.1B-Chat-v0.6
模型介绍文件和版本分析
下载使用量0

TinyLlama-1.1B

https://github.com/jzhang38/TinyLlama

TinyLlama项目旨在预训练一个基于3万亿tokens的1.1B Llama模型。通过适当的优化,我们仅需16块A100-40G GPU,在“短短”90天内即可完成这一目标 🚀🚀。训练已于2023年9月1日启动。

我们采用了与Llama 2完全相同的架构和分词器。这意味着TinyLlama可以直接应用于许多基于Llama构建的开源项目中,即插即用。此外,TinyLlama仅拥有1.1B参数,体型小巧。这种紧凑性使其能够满足众多对计算和内存资源有严格限制的应用场景。

本模型

此模型是在[TinyLlama/TinyLlama-1.1B-intermediate-step-955k-2T]基础上微调得到的对话模型。我们遵循[HF's Zephyr]的训练方案。 该模型“首先在[UltraChat]数据集的一个变体上进行微调,该数据集包含由ChatGPT生成的各种合成对话。 然后,我们使用🤗 TRL's的DPOTrainer在[openbmb/UltraFeedback]数据集上进一步对齐模型,该数据集包含64k个提示词以及由GPT-4评分的模型补全内容。”

使用方法

您需要安装transformers>=4.34版本。 更多信息请查阅TinyLlama的GitHub页面。

# Install transformers from source - only needed for versions <= v4.34
# pip install git+https://github.com/huggingface/transformers.git
# pip install accelerate

import torch
from openmind import pipeline

pipe = pipeline("text-generation", model="LF_AICC/TinyLlama-1.1B-Chat-v0.6", torch_dtype=torch.bfloat16, device_map="auto")

# We use the tokenizer's chat template to format each message
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"])
# <|system|>
# You are a friendly chatbot who always responds in the style of a pirate.</s>
# <|user|>
# How many helicopters can a human eat in one sitting?</s>
# <|assistant|>
# ...