# 常见问题整理 下面是swift使用过程中遇到的一些常见问题。 ## 训练 ### Q1: Swift微调支持的模型和数据集有哪些? 详见文档[支持的模型和数据集](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E6%94%AF%E6%8C%81%E7%9A%84%E6%A8%A1%E5%9E%8B%E5%92%8C%E6%95%B0%E6%8D%AE%E9%9B%86.html)。 ### Q2: 使用自定义数据集训练时支持的数据格式有哪些? 自定义数据集格式见文档[自定义数据集](https://swift.readthedocs.io/zh-cn/latest/Customization/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E9%9B%86.html)。 ### Q3: 自定义数据集dataset_info.json格式,如何通过这种方式使用自定义数据集? dataset_info.json格式见文档[自定义数据集](https://swift.readthedocs.io/zh-cn/latest/Customization/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E9%9B%86.html)。命令行,`--custom_dataset_info xxx.json`,`--dataset `。 ### Q4: 如何在界面训练使用自定义数据集? 界面训练使用自定义数据集与命令行一致,参考文档[自定义数据集](https://swift.readthedocs.io/zh-cn/latest/Customization/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E9%9B%86.html)。 ### Q5: 数据集jsonl文件里的一行能不能写成这样?{"index": "00000", "query": "11111", "response": "22222", 'source':'qqq'} 可以有额外字段的,这些字段不会被使用。 ### Q6: 命令行参数在哪个文档中查看? 详见文档[命令行参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q7: 离线环境训练需要配置的参数有哪些? `--model 本地路径`,`--check_model false`,详见[命令行参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q8: model_type在哪儿查看? 查看文档[支持的模型和数据集](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E6%94%AF%E6%8C%81%E7%9A%84%E6%A8%A1%E5%9E%8B%E5%92%8C%E6%95%B0%E6%8D%AE%E9%9B%86.html)。 ### Q9: 模型训练完能直接转gguf格式吗? 目前只支持导出ModelFile,详见文档[命令行参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q10: swift支持预训练吗,我看只有sft? 支持,命令行`swift pt`,[预训练例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/pretrain),数据集格式见[自定义数据集](https://swift.readthedocs.io/zh-cn/latest/Customization/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E9%9B%86.html)。 ### Q11: 想问一下用lora微调的模型,如果想断点续训的话,是应该先把它合成一整个模型吗,还是可以不合起来,直接通过路径来指定原模型和lora块 不合并,`--resume_from_checkpoint output/xxx/vx-xxx/checkpoint-xxx`,详见[命令行参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q12: 我想控制一下从网上下载下来的原始模型权重的位置,怎么才能做到把原始的模型放在指定的文件夹里呢? 可以配置环境变量`MODELSCOPE_CACHE=your_path`将原始的模型存到指定路径;如果用sdk下载,通过`cache_dir="本地地址"`;也可以使用`modelscope download`命令行工具或`git`下载,详见modelscope文档[模型下载](https://modelscope.cn/docs/models/download)。训练时`--model`配置本地路径即可。如果需要在离线环境训练,配置`--check_model false`,详见[命令行参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q13: 有人在用ms-swift遇到过这个问题? ```text [rank6]: pydantic_core._pydantic_core.ValidationError: 1 validation error for DeepSpeedZeroConfig [rank6]: stage3_prefetch_bucket_size [rank6]: Input should be a valid integer, got a number with a fractional part [type=int_from_float,input_value=11560550.4,in put_type=float] [rank6]: For further information visit https://errors.pydantic.dev/2.8/v/int_fro_float ``` `deepspeed`版本降到`0.14.*`。 ### Q14: 有微调qwen-2-vl的完整的教程和命令行吗? 参考多模态模型训练的[例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/multimodal)。 ### Q15: 多模态大模型微调有什么支持的trick吗,类似llm的neftune? `piassa/olora/dora`这些`lora`的变种或者`fourierft`都可以尝试。参考`sft`参数里面的各种trick,有一些不一定在多模态上适用。 ### Q16: 训练过程中eval得到的acc和对应保存的ckpt去重新推理一遍计算得到的acc不是一致的 训练时候的eval_acc和推理时候的acc 计算方式不一样的。`acc_strategy`: 默认为`'token'`, 可选择的值包括: `'token'`, `'seq'`. ### Q17: 魔搭官方镜像与swift环境 `docker run`命令启动容器即可,如:`docker run --gpus all -p 8000:8000 -it -d --name ms modelscope-registry.cn-beijing.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.4.0-py311-torch2.6.0-1.26.0-LLM /bin/bash`,启动容器后拉最新代码安装swift。另外,针对大模型训练场景,提供了`ms-swift`镜像,额外增加了`Megatron-SWIFT`的依赖,如:`modelscope-registry.cn-beijing.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.4.0-py311-torch2.6.0-vllm0.8.5.post1-modelscope1.26.0-swift3.4.1.post1`,详见[swift安装文档](https://swift.readthedocs.io/zh-cn/latest/GetStarted/SWIFT%E5%AE%89%E8%A3%85.html)。 ### Q18: 多机多卡训练命令行 详见[多机多卡例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/multi-node) ### Q19: 如何选择template? 见[issue](https://github.com/modelscope/ms-swift/issues/1813)。 ### Q20: 多卡训练torchrun和swift sft如何使用? `swift sft`走的就是`torchrun`。 ### Q21: 有个问题,因为我的sft数据集太大了,然后每次tokenize都需要很久,有解决方案吗? 使用`lazy_tokenize`或流式读取`streaming`,详见[命令行参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q22: 训练时,如果两个数据集直接追加一起放在训练集中,模型在训练的时候内部会有shuffle的流程吗?还是按顺序取数据去训练? 命令行参数`dataset_shuffle`,详见[命令行参数文档](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q23: 如果模型两张卡,数据不开并行,deepspeed就会出现报错,怎么处理呢? `deepspeed` 和 `device_map`是不兼容的,两个只能选1个。 ### Q24: 在线训练时已经下载的数据集,离线重新训练为什么还要下载? 数据文件中有url,不支持离线训练。 ### Q25: vlm模型训练如何减少显存使用? 配置`--freeze_vit true`,以及限制最大像素的参数`--max_pixels`。 ### Q26: 为什么WEB-UI界面上支持的模型比文档中少? 升级一下ms-swift。 ### Q27: 没有适配model_type的模型,sft时可以自定义special_tokens和chat_template吗? 可以。参考接入模型的PR以及自定义模型数据集文档。 ### Q28: 可以在python脚本里面用DPO去训练qwen2-vl吗? 可以。从`swift.llm`中导入`rlhf_main` 和`RLHFArguments`。 ### Q29: 请问训练MLLM时,可否先进行纯文本的预训练,然后接入VQA数据集进行微调呢? 可以。也可以混着训练。 ### Q30: 基于qwen2的sft模型进行dpo训练,v100的机器,训练时都是Nan呢? V100机器要用fp32训练qwen2。 ### Q31: 想问一下,swift,能支持蒸馏吗? 参考这个[例子](https://github.com/modelscope/ms-swift/blob/main/examples/sampler/distill/distill.sh)。 ### Q32: 当前训练完默认最多保存两个checkpoint,如果想多保存几个应该怎么修改呢? `--save_total_limit`,详见[命令行参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html)。 ### Q33: Grounding任务中通用数据格式支持一个类别有多个实例吗? 目前均支持了一个物体对应多个bbox,参考文档[自定义数据集](https://swift.readthedocs.io/zh-cn/latest/Customization/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E9%9B%86.html#grounding)。 ### Q34: 这个错误为什么会出现在这,numpy.object找不到在哪? `numpy==1.26.3`,尝试一下。 ### Q35: swift框架能支持序列并行了吗? 支持。参考这里的[例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/long_text)。 ### Q36: 用v100微调qwen2-1.5B时,loss': 0.0, 'acc': 0.0, 'grad_norm': nan,是什么问题呢? 尝试用fp32。 ### Q37: gptq量化模型,能全参数微调吗? 不能。gptq模型的int型参数无法参与求导,只能附着lora等额外结构参与更新。 ### Q38: 请问如果想用qlora的方式微调的话应该如何设置参数呢?glm4-chat 参考qlora[例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/qlora)。 ### Q39: 请教一个问题,我应该如何在swift框架下扩充我的词表呢? swift目前还不支持词表扩充。 ### Q40: 同名的模型是可以直接使用huggingface上的吗? 设置环境变量`USE_HF=1`。 ### Q41: 请问Qwen2-VL-2B能进行增量预训练吗?有指导文件吗?有图文,也有纯文本的。 支持了,如果继续预训练将所有的内容放在response中就可以了。 ### Q42: 请问下用视频做训练的时候,如何在参数中控制抽帧率,设了frame_rate设不起, minicpmv 设置环境变量`MAX_NUM_FRAMES`。 ### Q43: swift在训练的时候,可以把验证集的推理结果保存下来吗? 训练结束后,运行swift infer,会保存。 ### Q44: 我全量full参数dpo,为何保存的checkpoint 比原本模型文件要大呢?整整大了1倍 用V100微调,存的是fp32类型。 ### Q45: 多机训练速度缓慢,在使用swift框架进行LLM训练时,发现采用deepspeed zero3训练会出现严重的速度下降问题 详见[issue](https://github.com/modelscope/ms-swift/issues/1825)。 ### Q46: swift现在是支持qwen2-vl多阶段预训练的吗?我看官方的最佳实践里的sft好像都是vit+llm一起训的,不知道支不支持单独finetune `--freeze_vit`,`--freeze_aligner`,`--freeze_llm`这几个参数可以控制,详见[命令行参数文档](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html#tuner)。 ### Q47: qwen2-vl是不是不支持混合纯文本数据? 支持图文和纯文本。 ### Q48: 微调的时候可以绘制不同数据集的loss曲线吗? 支持channel loss,参考这个[例子](https://github.com/modelscope/ms-swift/blob/main/examples/train/plugins/channel_loss.sh) ### Q49: 模型训练后,回复重复了很多内容 参考[预训练与微调](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E9%A2%84%E8%AE%AD%E7%BB%83%E4%B8%8E%E5%BE%AE%E8%B0%83.html)。如果训练过程中出现重复的情况,请多训练几个epoch, 清洗数据, 全参数训练, 采用RLHF的方式缓解。 ### Q50: 想问一下swift目前支持prompt tuning或者prefix tuning吗? 不支持,这两个方法知识遗忘比较严重,目前不推荐使用。 ### Q51: 两张A10训练报错如下: ```text [rank0]: torch.distributed.DistBackendError: NCCL error in:../torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp:1970, unhandled system error (run with NCCL_DEBUG=INFO for details),NCCL version 2.20.5 [rank0]:ncclSystemError: System call (e.g. socket,malloc) or external library call failed or device error. ``` 请检查共享内存是否太小,nccl需要共享内存。 ### Q52: 请问在采用DDP微调训练的过程中,冻结某些层时导致的某些参数未参与梯度回传问题怎么解决? 配置参数`--ddp_find_unused_parameters true`。 ### Q53: swift有没有数据集质检工具? [data-juicer](https://github.com/modelscope/data-juicer)。 ### Q54: web端在哪启动模型并行?只找到了数据并行的勾选项,没找到模型并行在哪。 指定可见显卡就可以。 ### Q55: 设置--dataset的话,怎么让数据集下载到固定位置,我在命令行参数没找到,下次如果再次读取的话如何可以从下载的地方读取 `dataset_path`支持文件夹,一般是`git clone`下载下来的数据集文件夹。详见[自定义数据集文档](https://swift.readthedocs.io/zh-cn/latest/Customization/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E9%9B%86.html#dataset-info-json)。 ### Q56: --streaming true,我设置num_train_epochs会报错让我设置max_steps。不可以只设置num_train_epochs吗? 详见`streaming`参数说明,[命令行参数文档](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html#id4)。 ### Q57: 好奇tools为啥是"[]",不是直接支持[]呢,能否帮忙解答一下,这个tools为啥是"[]"这种格式呢,不是直接使用[]呢,有些不理解 这是因为datasets的底层pyarrow对于类型管控比较严格。我们官方的grounding数据集的objects部分也是因为这个原因要用str,要不pyarrow就会报错:你每行的类型不一致。 ### Q58: 这个参数不能用吗?check_dataset_strategy==discard swift3.0没这个参数了,用`strict`参数。 ### Q59: 运行sft命令出现报错如下: ```text RuntimeError: Expected to mark a variable ready only once.This error is caused by one of the following reasons: 1) Use of a module parameter outsid forward function. Please make sure model parameters are not shared across multiple concurrent forward-backward passes. or try to use _set_static_graph( ) as round if this module graph does not change during training loop.2) Reused parameters in multiple reentrant backward passes. For example, if you use multiple oint` functions to wrap the same part of your model, it would result in the same set of parameters been used by different reentrant backward passes multiple and hence marking a variable ready multiple times. DDP does not support such use cases in default. You can try to use _set_static_graph( ) as a workaround if dule graph does not change over iterations. ``` 加一下这个参数,`--gradient_checkpointing_kwargs '{"use_reentrant": false}'`。 ### Q60: 有遇到过这个问题嘛?AttributeError:’TrainerState’ object has no attribute ’last_model_checkpoint’ 数据集太少了,增加一些。数据数量不足一个step导致的报错。 ### Q61: 我看到custompreprocessor里面可以定义preprocess,这个是在训练开始前全部会处理好,还是一边训练一边加载的啊 如果设置了参数`--streaming true`,就是一边训练一边加载。默认是全部处理完然后训练。 ### Q62: 全参数训练internvl2_5,为啥里面的 freeze parameters默认就有vision_model 和 mlp1?我看命令行参数的文档里面freeze parameters默认为[],命令中显示设置 freeze vit, freeze aligner, freeze llm都为False,又会打印出来trainable parameters:[‘mlp1’] 也不知道是指只有mlp1可以train 还是 所有的paras都可以train 只是mlp1打印一下 先freeze parameters再active parameters。`freeze vit/freeze aligner/freeze llm`这三个参数会对freeze parameters 和trainable parameters进行调整.因为有些模型的`vit`中包含`aligner`,所以会将`aligner`单独加入trainable_parameters。 ### Q63: 请问swift中的llamapro对多模态做适配了吗? 支持的。 ### Q64: 我发现2.x支持MAX_PIXELS,3.x文档里有个--max_pixel参数是一个意思吗,他的处理逻辑是啥样的?我用12000*9000的图片,2.x设置resacle_image训练internvl还是会崩 环境变量的参数是对应模型的参数,`MAX_PIXELS`只支持qwen2vl的,internvl有自己的环境变量参数,详见[特定模型参数](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html#id18)。 ### Q65: 从qwen base模型微调成chat模型有没有实践文档,有什么要特别配置的吗? A: `swift sft`,没有其他需要特别配置的,参考[例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/base_to_chat)。 ### Q66: sequence parallel例子在哪呀? A: 看这个例子[sequence_parallel](https://github.com/modelscope/ms-swift/tree/main/examples/train/long_text)。 ### Q67: swift能支持训练自己定义的模型结构吗? 可以的,只需要自定义`get_model_tokenizer_xxx`函数就好了,返回`model`和`tokenizer`。 ### Q68: 我用"name_or_path": "/mnt/workspace/model/Qwen2.5-14B-Instruct"跑longlora 发现出现了报错,不会是只有个llama系列可以使用longlora吧 只有llama系列能用`longlora`。 ### Q69: 想问下swift怎么加入自己的special token? 在`get_model_tokenizer`函数中增加。 ### Q70: --freeze_parameters_ratio这个参数,如果设定为0.7,是不是说明训练的时候只更新llm的30%的参数?是随机更新30%吗,这个参数更新的机制是什么呀? 从下往上freeze。 ### Q71: map过程为啥这么慢,这是正常的吗? ```text Map: 4%|██ | 9000/203823 [02:18<50:34, 64.19 examples/s] ``` 设置参数`--dataset_num_proc`可以开多进程。 ### Q72: 请问数据集如何能够删除重新下载,感觉数据集出了点问题 设置参数`--download_mode`。 ### Q73: 请问这个问题如何解决?safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge 磁盘空间不足了,模型没有保存完整。 ### Q74: swift3.0不支持get_default_template_type是吗? 请查看`model.model_meta.template`,信息都存在`model.model_meta和model.model_info`。 ### Q75: 魔搭swift微调支持herms格式的agent微调嘛,我看qwen2.5使用vllm原生支持hermes格式的工具调用,怎么swift上没有看到相关的 目前没有支持`hermes`格式,主要还是`toolbench`和`react`两个格式,因为`react`应用比较广泛一些,目前swift的deploy也支持解析这两种格式并给出`openai tool calling`的。 ### Q76: 请问默认模型训练都是left padding是吧? 训练可以选择使用左padding还是右padding。默认是右padding, `batch infer`都是左padding。 ### Q77: 请问下现在支持grounding任务了吗 examples下有[例子](https://github.com/modelscope/ms-swift/blob/main/examples/train/multimodal/grounding.sh)。 ### Q78: 请问现在ms-swift支持对比学习,从而训练llm_emb吗? 支持,[例子](https://github.com/modelscope/ms-swift/blob/main/examples/train/embedding)。 ### Q79: 话说直接从peft和trl库,手搓微调和grpo代码和swift官方在同参数下进行训练,效果差异大吗? 区别不大,额外支持了多模态。 ### Q80: swift 目前不支持 minicpmo2_6 使用音频模态输入的训练吗?会报错: assert media_type in {'image', 'video'} 目前不支持音频。 ### Q81: swift可以微调deepseek R1 671B吗? 可以,template是接入了的,不过过程会比较麻烦,要先fp8转bf16。 ### Q82: 最新的swift框架不是通过这个命令来指定模型的位置的么?这是我已经下载好的模型位置,不知道为什么还要下载,还下不下来,提示报错git clone ```shell --model /mnt/workspace/.cache/modelscope/hub/deepseek-ai/deepseek-vl2/ \ ``` 有些需要clone repo,然后通过`local_repo_path`指定。 ### Q83: swift现在支持多模态的grpo吗? 支持。 ### Q84: grpo的reward函数支持自己定义么? 支持,参考[examples/train/grpo/plugin](https://github.com/modelscope/ms-swift/tree/main/examples/train/grpo/plugin)。 ### Q85: 请问为什么 --torch_dtype float16 (卡不能使用bf16)会出现报错:lib/python3.12/site-packages/torch/amp/grad_scaler.py", line 260, in _unscale_grads_ raise ValueError("Attempting to unscale FP16 gradients.") ValueError: Attempting to unscale FP16 gradients. 全参数,不能fp16训练的。 ### Q86: 请教一个问题。我用swift训练了一个reward模型(基线是qwen2.5-7b),然后用在ppo或者grpo中加载会报错。reward模型是lora训练的。 ```shell --rlhf_type ppo \ --model Qwen/Qwen2.5-14B-Instruct \ --reward_model /mnt/workspace/output/rm/model --train_type lora \ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#20000' --torch_dtype float32 --num_train_epochs 1 \ --per_device_train_batch_size 1 --per_device_eval_batch_size 1 --learning_rate 1e-5 --lora_rank 8 --lora_alpha 32 \ --target_modules all-linear \ --gradient_accumulation_steps 16 --eval_steps 100 --save_steps 100 \ ``` lora训练的reward model需要merge一下。 ### Q87: 各位大佬,请问要微调deepseek_vl2,transformers用什么什么版本?官方文档说<4.42,但是4.42及以下也报错。peft版本也要降低吗? `peft==0.11.*`。 ### Q88: 请问generate train split太慢了有没有什么好办法呀(大概有30多个数据集,总数据量百万左右)。之前swift 2.x好像没有这么慢。lazy tokenize 已经开了 设置`--dataset_num_proc 16`。 ### Q89: 请问下微调qwen2.5vl的时候,我想使用全参数微调visual encoder同时使用LoRA微调LLM,怎么实现呢? 参考这里[例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/multimodal/lora_llm_full_vit)。   ### Q90: 问一下,swift怎么使用自定义的损失函数? plugin中加就可以了。 ### Q91: 请问下MoE的参数有哪些,参数表里关键字搜索不到?专家数量,专家路由这些参数怎么设置? 直接用config.json中的参数。 ### Q92: grpo训练中使用lmdeploy会报相关函数不存在的问题,想请教下具体问题,在lmdeployengine类里面确实没找到load_weights这个函数 只在turbomind引擎下支持。 ### Q93: Moonlight-16B-A3B-Instruct, 我在微调这个模型的时候报错怎么办?ms-swift好像不支持这个模型进行微调 因为是模型文件中禁止了训练, 参考deepseek_vl2的解决方案,你搜搜issue。 ### Q94: 训练时出了这个错应该咋解决?RuntimeError: “triu_tril_cuda_template“ not implemented for ‘BFloat16' ```shell CUDA_VISIBLE_DEVICES=01,2,3,4,5,6,7 \ swift sft \ --model Internlm3-8b \ --dataset train.json \ --train_type full \ --torch_dtype bfloat16 \ --num_train_epochs 5 \ --per_device_train_batch_size 1 \ --deepspeed zero3 \ --per_device_eval_batch_size 1 \ --learning_rate 1e-4 \ --gradient_accumulation_steps 16 \ --eval_steps 100 \ --save_steps 100 \ --save_total_limit 5 \ --logging_steps 5 \ --max_length 2048 \ --output_dir output \ --warmup_ratio 0.05 \ --dataloader_num_workers 4 ``` 升级torch。 ### Q95: grpo训练,loss和grad_norm全是0,正常的吗? ```text {'loss': 0.0. 'grad norm':0.0, 'learning_rate':9e-08, 'memory(GiB)':88.1, 'train_speed(iter/s)':0.009252, 'completion_length': 150.00000763, 'response_clip ratio': 0.0, 'rewards/Format':1.0, 'reward : 1.0, 'reward std':0.0, 'kl': 0.0, 'clip_ratio': 0.0, 'epoch': 0.0, 'qlobal step/max steps':'1/1052', 'percentage':'0.10% 'elapsed time': '36s 'remaining time': '10h 43m 54s'} {'loss': 0.0,'grad_norm':0.0,'learning_rate': 1.8e-07,'memory(GiB)':94.15,'train_speed(iter/s)':0.014782,'completion_length': 133.25000763,'response_clip_ratio': 0.0,'rewards/Format': 1.0, 'rewa rd': 1.0,'reward_std': 0.0, 'kl': 0.0,'clip_ratio': 0.0,'epoch': 0.0, 'global_step/max_steps': '2/1052','percentage': '0.19%', 'elapsed_time': '1m 3s', 'remaining_time': '9h 19m 49s'} {'loss': 0.0, 'qrad norm': 0.0, 'learning rate': 2.7e-07,'memory(GiB)': 94.15,'train_speed(iter/s)': 0.018695,'completion_length': 123.08333969,,'response_clip_ratio': 0.0,'rewards/Format': 1.0, 'rewa rd': 1.0, 'reward_ std': 0.0,'kl': 0.0,'clip_ratio': 0.0, 'epoch': 0.0, 'global_step/max_steps': '3/1052','percentage': '0.29%,'elapsed_time': '1m 29s','remaining_time': '8h 39m 34s'} ``` 训练过程中loss接近0是正常情况,参考[issue](https://github.com/huggingface/open-r1/issues/239#issuecomment-2646297851)。 ### Q96: 请教一下这个grpo的内置奖励函数,从哪里可以传入accuracy_orm 目前是直接改代码。 ### Q97: 我看这奖励函数有solution参数,是要从数据集里面传过来吗?就是我数据集必须有solution这项? 是的,针对math问题,不然不好算accuracy。 ### Q98: 训练为什么没有token_acc? 有些模型`logits`和`labels`数量对不上,就不算的。 ### Q99: 微调Ovis2 使用lora参数不起作用?加不加--train_type lora \,好像都是全参数微调?显存没变化。 `--max_length`限制一下,这个模型有点特殊,需要padding到max_length。 ### Q100: 请问下用qwen2.5跑一个分类任务,抱下面的错误,是哪里配置的有问题呢?ValueError: The model did not return a loss from the inputs, only the following keys: logits. For reference, the inputs it received are input_ids,attention_mask. 数据集是这样的:{"messages": [{"role": "user", "content": "xxxxx"}, {"label": 1}]} `label`写在`message`同级。 ### Q101: 启动了VllmEngine,要如何退出呀?就是调用了engine,模型就被载入显存准备工作。但是我推理完想要engine释放显存。下次调用时,再加载。而不是一直占用 sleep mode啊,支持的。`engine.sleep(level=1)/engine.wake_up()`,构造的时候加一个`enable_sleep_mode=True`。 ### Q102: 求问,streaming模式下,trainer_sampler_random是不是就没有作用了呢? streaming是不随机的。 ### Q103: 请问grpo使用vllm进行推理,vllm可以设置trust_rwmote_code吗? 默认就是true的。 ### Q104: 请教一下,pretrain阶段数据集比较大,用了streaming流式和packing打包数据,这时候需要设置 max_steps,有没有参数或者命令可以根据epochs、bs等参数计算打包后的总的steps吗? 设置`--max_steps`或`--max_epochs`,详见[命令行参数文档](https://swift.readthedocs.io/zh-cn/latest/Instruction/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0.html#id4)streaming参数说明。 ### Q105: unsloth训练,报错:assert(type(target modules) in (list,tuple,))。配置的参数是--target modules all-linear 别用`all-linear`,改为具体的模块列表,比如`--target_modules q k v`。 ### Q106: Swift现在支持多标签分类么? 支持的。自定义数据集文档有格式,然后在命令行参数文档中搜索一下`problem_type`,改一下,其他和回归是一样的。 ### Q107: 请问packing中flash_attn是分开处理的还是合并处理的? 一定需要flash_attn,不然是有误差,attention_mask会出问题。 ### Q108: 请问对于qwen2.5-omni来说--freeze_vit false意味这视觉编码器和音频编码器都打开了,有什么办法可以只打开音频编码器不打开视觉编码器吗? `--target_regex`写一下。 ### Q109: 请问现在swift的强化学习那几种训练方法支持序列并行么? 支持pt, sft, dpo and grpo。 ### Q110: 使用 lora sft之后是不会储存tokenizer.json吗 lora不会存储,merge后才会把这些文件迁移过来,因为lora目录需要配合原模型使用。 ### Q111: GRPO 的reward_model 和 reward_funcs可以一起用吗? 可以。 ### Q112: 想请教一下,在进行GRPO时不打算引入KL项,有相关的参数可以调整吗? 命令行参数搜一下beta。 ### Q113: 请教一个问题,做grpo的时候,如何在orm的自定义奖励函数中获取原始标签呢?我打印了kwargs的messages字段,里面的每一项的assistant的content的值已经被替换成生成的结果了 放到另外的列里。 ### Q114: 默认只用 num_iterations=1 的话,clip 就失去作用了吧?dapo 的 clip higher 也没用。我看 veRL 有个 micro batch 可以设置单轮小批次更新 policy model 来使得 clip 项生效,ms-swift 的 mini batch 看源码貌似只是做了梯度累加? 是的,需要num_iterations>1。 ### Q115: 请问qwen2.5-omni的训练支持全参训练吗,是否支持talker的训练? 目前不支持talker训练,只有thinker。 ### Q116: 请问,sequence parallel是否可以和liger kernel同时启用呀? 可以。 ### Q117: 请问ppo训练rm和policy有什么要求呢? 现在ppo还只支持rm和policy是同一系列的模型(tokenizer/template)。 ### Q118: 还想问一下,由于llama3.1没有小于8B的模型,因此我想用3.2 1B的的来微调,那么还能用Llama-3.1这个奖励模型吗? 要求是`template`和`tokenizer`要一样, 3.1 和 3.2 应该问题不大。 ### Q119: 请问swift是否能缓存一份mappiing之后的数据?方便排查训练数据的问题 设置`--load_from_cache_file false`。 ### Q120: 全参数训练为啥会有warning: none of the inputs have requires_grad=True? 如果vit没有训练,那有这个warning是正常的,如果训练了,则不应该抛出。 ### Q121: 现在qwen2.5vl ulysses支持sdpa吗? vl模型的目前仅支持flash-attn,纯文本两种都支持。 ### Q122: 请问这图片列表形式的videos现在支持了吗?格式如下 ```json {"messages": [{"role": "assistant", "content": "