Skip to content

Commit 4e18bff

Browse files
Jintao-Huanghuangjintao
andauthored
update arguments (#1043)
Co-authored-by: huangjintao <[email protected]>
1 parent 931b465 commit 4e18bff

File tree

3 files changed

+84
-21
lines changed

3 files changed

+84
-21
lines changed

docs/source/index.rst

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,60 @@ Swift DOCUMENTATION
99
:maxdepth: 2
1010
:caption: Get Started
1111

12-
GetStarted/快速使用.md
1312
GetStarted/SWIFT安装.md
1413
GetStarted/界面训练推理.md
1514
GetStarted/使用tuners.md
1615
GetStarted/ResTuning.md
16+
GetStarted/SCEdit.md
1717
GetStarted/在SWIFT内使用PEFT.md
18-
GetStarted/部署指南.md
1918

2019
.. toctree::
2120
:maxdepth: 2
22-
:caption: LLM Training and Inference Example
21+
:caption: LLM Training and Inference
2322

24-
LLM/自我认知微调最佳实践.md
25-
LLM/Agent微调最佳实践.md
2623
LLM/LLM推理文档.md
2724
LLM/LLM微调文档.md
2825
LLM/DPO训练文档.md
29-
LLM/ORPO算法最佳实践.md
26+
LLM/LLM评测文档.md
27+
LLM/LLM量化文档.md
3028
LLM/VLLM推理加速与部署.md
29+
LLM/LLM实验文档.md
30+
LLM/命令行参数.md
3131
LLM/支持的模型和数据集.md
3232
LLM/自定义与拓展.md
33-
LLM/命令行参数.md
33+
LLM/自我认知微调最佳实践.md
34+
LLM/Agent微调最佳实践.md
35+
LLM/Qwen1.5全流程最佳实践.md
36+
LLM/NPU推理与微调最佳实践.md
37+
LLM/Grok训练和推理.md
38+
LLM/ORPO算法最佳实践.md
39+
LLM/SimPO算法最佳实践.md
40+
LLM/HuggingFace生态兼容.md
3441
LLM/Benchmark.md
3542

3643
.. toctree::
3744
:maxdepth: 2
38-
:caption: AIGC Training and Inference Example
45+
:caption: Multi-Modal LLM Training and Inference
46+
47+
Multi-Modal/qwen-vl最佳实践.md
48+
Multi-Modal/qwen-audio最佳实践.md
49+
Multi-Modal/deepseek-vl最佳实践.md
50+
Multi-Modal/internlm-xcomposer2最佳实践.md
51+
Multi-Modal/phi3-vision最佳实践.md
52+
Multi-Modal/llava最佳实践.md
53+
Multi-Modal/yi-vl最佳实践.md
54+
Multi-Modal/mplug-owl2最佳实践.md
55+
Multi-Modal/cogvlm最佳实践.md
56+
Multi-Modal/cogvlm2最佳实践.md
57+
Multi-Modal/minicpm-v最佳实践.md
58+
Multi-Modal/minicpm-v-2最佳实践.md
59+
Multi-Modal/minicpm-v-2.5最佳实践.md
60+
Multi-Modal/internvl最佳实践.md
61+
Multi-Modal/MLLM部署文档.md
62+
63+
.. toctree::
64+
:maxdepth: 2
65+
:caption: AIGC Training and Inference
3966

4067
AIGC/AnimateDiff微调推理文档.md
4168

docs/source_en/index.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,54 @@ Swift DOCUMENTATION
1212
GetStarted/Installation.md
1313
GetStarted/Web-ui.md
1414
GetStarted/Tuners.md
15-
GetStarted/SCEdit.md
1615
GetStarted/ResTuning.md
16+
GetStarted/SCEdit.md
1717
GetStarted/Use-PEFT.md
1818

1919
.. toctree::
2020
:maxdepth: 2
21-
:caption: LLM Training and Inference Example
21+
:caption: LLM Training and Inference
2222

23-
LLM/Self-cognition-best-practice.md
24-
LLM/Agent-best-practice.md
2523
LLM/LLM-fine-tuning.md
2624
LLM/LLM-inference.md
2725
LLM/DPO.md
26+
LLM/LLM-eval.md
27+
LLM/LLM-quantization.md
2828
LLM/VLLM-inference-acceleration-and-deployment.md
29+
LLM/LLM-exp.md
30+
LLM/Command-line-parameters.md
2931
LLM/Supported-models-datasets.md
3032
LLM/Customization.md
31-
LLM/Command-line-parameters.md
33+
LLM/Self-cognition-best-practice.md
34+
LLM/Agent-best-practice.md
35+
LLM/Qwen1.5-best-practice.md
36+
LLM/Grok-1-best-practice.md
37+
LLM/ORPO.md
38+
LLM/SimPO.md
39+
LLM/Compat-HF.md
3240
LLM/Benchmark.md
3341

42+
43+
.. toctree::
44+
:maxdepth: 2
45+
:caption: Multi-Modal LLM Training and Inference
46+
47+
Multi-Modal/qwen-vl-best-practice.md
48+
Multi-Modal/qwen-audio-best-practice.md
49+
Multi-Modal/deepseek-vl-best-practice.md
50+
Multi-Modal/internlm-xcomposer2-best-practice.md
51+
Multi-Modal/phi3-vision-best-practice.md
52+
Multi-Modal/llava-best-practice.md
53+
Multi-Modal/yi-vl-best-practice.md
54+
Multi-Modal/cogvlm-best-practice.md
55+
Multi-Modal/cogvlm2-best-practice.md
56+
Multi-Modal/minicpm-v-best-practice.md
57+
Multi-Modal/internvl-best-practice.md
58+
Multi-Modal/mutlimodal-deployment.md
59+
3460
.. toctree::
3561
:maxdepth: 2
36-
:caption: AIGC Training and Inference Example
62+
:caption: AIGC Training and Inference
3763

3864
AIGC/AnimateDiff-train-infer.md
3965

swift/llm/utils/argument.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
from swift.tuners import Swift
2323
from swift.utils import (add_version_to_work_dir, get_dist_setting, get_logger, get_pai_tensorboard_dir, is_dist,
2424
is_local_master, is_mp, is_pai_training_job, use_torchacc)
25-
from .dataset import DATASET_MAPPING, _dataset_name_exists, get_dataset, register_dataset_info_file, sample_dataset
25+
from .dataset import (DATASET_MAPPING, _dataset_name_exists, get_dataset, parse_dataset_name,
26+
register_dataset_info_file, sample_dataset)
2627
from .model import (MODEL_MAPPING, dtype_mapping, get_additional_saved_files, get_default_lora_target_modules,
2728
get_default_template_type)
2829
from .template import TEMPLATE_MAPPING
@@ -271,9 +272,18 @@ def handle_custom_dataset_info(self):
271272
def _handle_dataset_sample(self):
272273
# compatibility. (Deprecated)
273274
# Avoid post-processing
274-
if len(self.dataset) == 1 and '#' not in self.dataset[0] and self.train_dataset_sample >= 0:
275-
self.dataset[0] = f'{self.dataset[0]}#{self.train_dataset_sample}'
276-
self.train_dataset_sample = -1
275+
if len(self.dataset) != 1 or self.train_dataset_sample == -1:
276+
return
277+
_dataset = self.dataset[0]
278+
train_sample = parse_dataset_name(_dataset)[3]
279+
if train_sample is None:
280+
train_sample = self.train_dataset_sample
281+
elif self.train_dataset_sample < train_sample:
282+
train_sample = self.train_dataset_sample
283+
_dataset = _dataset[:_dataset.find('#')]
284+
_dataset = f'{_dataset}#{train_sample}'
285+
self.dataset[0] = _dataset
286+
self.train_dataset_sample = -1
277287

278288
def _register_self_cognition(self: Union['SftArguments', 'InferArguments']) -> None:
279289

@@ -688,11 +698,9 @@ def _prepare_modules_to_save(self, modules_to_save) -> List[str]:
688698

689699
def __post_init__(self) -> None:
690700
self.handle_compatibility()
691-
self._register_self_cognition()
692701
if len(self.val_dataset) > 0:
693702
self.dataset_test_ratio = 0.0
694703
logger.info('Using val_dataset, ignoring dataset_test_ratio')
695-
self._handle_dataset_sample()
696704
if is_pai_training_job():
697705
self._handle_pai_compat()
698706
ds_config_folder = os.path.abspath(os.path.join(__file__, '..', '..', 'ds_config'))
@@ -707,6 +715,8 @@ def __post_init__(self) -> None:
707715
break
708716

709717
self.handle_path()
718+
self._handle_dataset_sample()
719+
self._register_self_cognition()
710720
self.handle_custom_register()
711721
self.handle_custom_dataset_info()
712722
self.set_model_type()
@@ -1059,7 +1069,6 @@ def __post_init__(self) -> None:
10591069
logger.warning(f'The checkpoint dir {self.ckpt_dir} passed in is invalid, please make sure'
10601070
'the dir contains a `configuration.json` file.')
10611071
self.handle_compatibility()
1062-
self._register_self_cognition()
10631072
if len(self.val_dataset) > 0:
10641073
self.dataset_test_ratio = 0.0
10651074
logger.info('Using val_dataset, ignoring dataset_test_ratio')
@@ -1073,6 +1082,7 @@ def __post_init__(self) -> None:
10731082
else:
10741083
assert self.load_dataset_config is False, 'You need to first set `--load_args_from_ckpt_dir true`.'
10751084
self._handle_dataset_sample()
1085+
self._register_self_cognition()
10761086
self.handle_custom_register()
10771087
self.handle_custom_dataset_info()
10781088
self.set_model_type()

0 commit comments

Comments
 (0)