OpenBMB / MiniCPM-V

MiniCPM-V 2.6: A GPT-4V Level MLLM for Single Image, Multi Image and Video on Your Phone
Apache License 2.0
12.14k stars 849 forks source link

例子出错:Token indices sequence length is longer than the specified maximum sequence length for this model (2105 > 2048). Running this sequence through the model will result in indexing errors #189

Closed zhaoyang0618 closed 4 months ago

zhaoyang0618 commented 4 months ago

起始日期 | Start Date

No response

实现PR | Implementation PR

No response

相关Issues | Reference Issues

No response

摘要 | Summary

例子执行出错,会是什么原因?token长度限制这么小吗?只有2048?

基本示例 | Basic Example

from chat import MiniCPMVChat, img2base64 import torch import json

torch.manual_seed(0)

chat_model = MiniCPMVChat('openbmb/MiniCPM-Llama3-V-2_5')

im_64 = img2base64('./assets/airplane.jpeg')

First round chat

msgs = [{"role": "user", "content": "Tell me the model of this aircraft."}]

inputs = {"image": im_64, "question": json.dumps(msgs)} answer = chat_model.chat(inputs) print(answer)

Second round chat

pass history context of multi-turn conversation

msgs.append({"role": "assistant", "content": answer}) msgs.append({"role": "user", "content": "Introduce something about Airbus A380."})

inputs = {"image": im_64, "question": json.dumps(msgs)} answer = chat_model.chat(inputs) print(answer)

缺陷 | Drawbacks

执行的时候报错:Token indices sequence length is longer than the specified maximum sequence length for this model (2105 > 2048). Running this sequence through the model will result in indexing errors

未解决问题 | Unresolved questions

No response

YuzaChongyi commented 4 months ago

你好,这是因为你的输入内容 tokenize 后长度大于 2048,你可以尝试用 huggingface 的 usage 进行测试,以及如果你的输入比较长,需要调整一下 max_inp_length,目前默认是 2048

zhaoyang0618 commented 4 months ago

多谢答复!

zhaoyang0618 commented 4 months ago

在我的电脑上,文档中给出的例子,web_demo_2.5以及web_demo_streamlit-2_5没有一个成功运行的,web_demo_2.5出现的问题是无法创建share模式,外部无法访问 web_demo_streamlit-2_5使用python去执行的时候,提示我使用streamlit run的方式执行,然后使用streamlit run执行,在执行之后,同样访问不到,模型也没有去加载。

YuzaChongyi commented 4 months ago

web_demo_2.5 无法创建 share 可能是网络问题,如果能看到本地启动端口的话说明是正确的,web_demo_streamlit-2_5 需要 streamlit run 方式启动,如果有报错的话还请贴一下报错信息。

zhaoyang0618 commented 4 months ago

麻烦的是它也不报错,就是如图这样了。 20240531143242

zhaoyang0618 commented 4 months ago

外部访问192.168.0.52:8501没有用

zhaoyang0618 commented 4 months ago

从代码看,按理应该加载模型,有输出消息才对

zhaoyang0618 commented 4 months ago

web_demo_2.5 无法创建 share 可能是网络问题:这个问题解决了,是权限问题!

zhaoyang0618 commented 4 months ago

是不支持中文吗?我输入一幅图片,请他帮忙提取其中的表格数据,结果返回一堆莫名其妙的东西。(有一个黑色部分是为了去敏) 20240531155606 20240531155637

YuzaChongyi commented 4 months ago

你好,你能分享一下这张图吗,当前模型在复杂的表格提取上能力还不太稳定,我们后续也会针对复杂表格的结构化提取做增强

zhaoyang0618 commented 4 months ago

你好,你能分享一下这张图吗,当前模型在复杂的表格提取上能力还不太稳定,我们后续也会针对复杂表格的结构化提取做增强

不好意思,图片中涉及一些个人隐私,无法提供!

Cuiunbo commented 4 months ago

你好,你能分享一下这张图吗,当前模型在复杂的表格提取上能力还不太稳定,我们后续也会针对复杂表格的结构化提取做增强

不好意思,图片中涉及一些个人隐私,无法提供!

您好,可以选择尝试beam search,通常会带来更好的结果