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

Multiturn chat demo 多轮对话的示例 #410

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gxlover0625
Copy link

主要贡献

  • 修改readme中没有多轮对话示例的问题
  • 将所有的推理代码封装成类的形式,提升封装性

具体工作

设计了Qwen2VL类,将推理代码进一步的封装,
用户只需要通过传递自然语言形式的query、图片的路径imgs、前文的对话history给chat接口,就可以完成多轮对话。简单如下:

chat_model = Qwen2VL(model_path="local path/repo id")

# First turn
history = None
response, history = chat_model.chat(query="hello", history=history)
print(response, history)

# Second turn
# For image type, (imgae_url, local_image_path, base64)
# For image count, ([image], [image1, image2], ...)
response, history = chat_model.chat(query="please describe the image", imgs=["image_url"], history=history)
print(response, history)

对于新手小白会更加友好,无需关心如何构造messages,就跟我们跟gpt打交道一样,用自然语言表述我们的需求、在浏览器端上传图片,同时保留历史对话。

自我介绍

最后小小的自我介绍一下,我是一名浙江大学的研究生,同时也在淘天集团的大模型岗位实习过,主要工作集中在多模态大模型,对Qwen2VLQwenVLInternVL比较熟悉,因为学校开设的开源课程,对开源社区贡献比较感兴趣,第一次提交pr,无论是否被merge,都算是一次勇敢的尝试哈哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant