Source code for lmflow.utils.conversation_template.qwen
#!/usr/bin/env python
# coding=utf-8
# Copyright 2024 Statistics and Machine Learning Research Group. All rights reserved.
from .base import StringFormatter, TemplateComponent, ConversationTemplate, ConversationTemplateForTool
[docs]
QWEN2_TEMPLATE = ConversationTemplate(
template_name='qwen2',
user_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>user\n{{content}}<|im_end|>\n')
]
),
assistant_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>assistant\n{{content}}<|im_end|>\n')
]
),
system_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>system\n{{content}}<|im_end|>\n')
]
),
separator=TemplateComponent(type='string', content='\n')
)
[docs]
QWEN2_TEMPLATE_FOR_TOOL = ConversationTemplateForTool(
template_name='qwen2_for_tool',
user_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>user\n{{content}}<|im_end|>\n')
]
),
function_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>assistant\n{{content}}<|im_end|>\n')
]
),
observation_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>tool\n{{content}}<|im_end|>\n')
]
),
assistant_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>assistant\n{{content}}<|im_end|>\n')
]
),
system_formatter=StringFormatter(
template=[
TemplateComponent(type='string', content='<|im_start|>system\n{{content}}<|im_end|>\n')
]
),
separator=TemplateComponent(type='string', content='\n')
)