Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix telechat2 template #2775

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion swift/llm/template/template/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class TeleChatTemplateMeta(TemplateMeta):
prompt: Prompt = field(default_factory=lambda: ['<_user>{{QUERY}}<_bot>'])
chat_sep: Optional[Prompt] = field(default_factory=lambda: ['<_end>'])
suffix: Prompt = field(default_factory=lambda: ['<_end>'])
system_prefix: Optional[Prompt] = field(default_factory=lambda: ['<_system>{{SYSTEM}}'])
system_prefix: Optional[Prompt] = field(default_factory=lambda: ['<_system>{{SYSTEM}}\n'])


register_template(TeleChatTemplateMeta(LLMTemplateType.telechat))
Expand Down
6 changes: 4 additions & 2 deletions tests/test_align/test_template/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ def test_codegeex4():

def test_telechat():
pt_engine = PtEngine('TeleAI/TeleChat2-7B', torch_dtype=torch.float16)
_infer_model(pt_engine, messages=[{'role': 'user', 'content': '你是谁?'}])
messages = [{'role': 'system', 'content': '你是一个乐于助人的智能助手,请使用用户提问的语言进行有帮助的问答'}, {'role': 'user', 'content': '你好'}]
response = _infer_model(pt_engine, messages=messages)
pt_engine.default_template.template_backend = 'jinja'
_infer_model(pt_engine, messages=[{'role': 'user', 'content': '你是谁?'}])
response2 = _infer_model(pt_engine, messages=messages)
assert response == response2


def test_glm_edge():
Expand Down
Loading