之前看代码都比较粗,没太注意提示工程,昨天花了时间搜集整理了一下。
我理解的template是针对一组(ins,input(可选),output)对,模型如何去组织,利用template去format一种可学习的“知识”。对stanford_alpaca而言,他使用了alpaca数据集,提出了standford_alpaca的template,同时利用这个 数据+模板 微调了一个模型ALPACA。所以在我们讲到ALPACA的时候,既可以指用于微调的数据集,也可以指微调使用的template结构,还可以指最后微调出来的ALPACA模型。
下面解读一些平时常听到的template结构。
Stanford_alpaca
官网提供了两种结构,有input与没有input。是简单的指令-响应格式。
- 有input的
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{instruction}
### Input:
{input}
### Response:
- 没有input的
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{instruction}
### Response:
Vicuna
官网给出的样例如下,是有system设置的对话模式。
A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
USER: Hello!
ASSISTANT: Hello!</s>
USER: How are you?
ASSISTANT: I am good.</s>
Llama2
<s>{{ user_prompt }}
llama2-chat
<s>[INST] <<SYS>>
{{ system_prompt }}
<</SYS>>
{{ user_message }} [/INST]
目前大概理解到这种程度,有新的想法再更新。