Meta Llama - Model Cards & Prompt formats-一、Meta Llama

模型卡 : https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md


与Meta Llama 3一起使用的特殊token

  • <|begin_of_text|> :这相当于BOS token
  • <|eot_id|> :这表示本轮消息结束。
  • <|start_header_id|>{role}<|end_header_id|> :这些标记包含特定消息的角色。可能的角色可以是: system, user, assistant。
  • <|end_of_text|> :这相当于 EOS token 。在生成此token 时,Llama 3 将停止生成更多token 。

提示可以选择包含单个系统消息,或多个交替的用户和助手消息,但始终以最后一条用户消息结尾,后跟助手标头。


Meta Llama 3

生成此提示格式的代码可见:
https://github.com/meta-llama/llama3/blob/main/llama/generation.py#L223

注:换行符(0x0A)是提示格式的一部分,为了在示例中清晰起见,它们被表示为实际的新行。

<|begin_of_text|>{{ user_message }}

Meta Llama 3 Instruct

生成此提示格式的代码可见:https://github.com/meta-llama/llama3/blob/main/llama/tokenizer.py#L203

注意:

  • 换行符(0x0A)是提示格式的一部分,为了在示例中清楚起见,它们被表示为实际的新行。
  • 模型期望提示末尾的辅助标头 来开始完成它。

使用系统消息分解示例指令提示:

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful AI assistant for travel tips and recommendations<|eot_id|><|start_header_id|>user<|end_header_id|>

What can you help me with?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

  • <|begin_of_text|> : 指定 prompt 的开头
  • <|start_header_id|>system<|end_header_id|> : 指定以下消息的角色,即“系统”
  • You are a helpful AI assistant for travel tips and recommendations: 系统信息
  • <|eot_id|> :指定输入信息的结尾
  • <|start_header_id|>user<|end_header_id|> : 指定接下来信息的校色,如 user
  • What can you help me with? : 用户信息
  • <|start_header_id|>assistant<|end_header_id|> : 结束 assistant header,提示模型开始生成
  • 在这个提示之后,Llama 3通过生成 {{assistant_message}} 来完成它。它通过生成 <|eot_id|> 标志 {{assistant_message}} 的结束。

带有单个用户消息的示例提示

<|begin_of_text|><|start_header_id|>user<|end_header_id|>

What is France's capital?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

系统提示和 用户与助手之间的多轮对话

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful AI assistant for travel tips and recommendations<|eot_id|><|start_header_id|>user<|end_header_id|>

What is France's capital?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Bonjour! The capital of France is Paris!<|eot_id|><|start_header_id|>user<|end_header_id|>

What can I do there?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Paris, the City of Light, offers a romantic getaway with must-see attractions like the Eiffel Tower and Louvre Museum, romantic experiences like river cruises and charming neighborhoods, and delicious food and drink options, with helpful tips for making the most of your trip.<|eot_id|><|start_header_id|>user<|end_header_id|>

Give me a detailed list of the attractions I should visit, and time it takes in each one, to plan my trip accordingly.<|eot_id|><|start_header_id|>assistant<|end_header_id|>


上一篇:Emacs: 可扩展的编辑器之神-Emacs的核心特性


下一篇:mac合并pdf文件最简单的方法,mac如何合并pdf文件