src/llamafactory/data/template.pydefault 템플릿
_register_template(
name="default",
format_user=StringFormatter(slots=["Human: {{content}}\nAssistant: "]),
format_system=StringFormatter(slots=["{{content}}\n"]),
format_separator=EmptyFormatter(slots=["\n"]),
)
LLaMA-3 템플릿 템플릿
_register_template(
name="llama3",
format_user=StringFormatter(
slots=[
(
"<|start_header_id|>user<|end_header_id|>\n\n{{content}}<|eot_id|>"
"<|start_header_id|>assistant<|end_header_id|>\n\n"
)
]
),
format_system=StringFormatter(
slots=[{"bos_token"}, "<|start_header_id|>system<|end_header_id|>\n\n{{content}}<|eot_id|>"]
),
format_observation=StringFormatter(
slots=[
(
"<|start_header_id|>tool<|end_header_id|>\n\n{{content}}<|eot_id|>"
"<|start_header_id|>assistant<|end_header_id|>\n\n"
)
]
),
default_system="You are a helpful assistant.",
stop_words=["<|eot_id|>"],
replace_eos=True,
)
data 디렉토리에 있는 json형태의 LLaMA Factory 입력 데이터의 형식과, 모델의 ChatTemplate이 합쳐져 LLM에서 요구하는 형식의 질문을 하게 됩니다.sample_data.json
{
"instruction": "갈비찜이 뭐야??",
"input": "",
"output": "갈비찜은 한국 전통 음식으로, 부드럽게 익힌 갈비에 양념을 넣어 맛을 낸 요리입니다."
}