MiniCPM-V icon indicating copy to clipboard operation
MiniCPM-V copied to clipboard

[BUG] Conversation processing error.

Open SummerFall1819 opened this issue 1 year ago • 4 comments

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

  • [x] 我已经搜索过已有的issues和讨论 | I have searched the existing issues / discussions

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

  • [x] 我已经搜索过FAQ | I have searched FAQ

当前行为 | Current Behavior

Function conversation_to_ids in file finetune/dataset.py. There exists the following code:

    if llm_type == "llama3":
        input_ids, context, raw_msg = conversation_to_ids_llama3(
            conversation, tokenizer
        )
    elif llm_type == "qwen":
        input_ids, context, raw_msg = conversation_to_ids_qwen2(
            conversation, tokenizer
        )
    else:
        input_ids, context, raw_msg = conversation_to_ids_minicpm(
            conversation, tokenizer
        )

    ids = torch.from_numpy(np.hstack(input_ids, dtype=np.int32))
    context = torch.from_numpy(np.hstack(context, dtype=np.int8))
    if input_ids.shape[-1] > max_length:
    [omitted]

but function conversation_to_ids_minicpm only returns a tuple of lists, which won't have a shape attribute, thus setting LLM_TYPE as minicpm would lead the following error:

Traceback (most recent call last):
  File "/finetune/dataset.py", line 60, in __getitem__
    ret = preprocess(
          ^^^^^^^^^^^
  File "dataset.py", line 399, in preprocess
    input_dict = conversation_to_ids(conversations, tokenizer, llm_type, new_schema, max_length)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/finetune/dataset.py", line 150, in conversation_to_ids
    if input_ids.shape[-1] > max_length:
       ^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'shape'

期望行为 | Expected Behavior

Return a tuple of numpy array as other functions do.

复现方法 | Steps To Reproduce

None

运行环境 | Environment

No need.

备注 | Anything else?

This issue is first raised in #535. Is this a legacy code? Do you consider updating this code?

SummerFall1819 avatar Oct 18 '25 13:10 SummerFall1819

May I ask what code this is, and what framework is it from?

tc-mb avatar Oct 27 '25 03:10 tc-mb

Function conversation_to_ids in file finetune/dataset.py. Directly from your official repo. https://github.com/OpenBMB/MiniCPM-V/blob/74aa48ebeb6caa273842395feb95614ad85f81e9/finetune/dataset.py#L200-L229 You could see from here, this function returns List.

However, at here: https://github.com/OpenBMB/MiniCPM-V/blob/74aa48ebeb6caa273842395feb95614ad85f81e9/finetune/dataset.py#L126-L150

line 141 call the function above, get a list, and immediately use input_ids.shape[-1] at line 147, causing the error discussed above, this error will be covered as fetch data error..

I'm aware that this function might already be deprecated, but I think it is better to either update readme or update this part of code as there exists relevant description about this part of code.

https://github.com/OpenBMB/MiniCPM-V/blob/74aa48ebeb6caa273842395feb95614ad85f81e9/finetune/readme.md?plain=1#L102

SummerFall1819 avatar Oct 27 '25 07:10 SummerFall1819

@qyc-98 PTAL

tc-mb avatar Oct 31 '25 09:10 tc-mb

您好,感谢反馈。由于目前团队人力有限,这个问题暂时无法及时跟进处理,非常抱歉。如后续有进展我们会更新,也欢迎社区贡献。先关闭此 issue,如有需要欢迎重新打开。

tc-mb avatar Mar 05 '26 08:03 tc-mb