LLamaFactory 微调Qwen-VL-3B时报错TypeError: argument of type ‘NoneType‘ is not iterable

LLamaFactory 微调Qwen-VL-3B时报错如下:

TypeError: argument of type 'NoneType' is not iterable

修改方式如下所示:

 进入\src\llamafactory文件夹,打开cli.py文件

在文件头添加如下语句

from transformers import modeling_utils
if not hasattr(modeling_utils, "ALL_PARALLEL_STYLES") or modeling_utils.ALL_PARALLEL_STYLES is None:
    modeling_utils.ALL_PARALLEL_STYLES = ["tp", "none","colwise",'rowwise']
root@dsw-1208255-6465b7b85-hssrw:/mnt/workspace/fine-tuning# python -c "from transformers import AutoModel; AutoModel.from_pretrained(&#39;Qwen/Qwen2.5-0.5B-Instruct&#39;, trust_remote_code=True)" 2025-07-12 14:30:57.162813: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. 2025-07-12 14:30:57.209646: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2025-07-12 14:30:58.175636: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/local/lib/python3.11/site-packages/transformers/models/auto/auto_factory.py", line 571, in from_pretrained return model_class.from_pretrained( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/modeling_utils.py", line 309, in _wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/modeling_utils.py", line 4508, in from_pretrained model = cls(config, *model_args, **model_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/models/qwen2/modeling_qwen2.py", line 362, in __init__ self.post_init() File "/usr/local/lib/python3.11/site-packages/transformers/modeling_utils.py", line 1969, in post_init if v not in ALL_PARALLEL_STYLES: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type &#39;NoneType&#39; is not iterable root@dsw-1208255-6465b7b85-hssrw:/mnt/workspace/fine-tuning#
07-13
[INFO|modeling_utils.py:2241] 2025-07-15 10:13:01,778 >> Instantiating Qwen2_5_VisionTransformerPretrainedModel model under default dtype torch.bfloat16. [INFO|modeling_utils.py:2241] 2025-07-15 10:13:01,789 >> Instantiating Qwen2_5_VLTextModel model under default dtype torch.bfloat16. Traceback (most recent call last): File "F:\anaconda\envs\qwen\lib\site-packages\gradio\queueing.py", line 715, in process_events response = await route_utils.call_process_api( File "F:\anaconda\envs\qwen\lib\site-packages\gradio\route_utils.py", line 322, in call_process_api output = await app.get_blocks().process_api( File "F:\anaconda\envs\qwen\lib\site-packages\gradio\blocks.py", line 2191, in process_api result = await self.call_function( File "F:\anaconda\envs\qwen\lib\site-packages\gradio\blocks.py", line 1714, in call_function prediction = await utils.async_iteration(iterator) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 739, in async_iteration return await anext(iterator) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 733, in __anext__ return await anyio.to_thread.run_sync( File "F:\anaconda\envs\qwen\lib\site-packages\anyio\to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "F:\anaconda\envs\qwen\lib\site-packages\anyio\_backends\_asyncio.py", line 2470, in run_sync_in_worker_thread return await future File "F:\anaconda\envs\qwen\lib\site-packages\anyio\_backends\_asyncio.py", line 967, in run result = context.run(func, *args) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 716, in run_sync_iterator_async return next(iterator) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 877, in gen_wrapper response = next(iterator) File "F:\qwen\LLaMA-Factory\src\llamafactory\webui\chatter.py", line 158, in load_model super().__init__(args) File "F:\qwen\LLaMA-Factory\src\llamafactory\chat\chat_model.py", line 53, in __init__ self.engine: BaseEngine = HuggingfaceEngine(model_args, data_args, finetuning_args, generating_args) File "F:\qwen\LLaMA-Factory\src\llamafactory\chat\hf_engine.py", line 59, in __init__ self.model = load_model( File "F:\qwen\LLaMA-Factory\src\llamafactory\model\loader.py", line 173, in load_model model = load_class.from_pretrained(**init_kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\auto\auto_factory.py", line 571, in from_pretrained return model_class.from_pretrained( File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 309, in _wrapper return func(*args, **kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 4508, in from_pretrained model = cls(config, *model_args, **model_kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\qwen2_5_vl\modeling_qwen2_5_vl.py", line 1799, in __init__ self.model = Qwen2_5_VLModel(config) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\qwen2_5_vl\modeling_qwen2_5_vl.py", line 1393, in __init__ self.language_model = Qwen2_5_VLTextModel._from_config(config.text_config) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 309, in _wrapper return func(*args, **kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 2077, in _from_config model = cls(config, **kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\qwen2_5_vl\modeling_qwen2_5_vl.py", line 1101, in __init__ self.post_init() File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 1969, in post_init if v not in ALL_PARALLEL_STYLES: TypeError: argument of type &#39;NoneType&#39; is not iterable
07-16
Traceback (most recent call last): File "F:\anaconda\envs\qwen\lib\site-packages\gradio\queueing.py", line 715, in process_events response = await route_utils.call_process_api( File "F:\anaconda\envs\qwen\lib\site-packages\gradio\route_utils.py", line 322, in call_process_api output = await app.get_blocks().process_api( File "F:\anaconda\envs\qwen\lib\site-packages\gradio\blocks.py", line 2191, in process_api result = await self.call_function( File "F:\anaconda\envs\qwen\lib\site-packages\gradio\blocks.py", line 1714, in call_function prediction = await utils.async_iteration(iterator) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 739, in async_iteration return await anext(iterator) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 733, in __anext__ return await anyio.to_thread.run_sync( File "F:\anaconda\envs\qwen\lib\site-packages\anyio\to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "F:\anaconda\envs\qwen\lib\site-packages\anyio\_backends\_asyncio.py", line 2470, in run_sync_in_worker_thread return await future File "F:\anaconda\envs\qwen\lib\site-packages\anyio\_backends\_asyncio.py", line 967, in run result = context.run(func, *args) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 716, in run_sync_iterator_async return next(iterator) File "F:\anaconda\envs\qwen\lib\site-packages\gradio\utils.py", line 877, in gen_wrapper response = next(iterator) File "F:\qwen\LLaMA-Factory\src\llamafactory\webui\chatter.py", line 158, in load_model super().__init__(args) File "F:\qwen\LLaMA-Factory\src\llamafactory\chat\chat_model.py", line 53, in __init__ self.engine: BaseEngine = HuggingfaceEngine(model_args, data_args, finetuning_args, generating_args) File "F:\qwen\LLaMA-Factory\src\llamafactory\chat\hf_engine.py", line 59, in __init__ self.model = load_model( File "F:\qwen\LLaMA-Factory\src\llamafactory\model\loader.py", line 173, in load_model model = load_class.from_pretrained(**init_kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\auto\auto_factory.py", line 571, in from_pretrained return model_class.from_pretrained( File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 309, in _wrapper return func(*args, **kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 4508, in from_pretrained model = cls(config, *model_args, **model_kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\qwen2_5_vl\modeling_qwen2_5_vl.py", line 1799, in __init__ self.model = Qwen2_5_VLModel(config) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\qwen2_5_vl\modeling_qwen2_5_vl.py", line 1393, in __init__ self.language_model = Qwen2_5_VLTextModel._from_config(config.text_config) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 309, in _wrapper return func(*args, **kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 2077, in _from_config model = cls(config, **kwargs) File "F:\anaconda\envs\qwen\lib\site-packages\transformers\models\qwen2_5_vl\modeling_qwen2_5_vl.py", line 1101, in __init__ self.post_init() File "F:\anaconda\envs\qwen\lib\site-packages\transformers\modeling_utils.py", line 1969, in post_init if v not in ALL_PARALLEL_STYLES: TypeError: argument of type &#39;NoneType&#39; is not iterable
07-16
/usr/local/lib/python3.11/site-packages/_distutils_hack/__init__.py:53: UserWarning: Reliance on distutils from stdlib is deprecated. Users must rely on setuptools to provide the distutils module. Avoid importing distutils or import setuptools first, and avoid setting SETUPTOOLS_USE_DISTUTILS=stdlib. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml warnings.warn( 2025-07-04 10:45:43.819174: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. 2025-07-04 10:45:43.859491: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2025-07-04 10:45:44.671052: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT /usr/local/lib/python3.11/site-packages/jieba/_compat.py:18: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. import pkg_resources Converting format of dataset (num_proc=16): 0%| | 0/91 [00:00<?, ? examples/s] Converting format of dataset (num_proc=16): 77%|████████████████████████████████████████████████████████▏ | 70/91 [00:00<00:00, 687.79 examples/s] Converting format of dataset (num_proc=16): 100%|█████████████████████████████████████████████████████████████████████████| 91/91 [00:00<00:00, 495.30 examples/s] Generating train split: 0 examples [00:00, ? examples/s] Generating train split: 1000 examples [00:00, 42466.65 examples/s] Converting format of dataset (num_proc=16): 0%| | 0/1000 [00:00<?, ? examples/s] Converting format of dataset (num_proc=16): 94%|████████████████████████████████████████████████████████████████▋ | 938/1000 [00:00<00:00, 8956.68 examples/s] Converting format of dataset (num_proc=16): 100%|████████████████████████████████████████████████████████████████████| 1000/1000 [00:00<00:00, 5587.08 examples/s] Running tokenizer on dataset (num_proc=16): 0%| | 0/1091 [00:00<?, ? examples/s] Running tokenizer on dataset (num_proc=16): 6%|████▍ | 69/1091 [00:00<00:08, 113.69 examples/s] Running tokenizer on dataset (num_proc=16): 13%|████████▊ | 138/1091 [00:00<00:04, 212.02 examples/s] Running tokenizer on dataset (num_proc=16): 19%|█████████████▎ | 207/1091 [00:01<00:04, 217.80 examples/s] Running tokenizer on dataset (num_proc=16): 25%|█████████████████▋ | 275/1091 [00:01<00:02, 276.83 examples/s] Running tokenizer on dataset (num_proc=16): 38%|██████████████████████████▎ | 411/1091 [00:01<00:01, 368.09 examples/s] Running tokenizer on dataset (num_proc=16): 44%|██████████████████████████████▋ | 479/1091 [00:01<00:01, 400.06 examples/s] Running tokenizer on dataset (num_proc=16): 56%|███████████████████████████████████████▍ | 615/1091 [00:01<00:00, 545.20 examples/s] Running tokenizer on dataset (num_proc=16): 63%|███████████████████████████████████████████▊ | 683/1091 [00:01<00:00, 533.73 examples/s] Running tokenizer on dataset (num_proc=16): 69%|████████████████████████████████████████████████▏ | 751/1091 [00:01<00:00, 517.06 examples/s] Running tokenizer on dataset (num_proc=16): 75%|████████████████████████████████████████████████████▌ | 819/1091 [00:02<00:00, 496.78 examples/s] Running tokenizer on dataset (num_proc=16): 88%|█████████████████████████████████████████████████████████████▎ | 955/1091 [00:02<00:00, 625.17 examples/s] Running tokenizer on dataset (num_proc=16): 94%|████████████████████████████████████████████████████████████████▋ | 1023/1091 [00:02<00:00, 606.56 examples/s] Running tokenizer on dataset (num_proc=16): 100%|█████████████████████████████████████████████████████████████████████| 1091/1091 [00:02<00:00, 434.44 examples/s] Traceback (most recent call last): File "/usr/local/bin/llamafactory-cli", line 8, in <module> sys.exit(main()) ^^^^^^ File "/mnt/workspace/LLaMA-Factory/src/llamafactory/cli.py", line 151, in main COMMAND_MAP[command]() File "/mnt/workspace/LLaMA-Factory/src/llamafactory/train/tuner.py", line 110, in run_exp _training_function(config={"args": args, "callbacks": callbacks}) File "/mnt/workspace/LLaMA-Factory/src/llamafactory/train/tuner.py", line 72, in _training_function run_sft(model_args, data_args, training_args, finetuning_args, generating_args, callbacks) File "/mnt/workspace/LLaMA-Factory/src/llamafactory/train/sft/workflow.py", line 52, in run_sft model = load_model(tokenizer, model_args, finetuning_args, training_args.do_train) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/workspace/LLaMA-Factory/src/llamafactory/model/loader.py", line 180, in load_model model = load_class.from_pretrained(**init_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/models/auto/auto_factory.py", line 571, in from_pretrained return model_class.from_pretrained( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/modeling_utils.py", line 309, in _wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/modeling_utils.py", line 4508, in from_pretrained model = cls(config, *model_args, **model_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/models/qwen2/modeling_qwen2.py", line 633, in __init__ self.model = Qwen2Model(config) ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/transformers/models/qwen2/modeling_qwen2.py", line 362, in __init__ self.post_init() File "/usr/local/lib/python3.11/site-packages/transformers/modeling_utils.py", line 1969, in post_init if v not in ALL_PARALLEL_STYLES: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type &#39;NoneType&#39; is not iterable
07-05
<think>好的,用户想使用LLaMA-Factory微调Qwen-VL模型。首先,我需要回忆一下LLaMA-Factory的文档和它支持的模型类型。根据引用[4],LLaMA-Factory支持的模型有限,而Qwen-VL是多模态模型,可能需要特定的适配。 用户提到的Qwen-VL应该属于QWEN2-VL系列,引用[2]和[3]提到了下载模型的方法,比如使用魔搭社区和snapshot_download函数。所以首先需要确保用户正确下载模型文件,并配置好路径。 接下来,LLaMA-Factory的配置文件是关键。用户需要修改配置文件,比如examples/inference/llama3_lora_sft.yaml,来指定模型路径和调整参数。可能需要设置model_name_or_path为下载Qwen-VL路径,并确认模型类型是否被支持。如果Qwen-VL不在默认支持列表中,可能需要自定义模型类型,或者调整代码。 数据准备部分,用户需要准备多模态数据集,可能包含图像和文本。需要确保数据格式符合LLaMA-Factory的要求,比如JSON或特定格式的文件。可能需要参考现有的多模态微调示例,或者根据文档调整数据加载部分。 运行微调命令,用户需要指定配置文件,可能还需要调整训练参数,比如学习率、批次大小等。引用[1]中的命令例子可能需要修改配置文件路径和参数。此外,多模态训练可能需要更多的显存,用户需要确保硬件资源足够,或者使用梯度累积等技术。 最后,验证微调后的模型是否有效,可能需要加载检查点并进行推理测试。如果过程中遇到不支持的情况,可能需要查阅LLaMA-Factory的GitHub问题或社区讨论,寻找类似问题的解决方案。 总结步骤:下载模型、配置参数、准备数据、运行训练、验证结果。同注意可能遇到的兼容性问题,必要修改代码或寻求社区帮助。</think>以下是使用LLaMA-Factory微调Qwen-VL模型的分步指南: ### 一、环境准备 1. 下载Qwen-VL模型 - 通过魔搭社区获取模型文件(需注册并完成实名认证)[^2] - 或使用Modelscope API下载: ```python from modelscope import snapshot_download model_dir = snapshot_download(&#39;qwen/Qwen2-VL&#39;, cache_dir=&#39;your/path&#39;)[^3] ``` 2. 安装依赖 ```bash git clone https://github.com/hiyouga/LLaMA-Factory pip install -r requirements.txt ``` ### 二、配置文件调整 修改`examples/training/qwen_vl_sft.yaml`: ```yaml model_name_or_path: /path/to/Qwen-VL # 替换实际模型路径 model_type: qwen-vl # 确认模型类型支持性 dataset_dir: /path/to/dataset ``` ### 三、数据准备 1. 多模态数据集格式建议: ```json { "image": "base64_image_string", "conversations": [ {"role": "human", "value": "请描述这张图片"}, {"role": "assistant", "value": "图片内容描述..."} ] } ``` ### 四、启动微调 ```bash CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/training/qwen_vl_sft.yaml[^4] ``` ### 五、验证结果 ```bash llamafactory-cli chat examples/inference/qwen_vl_lora.yaml --checkpoint /path/to/checkpoint[^1] ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

闲云野鹤01

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值