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

[QA] 书生2模型有关chat_template的问题 #700

Closed
DirtyKnightForVi opened this issue Feb 20, 2024 · 5 comments
Closed

[QA] 书生2模型有关chat_template的问题 #700

DirtyKnightForVi opened this issue Feb 20, 2024 · 5 comments
Assignees
Labels
question Further information is requested Stale

Comments

@DirtyKnightForVi
Copy link

描述问题

整个模型系列中有chat_template,但是最新的模型文件中modeling.py里面没有使用到。
官方的例程里使用Transformers调用模型,对话用的是 chat() ,添加使用function call会很麻烦。

希望能基于openai样式的对话历史来组装inputs。

@DirtyKnightForVi DirtyKnightForVi added the question Further information is requested label Feb 20, 2024
@RangiLyu
Copy link
Collaborator

你可以使用tokenizer的apply_chat_template接口来处理openai样式的input message,然后直接使用model的generate接口进行对话

chat = [{"role": "user", "content": "Hello! What's your name?"},
        {"role": "assistant", "content": "My name is InternLM2!"},
        {"role": "user", "content": "Nice to meet you InternLM2!"},]

# convert the chat history to a string for generation
chat_str = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
print(chat_str)

output:

<s><|im_start|>user
Hello! What's your name?<|im_end|>
<|im_start|>assistant
My name is InternLM2!<|im_end|>
<|im_start|>user
Nice to meet you InternLM2!<|im_end|>
<|im_start|>assistant

我们之后会更新示例里面的用法

Copy link

github-actions bot commented Mar 7, 2024

This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 7 days if the stale label is not removed or if there is no further response.

@github-actions github-actions bot added the Stale label Mar 7, 2024
@jaffe-fly
Copy link

如何体验 function call 的功能?

Copy link

This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 7 days if the stale label is not removed or if there is no further response.

@github-actions github-actions bot added the Stale label Mar 16, 2024
Copy link

This issue is closed because it has been stale for 7 days. Please open a new issue if you have similar issues or you have any new updates now.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

4 participants