AI&大模型 | llama2微调手册查看ing

提示词说明

[INST] <>
{{ system_prompt }}
<>

{{ user_message }} [/INST]

其中,

,<\s>,<>,<>,[INST],以及[/INST]是特殊token,

标记着prompt中各个部分的构成。

每一组之间是一个相对完整的单元,可以理解为一个对话轮次(如果直接给一个文本作为输入,也可以看到模型的输入结果分别是以这两个BOS和EOS token作为结尾的)。

[INST]和[/INST]用于区分在当前这一轮的对话(历史)中,用户输入的部分与模型返回的部分。位于[INST]之后,/[INST]之前的文本,是用户在. 这一轮次(包含的文本)对话中所输入的query,而/[INST]之后的文本,是模型针对这一query所作出的回答。

在对话中的第一组单元,可以提供整个对话的背景信息,并以<>和<>作为特殊标记,位于它们之间的,是对话的背景信息,类似instruction。

{{ system_prompt }}部分是整个对话中的通用前缀,一般用来给模型提供一个身份,作为对话的大背景。

{{ user_message }}部分是用户所提供的信息,可以理解为多轮对话中其中一轮对话的内容。

[INST] <>
You are a helpful, respectful and honest assistant. Always answer as helpfully as 
possible, while being safe.  Your answers should not include any harmful, unethical, 
racist, sexist, toxic, dangerous, or illegal content. Please ensure that your 
responses are socially unbiased and positive in nature.

If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
<>

There's a llama in my garden   What should I do? [/INST]

对于多轮,有这个例子

<s>[INST] <<SYS>>

You are are a helpful... bla bla.. assistant

<</SYS>>

Hi there! [/INST] Hello! How can I help you today? </s><s>[INST] What is a neutron 
star? [/INST] A neutron star is a ... </s><s> [INST] Okay cool, thank you! [/INST]

上面整体作为prompt输入给模型去进行generate时,模型的输出应该是类似于You’re welcome! 之类的话。

https://zhuanlan.zhihu.com/p/651306200

不同版本Llama区别

Llama 2 模型接受了 2 万亿个标记的训练,上下文长度是 Llama 1 的两倍。Llama-2-chat 模型还接受了超过 100 万个新的人类注释的训练。
Llama 2训练语料相比LLaMA多出40%,上下文长度是由之前的2048升级到4096,可以理解和生成更长的文本。

训练 Llama-2-chat:Llama 2 使用公开的在线数据进行预训练。 然后通过使用监督微调创建 Llama-2-chat 的初始版本。 接下来,Llama-2-chat 使用人类反馈强化学习 (RLHF) 进行迭代细化,其中包括拒绝采样和近端策略优化 (PPO)。

模型

分词器

Llama 2使用与 Llama 1 相同的分词器; 它采用字节对编码(BPE)算法,使用 SentencePiece 实现。 与Llama 1 一样,将所有数字拆分为单独的数字,并使用字节来分解未知的 UTF-8 字符。 总数 词汇量为 32k 个token

架构

使用标准Transformer 架构,使用 RMSNorm 应用预归一化、使用 SwiGLU 激活函数和旋转位置嵌入RoPE。与 Llama 1 的主要架构差异包括增加了上下文长度和分组查询注意力(GQA)

计算资源

微调

常见Bug

你可能感兴趣的:(人工智能)