Quick Start
Sample Description
This section uses downstream tasks of the open-source Zidong.Taichu (OPT) project as examples to describe how to use the mxTuningKit package to quickly start model fine-tuning, evaluation, and inference jobs.
Environment Setup
- Pre-train the model code.
Download the Zidong.Taichu (OPT) model code from the official website:
git clone https://gitee.com/mindspore/omni-perception-pretrainer.git -b adapt_tk
- Pre-train the model weight.
- Obtain the downstream task datasets.
Prepare the training, test, and inference datasets required by each downstream task of the Zidong.Taichu (OPT) model and place them in {opt_model_code_path}/dataset/.
- (Optional) Set the model configuration file.
The model configuration file is used to customize hyperparameters and freeze some networks. If this file is set, the corresponding parameter values in it are used. Otherwise, the default values in the startup script are used. For details about the configuration rules, see (Optional) Model Configuration File Adaptation.
Model Fine-Tuning
tk finetune
--boot_file_path {opt_model_code_path}/code/src/scripts/train_caption.py # Fine-tuning job startup script
--data_path {opt_model_code_path}/dataset/data/ # Root directory of the dataset path
--output_path {opt_model_code_path}/output/ # Result output path, which stores the files to be dumped, such as .ckpt files and customized outputs.
--pretrained_model_path {opt_model_code_path}/pretrained_model/ # (Optional) Pre-trained model
--model_config_path {opt_model_code_path}/code/model_configs/model_config_finetune.yaml # (Optional) Model configuration file
- You can view the dump result in the specified output path {opt_model_code_path}/output/TK_UUID/.
- You can view the job run logs in $HOME/.cache/Huawei/mxTuningKit/log.
- All file paths are local absolute paths.
- Maximum allowed permissions: For a specific file/folder, users in the same group as the file/folder owner have the read/execute permissions. Other users cannot access the file/folder.
Model Evaluation
Use the mxTuningKit package and run the following commands to evaluate the model:
tk evaluate
--boot_file_path {opt_model_code_path}/code/src/scripts/test_caption.py # Evaluation job startup script
--data_path {opt_model_code_path}/dataset/data/ # Root directory of the dataset path
--ckpt_path {opt_model_code_path}/pretrained_model/ # Path of the .ckpt file required for evaluation
--output_path {opt_model_code_path}/output/ # Result output path, which stores the files to be dumped, such as .ckpt files and customized outputs.
--model_config_path {opt_model_code_path}/code/model_configs/model_config_evaluate.yaml # (Optional) Model configuration file
- All file paths are local absolute paths.
- You can view the dump result in the specified output path {opt_model_code_path}/output/TK_UUID/.
- You can view the job run logs in $HOME/.cache/Huawei/mxTuningKit/log.
Model Inference
Use the mxTuningKit package and run the following commands to perform model inference:
tk infer
--boot_file_path {opt_model_code_path}/code/src/scripts/inference_caption.py # Inference job startup script
--data_path {opt_model_code_path}/dataset/data/ # Root directory of the dataset path
--ckpt_path {opt_model_code_path}/pretrained_model/ # Path of the .ckpt file required for inference
--output_path {opt_model_code_path}/output/ # Result output path, which stores the files to be dumped, such as .ckpt files and customized outputs.
--model_config_path {opt_model_code_path}/code/model_configs/model_config_infer.yaml # (Optional) Model configuration file
- All file paths are local absolute paths.
- You can view the dump result in the specified output path {opt_model_code_path}/output/TK_UUID/.
- You can view the job run logs in $HOME/.cache/Huawei/mxTuningKit/log.