目录

Llama3

模型

下载

数据集

HuggingFaceH4/no_robots

No Robots 是由熟练的人类注释者创建的包含 10,000 条指令和演示的高质量数据集。该数据可用于监督微调(SFT),使语言模型更好地遵循指令。 No Robots 是根据 OpenAI 的 InstructGPT 论文中描述的指令数据集进行建模的。

介绍

Llama 3 最大的变化是采用了新的 Tokenizer,将词汇表大小扩展至 128,256(前版本为 32,000 Token)。这一更大的词汇库能够更高效地编码文本(无论输入还是输出),并有可能提升模型的多语种处理能力。不过,这也导致嵌入层的输入和输出矩阵尺寸增大,这是小型模型参数增加(从 Llama 2 的 7B 增至 Llama 3 的 8B)的主要原因之一。此外,8B 版本的模型现在采用了分组查询注意力(GQA),这是一种效率更高的表达方式,有助于处理更长的上下文。具有 8000 Token 的上下文长度。

Llama 3 模型在两个拥有 24,000 GPU 的集群上进行了训练,使用的是超过 15 万亿 Token 的新公共在线数据。我们无法得知训练数据具体细节,但可以推测,更大规模且更细致的数据策划是性能提升的重要因素。Llama 3 Instruct 针对对话应用进行了优化,结合了超过 1000 万的人工标注数据,通过监督式微调(SFT)、拒绝采样、邻近策略优化(PPO)和直接策略优化(DPO)进行训练。

Benchmarks

信任与安全

Responsibility at different layers of the development process(开发过程不同层面的责任)

Responsible LLM Product Development Stages

Meta Llama Cybersec Eval 2

System-level safeguards

Meta Llama Code Shield

A system-level approach to responsibility

Meta Llama Cybersec Eval 2

  • Insecure code practice(generation and autocomplete)(不安全的代码实践(生成和自动完成))
  • Cyber attacker helpfulness(对网络攻击者的帮助)
  • Code interpreter abuse(代码解释器滥用)
  • Offensive cybersecurity capabilities(攻击性网络安全能力)
  • Susceptibility to prompt injection(对提示注入的易感性)

设置提示

基础模型不具备固定的提示格式。如同其他基础模型,它们可以用来延续输入序列,提供合理的续写或进行零样本/少样本推理。这些模型也是您自定义微调的理想基础。指令版本采用以下对话结构:

system

user

assistant


使用 transformers

要在 transformers 中使用 Llama 3 模型,请确保安装了最新版本:

pip install -U "transformers==4.40.0" --upgrade

LangChain

from langchain_community.llms import Ollama
from langchain_core.prompts import ChatPromptTemplate

chat = Ollama(model="llama3", temperature=0)

system = "You are a helpful assistant that translates {input_language} to {output_language}."
human = "{text}"
prompt = ChatPromptTemplate.from_messages([("system", system), ("human", human)])

chain = prompt | chat
response = chain.invoke(
    {
        "input_language": "English",
        "output_language": "Chinese",
        "text": "I love Python",
    }
)

print('🤖 ', response)
I'd be happy to help you with that!

The translation of "I love Python" from English to Chinese is:

"" (Wǒ ài de Pītōn)

Here's the breakdown:

* "" (wǒ) means "I"
* "" (ài) means "love" or "like"
* "" (de) is a possessive particle indicating that something belongs to someone
* "" (Pītōn) refers to the programming language Python

So, "" (Wǒ ài de Pītōn) literally means "I love my Python", but in this context, it's more like saying "I love Python"!

llama3-8b 翻译成拼音了

参考资料