Skip to content

Commit c69cbaa

Browse files
committed
Merge branch 'main' into release/3.3
2 parents 1e48900 + ecea03e commit c69cbaa

File tree

26 files changed

+661
-54
lines changed

26 files changed

+661
-54
lines changed

docs/source/Instruction/命令行参数.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ qwen2_5_omni除了包含qwen2_5_vl和qwen2_audio的模型特定参数外,还
584584
- MAX_NUM: 默认为12
585585
- INPUT_SIZE: 默认为448
586586

587-
### internvl2, internvl2_phi3, internvl2_5
587+
### internvl2, internvl2_phi3, internvl2_5, internvl3
588588
参数含义可以查看[这里](https://modelscope.cn/models/OpenGVLab/InternVL2_5-2B)
589589
- MAX_NUM: 默认为12
590590
- INPUT_SIZE: 默认为448

docs/source/Instruction/常见问题整理.md

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,139 @@ examples下有[例子](https://github.com/modelscope/ms-swift/blob/main/examples
290290
### Q89: 请问为什么 --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.
291291
全参数,不能fp16训练的。
292292

293+
### Q90: 请教一个问题。我用swift训练了一个reward模型(基线是qwen2.5-7b),然后用在ppo或者grpo中加载会报错。reward模型是lora训练的。
294+
```shell
295+
--rlhf_type ppo \
296+
--model Qwen/Qwen2.5-14B-Instruct \
297+
--reward_model /mnt/workspace/output/rm/model --train_type lora \
298+
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#20000' --torch_dtype float32 --num_train_epochs 1 \
299+
--per_device_train_batch_size 1 --per_device_eval_batch_size 1 --learning_rate 1e-5 --lora_rank 8 --lora_alpha 32 \
300+
--target_modules all-linear \
301+
--gradient_accumulation_steps 16 --eval_steps 100 --save_steps 100 \
302+
```
303+
lora训练的reward model需要merge一下。
304+
305+
### Q91: 各位大佬,请问要微调deepseek_vl2,transformers用什么什么版本?官方文档说<4.42,但是4.42及以下也报错。peft版本也要降低吗?
306+
`peft==0.11.*`
307+
308+
### Q92: 请问generate train split太慢了有没有什么好办法呀(大概有30多个数据集,总数据量百万左右)。之前swift 2.x好像没有这么慢。lazy tokenize 已经开了
309+
设置`--dataset_num_proc 16`
310+
311+
### Q93: 请问下微调qwen2.5vl的时候,我想使用全参数微调visual encoder同时使用LoRA微调LLM,怎么实现呢?
312+
参考这里[例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/multimodal/lora_llm_full_vit)
313+
 
314+
### Q94: 问一下,swift怎么使用自定义的损失函数?
315+
plugin中加就可以了。
316+
317+
### Q95: 请问下MoE的参数有哪些,参数表里关键字搜索不到?专家数量,专家路由这些参数怎么设置?
318+
直接用config.json中的参数
319+
320+
### Q96: grpo训练中使用lmdeploy会报相关函数不存在的问题,想请教下具体问题,在lmdeployengine类里面确实没找到load_weights这个函数
321+
只在turbomind引擎下支持。
322+
323+
### Q97: Moonlight-16B-A3B-Instruct, 我在微调这个模型的时候报错怎么办?ms-swift好像不支持这个模型进行微调
324+
因为是模型文件中禁止了训练, 参考deepseek_vl2的解决方案,你搜搜issue。
325+
326+
### Q98: 训练时出了这个错应该咋解决?RuntimeError: “triu_tril_cuda_template“ not implemented for ‘BFloat16'
327+
```shell
328+
CUDA_VISIBLE_DEVICES=01,2,3,4,5,6,7 \
329+
swift sft \
330+
--model Internlm3-8b \
331+
--dataset train.json \
332+
--train_type full \
333+
--torch_dtype bfloat16 \
334+
--num_train_epochs 5 \
335+
--per_device_train_batch_size 1 \
336+
--deepspeed zero3 \
337+
--per_device_eval_batch_size 1 \
338+
--learning_rate 1e-4 \
339+
--gradient_accumulation_steps 16 \
340+
--eval_steps 100 \
341+
--save_steps 100 \
342+
--save_total_limit 5 \
343+
--logging_steps 5 \
344+
--max_length 2048 \
345+
--output_dir output \
346+
--warmup_ratio 0.05 \
347+
--dataloader_num_workers 4
348+
```
349+
升级torch。
350+
351+
### Q99: 支持自定义reward吗?
352+
支持,看这里的[例子](https://github.com/modelscope/ms-swift/tree/main/examples/train/grpo/plugin)
353+
354+
### Q100: grpo训练,loss和grad_norm全是0,正常的吗?
355+
```text
356+
{'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
357+
: 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'}
358+
{'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'}
359+
{'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'}
360+
```
361+
训练过程中loss接近0是正常情况,参考[issue](https://github.com/huggingface/open-r1/issues/239#issuecomment-2646297851)
362+
363+
### Q101: 请教一下这个grpo的内置奖励函数,从哪里可以传入accuracy_orm
364+
目前是直接改代码。
365+
366+
### Q102: 我看这奖励函数有solution参数,是要从数据集里面传过来吗?就是我数据集必须有solution这项?
367+
是的,针对math问题,不然不好算accuracy。
368+
369+
### Q103: 训练为什么没有token_acc?
370+
有些模型`logits``labels`数量对不上,就不算的。
371+
372+
### Q104: 微调Ovis2 使用lora参数不起作用?加不加--train_type lora \,好像都是全参数微调?显存没变化。
373+
`--max_length`限制一下,这个模型有点特殊,需要padding到max_length。
374+
375+
### Q105: 请问下用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.
376+
数据集是这样的:{"messages": [{"role": "user", "content": "xxxxx"}, {"label": 1}]}
377+
`label`写在`message`同级。
378+
379+
### Q106: 有人知道这是哪错了吗?训练方法是vera
380+
```text
381+
KeyError("The 'metric_for_best_model' training argument is set to 'eval_loss', which is not found in the evaluati on metrics. The available evaluation metrics are:['eval_runtime', 'eval_samples_per_second', 'eval_steps_per_sec ond', 'epoch', 'global_step/max_steps', 'percentage', 'elapsed_time', 'remaining_time']. consider changing the 'metric_for_best_model' via the TrainingArguments.")
382+
Train: 45%| 100/220[09:47<11:44,5.87s/it]
383+
```
384+
```shell
385+
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
386+
swift sft \
387+
    --model Qwen/Qwen2.5-7B-Instruct \
388+
    --dataset '/mnt/workspace/data.json' \
389+
    --train_type vera \
390+
    --torch_dtype bfloat16 \
391+
    --num_train_epochs 4 \
392+
    --per_device_train_batch_size 1 \
393+
    --learning_rate 1e-4 \
394+
    --gradient_accumulation_steps 16 \
395+
    --eval_steps 100 \
396+
    --save_steps 100 \
397+
    --save_total_limit 5 \
398+
    --logging_steps 5 \
399+
    --max_length 4096 \
400+
    --warmup_ratio 0.05 \
401+
    --output_dir output/Qwen2.5-7B-vera \
402+
```
403+
`--label_names labels`,加这个参数。
404+
405+
### Q107: 启动了VllmEngine,要如何退出呀?就是调用了engine,模型就被载入显存准备工作。但是我推理完想要engine释放显存。下次调用时,再加载。而不是一直占用
406+
sleep mode啊,支持的。`engine.sleep(level=1)/engine.wake_up()`,构造的时候加一个`enable_sleep_mode=True`
407+
408+
### Q108: 求问,streaming模式下,trainer_sampler_random是不是就没有作用了呢?
409+
streaming是不随机的。
410+
411+
### Q109: 请问grpo使用vllm进行推理,vllm可以设置trust_rwmote_code吗?
412+
默认就是true的。
413+
414+
### Q110: 请教一下,pretrain阶段数据集比较大,用了streaming流式和packing打包数据,这时候需要设置 max_steps,有没有参数或者命令可以根据epochs、bs等参数计算打包后的总的steps吗?
415+
会按`epochs``max_steps`两者较小的结束训练。
416+
417+
### Q111: unsloth训练,报错:assert(type(target modules) in (list,tuple,))。配置的参数是--target modules all-linear
418+
别用`all-linear`,改为具体的模块列表,比如`--target_modules q k v`
419+
420+
### Q112: Swift现在支持多标签分类么?
421+
支持的。自定义数据集文档有格式,然后在命令行参数文档中搜索一下`problem_type`,改一下,其他和回归是一样的。
422+
423+
### Q113: 请问packing中flash_attn是分开处理的还是合并处理的?
424+
一定需要flash_attn,不然是有误差,attention_mask会出问题。
425+
293426
## 推理
294427

295428
### Q1:swift推理有文档吗?
@@ -406,6 +539,23 @@ swift infer \
406539
```
407540
`--stream true`,这样可以一条条写,不过是非batch推理的。
408541

542+
### Q32: 我在swift训练推理的时候是有效果的,但是用merge_lora后再通过ollama的api开接口的时候效果就没了
543+
试试transformers加载,swift的template是对齐transformers的。
544+
545+
### Q33: 模型推理的时候如果需要在特定前缀下继续推理的话是设置哪个参数?
546+
参数`--response_prefix`
547+
548+
### Q34: 一直报这个错怎么改呀?
549+
```text
550+
File "/mnt/workspace/swift/swift/1lm/dataset/preprocessor/core. py", line 69, in _check_messages raise
551+
ValueError(f'assistant_message; {assistant_message}')
552+
ValueError: assistant_message: {'role' :'assistant', 'content': ''}
553+
```
554+
```shell
555+
CUDA_VISIBLE_DEVICES=0 NPROC_PER_NODE=1 MAX_PIXELS=1003520 swift sft --model Qwen/Qwen2.5-VL-7B-Instruct --train_type lora --dataset /mnt/workspace/data.json --deepspeed zero2 --max_length 16384
556+
```
557+
数据集assistant字段为空,如果是推理,把这个空字符串删掉,因为这个会导致训练时nan,会做检查。
558+
409559
## 部署
410560

411561
### Q1: 如何部署训练后的模型?
@@ -456,6 +606,9 @@ RAY_memory_monitor_refresh_ms=0 CUDA_VISIBLE_DEVICES=1 nohup swift deploy --ckpt
456606
### Q14: swift部署好多模态模型之后,客户端传PIL.Image,有示例没?
457607
看这个[client例子](https://github.com/modelscope/ms-swift/blob/main/examples/deploy/client/mllm/openai_client.py)
458608

609+
### Q15: 请问 deploy部署时候,设置什么参数可以实现一次输出,输出多个结果呢?
610+
`RequestConfig`参数`n`
611+
459612
## 评测
460613

461614
### Q1: swift支持的评测集有哪些?
@@ -520,3 +673,41 @@ ceval这种多选题的评测是通过计算每个选项的logits来得到的,
520673

521674
### Q12: 我想用evalscope压测一下我的模型,想采用prompt.txt文件的形式,这个文件内容的格式应该是什么样子的呀?
522675
配置line_by_line,详见[文档](https://evalscope.readthedocs.io/zh-cn/latest/user_guides/stress_test/parameters.html#id5)
676+
677+
### Q13: 使用evalscope perf进行模型推理性能压测,parallel和number这两个参数怎样使用呢?
678+
number是请求的总数量,parallel是并发数量。
679+
680+
### Q14: 问一下评估swift eval里,模型最多生成1024token就结束了,这个如何修改?设置--max_new_tokens 5000,看起来没起作用
681+
swift里面这个参数还没透出,可以使用evalscope来运行,model里面配置max_tokens参考[文档](https://evalscope.readthedocs.io/zh-cn/latest/user_guides/backend/vlmevalkit_backend.html#id6)
682+
683+
### Q15: 请问evalscope现在支持deepseek-r1 的相关benchmark吗?AIME、MATH-500这样
684+
支持的,这里有[最佳实践](https://evalscope.readthedocs.io/zh-cn/latest/best_practice/deepseek_r1_distill.html)
685+
686+
### Q16: 想问一下evalscope测评gpqa使用本地路径报错: ValueError: BuildingConfig 'gpqa_extended' not found. Available: ['default']
687+
参数配置如下:
688+
```shell
689+
--datasets gpqa --dataset-args '{"gpqa": {"local_path": "/mnt/workspace/gpqa"} }'
690+
```
691+
数据集如果要下载到本地使用,建议从modelscope上克隆仓库再指定路径。
692+
693+
### Q17: 用evalscope评测arc数据集的时候,报这个错误,这是什么原因呢,用的是加载本地数据路径方式
694+
```text
695+
KeyError: 'RequestId'
696+
```
697+
```shell
698+
--datasets arc --dataset-args '{"arc": {"local_path": "/mnt/workspace/arc"}}'
699+
```
700+
参考[文档](https://evalscope.readthedocs.io/zh-cn/latest/get_started/basic_usage.html#id10),arc数据集本身需要通过py脚本来下载数据,直接clone仓库不行。
701+
702+
### Q18: 请教一下,想使用opencompass的后端评测,如何从本地加载下载好的数据集?
703+
opencompass后端不支持设置`data_args`
704+
705+
### Q19: swift eval 来评估模型,--eval_backend OpenCompass不支持自定义数据集吗?
706+
```text
707+
ValueError: eval_dataset: /mnt/workspace/data.jsonl is not supported.
708+
eval_backend: OpenCompass supported datasets: ['C3', 'summedits', 'WiC', 'csl', 'lambada', 'mbpp', 'hellaswag', 'ARC_e', 'math', 'nq', 'race', 'MultiRC', 'cmb', 'ceval', 'GaokaoBench', 'mmlu', 'winogrande', 'tnews', 'triviaqa', 'CB', 'cluewsc', 'humaneval', 'AX_g', 'DRCD', 'RTE', 'ocnli_fc', 'gsm8k', 'obqa', 'ReCoRD', 'Xsum', 'ocnli', 'WSC', 'siqa', 'agieval', 'piqa', 'cmnli', 'cmmlu', 'eprstmt', 'storycloze', 'AX_b', 'afqmc', 'strategyqa', 'bustm', 'BoolQ', 'COPA', 'ARC_c', 'PMMEval', 'chid', 'CMRC', 'lcsts']
709+
```
710+
opencompass不支持自定义数据集,用native可以自定义模式。
711+
712+
### Q20: 我在本地用单张A100运行模型来做evalscope官方文档里的RAGAS评测任务(https://evalscope.readthedocs.io/zh-cn/latest/user_guides/backend/rageval_backend/ragas.html)时,跑文档中的两个样例花费了10分钟的时间,请问这是正常的么?有没有什么办法可以优化运行速度。
713+
rag评测本身确实比较耗资源,使用本地critic llm确实会慢一些,处理不了batch请求,建议用vllm这样的框架来拉起任务。

docs/source/Instruction/支持的模型和数据集.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,13 @@
620620
|[OpenGVLab/InternVL2_5-26B-MPO](https://modelscope.cn/models/OpenGVLab/InternVL2_5-26B-MPO)|internvl2_5|internvl2_5|transformers>=4.36, timm|&#x2718;|vision, video|[OpenGVLab/InternVL2_5-26B-MPO](https://huggingface.co/OpenGVLab/InternVL2_5-26B-MPO)|
621621
|[OpenGVLab/InternVL2_5-38B-MPO](https://modelscope.cn/models/OpenGVLab/InternVL2_5-38B-MPO)|internvl2_5|internvl2_5|transformers>=4.36, timm|&#x2718;|vision, video|[OpenGVLab/InternVL2_5-38B-MPO](https://huggingface.co/OpenGVLab/InternVL2_5-38B-MPO)|
622622
|[OpenGVLab/InternVL2_5-78B-MPO](https://modelscope.cn/models/OpenGVLab/InternVL2_5-78B-MPO)|internvl2_5|internvl2_5|transformers>=4.36, timm|&#x2718;|vision, video|[OpenGVLab/InternVL2_5-78B-MPO](https://huggingface.co/OpenGVLab/InternVL2_5-78B-MPO)|
623+
|[OpenGVLab/InternVL3-1B](https://modelscope.cn/models/OpenGVLab/InternVL3-1B)|internvl3|internvl2_5|transformers>=4.37.2, timm|&#x2718;|vision, video|[OpenGVLab/InternVL3-1B](https://huggingface.co/OpenGVLab/InternVL3-1B)|
624+
|[OpenGVLab/InternVL3-2B](https://modelscope.cn/models/OpenGVLab/InternVL3-2B)|internvl3|internvl2_5|transformers>=4.37.2, timm|&#x2718;|vision, video|[OpenGVLab/InternVL3-2B](https://huggingface.co/OpenGVLab/InternVL3-2B)|
625+
|[OpenGVLab/InternVL3-8B](https://modelscope.cn/models/OpenGVLab/InternVL3-8B)|internvl3|internvl2_5|transformers>=4.37.2, timm|&#x2718;|vision, video|[OpenGVLab/InternVL3-8B](https://huggingface.co/OpenGVLab/InternVL3-8B)|
626+
|[OpenGVLab/InternVL3-9B](https://modelscope.cn/models/OpenGVLab/InternVL3-9B)|internvl3|internvl2_5|transformers>=4.37.2, timm|&#x2718;|vision, video|[OpenGVLab/InternVL3-9B](https://huggingface.co/OpenGVLab/InternVL3-9B)|
627+
|[OpenGVLab/InternVL3-14B](https://modelscope.cn/models/OpenGVLab/InternVL3-14B)|internvl3|internvl2_5|transformers>=4.37.2, timm|&#x2718;|vision, video|[OpenGVLab/InternVL3-14B](https://huggingface.co/OpenGVLab/InternVL3-14B)|
628+
|[OpenGVLab/InternVL3-38B](https://modelscope.cn/models/OpenGVLab/InternVL3-38B)|internvl3|internvl2_5|transformers>=4.37.2, timm|&#x2718;|vision, video|[OpenGVLab/InternVL3-38B](https://huggingface.co/OpenGVLab/InternVL3-38B)|
629+
|[OpenGVLab/InternVL3-78B](https://modelscope.cn/models/OpenGVLab/InternVL3-78B)|internvl3|internvl2_5|transformers>=4.37.2, timm|&#x2718;|vision, video|[OpenGVLab/InternVL3-78B](https://huggingface.co/OpenGVLab/InternVL3-78B)|
623630
|[Shanghai_AI_Laboratory/internlm-xcomposer2-7b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm-xcomposer2-7b)|xcomposer2|ixcomposer2|-|&#x2718;|vision|[internlm/internlm-xcomposer2-7b](https://huggingface.co/internlm/internlm-xcomposer2-7b)|
624631
|[Shanghai_AI_Laboratory/internlm-xcomposer2-4khd-7b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm-xcomposer2-4khd-7b)|xcomposer2_4khd|ixcomposer2|-|&#x2718;|vision|[internlm/internlm-xcomposer2-4khd-7b](https://huggingface.co/internlm/internlm-xcomposer2-4khd-7b)|
625632
|[Shanghai_AI_Laboratory/internlm-xcomposer2d5-7b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm-xcomposer2d5-7b)|xcomposer2_5|xcomposer2_5|decord|&#x2718;|vision|[internlm/internlm-xcomposer2d5-7b](https://huggingface.co/internlm/internlm-xcomposer2d5-7b)|

docs/source_en/Instruction/Command-line-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ For the meaning of the arguments, please refer to [here](https://modelscope.cn/m
596596
- MAX_NUM: Default is 12
597597
- INPUT_SIZE: Default is 448
598598

599-
### internvl2, internvl2_phi3, internvl2_5
599+
### internvl2, internvl2_phi3, internvl2_5, internvl3
600600
For the meaning of the arguments, please refer to [here](https://modelscope.cn/models/OpenGVLab/InternVL2_5-2B)
601601
- MAX_NUM: Default is 12
602602
- INPUT_SIZE: Default is 448

0 commit comments

Comments
 (0)