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.61k stars 887 forks source link

[BUG] <title>请问该代码是不支持minicpm-v的模型吗 #553

Closed baymax591 closed 2 months ago

baymax591 commented 2 months ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

模型下载路径

https://huggingface.co/openbmb/MiniCPM-V

数据集(自定义)

[
    {
      "id": "0",
      "image": "/data2/baymax/MiniCPM-V/finetune/data/123.jpg",
      "conversations": [
            {
              "role": "user", 
              "content": "<image>\n这张照片有几头牛?"
            }, 
            {
                "role": "assistant", 
                "content": "在这张照片中,有两头牛。一头是棕色的,正朝着相机方向走来;另一头是黑白相间的,在后面吃草。"
            },   
            {
                "role": "user", 
                "content": "这两头牛分别是什么颜色的?"
            },
            {
                "role": "assistant", 
                "content": "其中一头是棕色的,另一头是黑白相间的。"
            }, 
            {
                "role": "user", 
                "content": "整个场景给你的感受是什么?"}, 
            {
                "role": "assistant", 
                "content": "整个场景显得宁静而自然,给人一种放松和舒适和感觉。"
            }
        ]
    }
  ]

finetune_ds文件

DATA="path/train_data.json"
EVAL_DATA="path/train_data.json"
LLM_TYPE="minicpm" # if use openbmb/MiniCPM-V-2, please set LLM_TYPE=minicpm, if use openbmb/MiniCPM-Llama3-V-2_5, please set LLM_TYPE="llama3"

碰到的问题

期望行为 | Expected Behavior

  1. 想问一下该代码是否支持minicpm-v模型
  2. 如果支持的话应该如何进行微调呢

复现方法 | Steps To Reproduce

  1. git clone源码
  2. 配置环境
  3. 自定义数据集
  4. 修改finetune_ds.sh文件
  5. 运行finetune_ds.sh

运行环境 | Environment

- OS:
- Python:3.10
- Transformers:4.40.0
- PyTorch:2.1.0

备注 | Anything else?

No response

baymax591 commented 2 months ago

推理是可以正常执行的,微调出错

LDLINGLINGLING commented 2 months ago

你的数据集中好像没有占位符

baymax591 commented 2 months ago

占位符是指image吗,是有的,在这里没显示 image

baymax591 commented 2 months ago

我更新了一下markdown,现在可以看清楚了

lyfpku commented 2 months ago

同样遇到这个问题,运行sh finetune_ds.sh报错data fetch error image debug发现,运行到if input_ids.shape[-1] > max_length:处中断,跳转到except: logger.error(f"data fetch error") image 打印type(input_ids)和input_ids,发现input_ids属于list,没有shape方法 image 添加input_ids = torch.tensor(np.hstack(input_ids), dtype=torch.int32)转换,依然报错:IndexError: tuple index out of range image 再往后就不会了,感觉是代码的问题,还请官方尽快检查一下看看是不是不支持minicpm-V-2微调

baymax591 commented 2 months ago

有官方人员帮忙看下嘛

LDLINGLINGLING commented 2 months ago

image 之前好像碰到过这个问题,将图中的红框改成input_ids应该就可以了。