You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用vLLM运行多模态Mistral-Small模型遇Tokenizer属性错误求助

解决Mistral-Small-3.1多模态模型在vLLM中运行的分词器错误

错误原因

指定tokenizer_mode="mistral"会启用vLLM内置的简化版MistralTokenizer,该实现仅适配纯文本模型,缺少多模态场景下vLLM所需的convert_tokens_to_ids方法,导致兼容性问题。

可行配置方案

1. 调整代码参数

修改LLM初始化配置,移除tokenizer_mode="mistral",改用transformers原生分词器,并显式指定模型对应的分词器和图像处理器:

def main():
    llm = LLM(
        model="mistralai/Mistral-Small-3.1-24B-Instruct-2503",
        tokenizer="mistralai/Mistral-Small-3.1-24B-Instruct-2503",
        trust_remote_code=True,
        max_model_len=32768,
        dtype="auto",
        image_processor="mistralai/Mistral-Small-3.1-24B-Instruct-2503"
    )

    params = SamplingParams(temperature=0.15, max_tokens=512)
    
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What's the picture about"},
                {"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/europe.png"}}
            ]
        }
    ]
    
    output = llm.chat(messages, params)[0].outputs[0].text
    print(output)


if __name__ == '__main__':
    main()

2. 补充依赖安装

确保安装多模态处理所需的依赖:

pip install pillow accelerate

3. 版本适配建议

尝试以下经过测试的兼容版本组合:

  • vLLM: 0.9.1
  • Transformers: 4.54.2
  • Mistral_common: 1.5.4

执行版本更新命令:

pip install vllm==0.9.1 transformers==4.54.2 mistral_common==1.5.4

内容的提问来源于stack exchange,提问作者weiming

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 01:20:02