魔搭 ms-swift 框架
一、什么是 ms-swift?為什么選它?
二、核心能力:這些技術讓微調效率翻倍
2.1 輕量訓練技術全家桶
2.2 人類偏好對齊訓練方法
2.3 推理與量化加速
三、5 分鐘上手
3.1 安裝
3.2 環境要求
3.3 10 分鐘微調實戰:以 Qwen2.5-7B 為例
3.3.1 命令行方式
3.3.2 訓練后推理
3.3.3 模型推送到ModelScope3
3.3.4 零代碼微調:Web-UI 界面
3.3.5 使用python訓練和推理
四、從訓練到部署完整流程
4.1 支持的訓練方法
4.2 預訓練
4.2 微調
4.3 RLHF
4.4 推理
4.5 界面推理
4.6 部署
4.7 采樣
4.8 評測
4.9 量化
4.10 模型推送
五、參數
六、接入SwanLab
6.1 安裝swanlab
6.2 CLI微調
6.3 WebUI微調
6.4 Python代碼微調
如何讓通用大模型快速適配特定場景?如何用有限硬件資源實現高效微調?今天給大家推薦一款由魔搭社區打造的輕量級微調神器 ——ms-swift,它能幫你搞定從訓練到部署的全流程,哪怕是新手也能快速上手!
一、什么是 ms-swift?為什么選它?
ms-swift(Scalable lightWeight Infrastructure for FineTuning)是魔搭社區推出的大模型與多模態大模型微調部署框架,簡單來說,它是一款能讓你 “花小錢辦大事” 的大模型工具集。
為什么推薦它?這幾個核心優勢太強了:
- 模型覆蓋超全:支持 450 + 純文本大模型(如 Qwen2.5、InternLM3、GLM4、Llama3.3 等)和 150 + 多模態大模型(如 Qwen2.5-VL、Llava、InternVL2.5 等),從文本到圖文、語音全場景覆蓋。
- 全流程一站通:從預訓練、微調、人類對齊(RLHF)到推理、評測、量化、部署,無需切換工具,一套框架走到底。
- 輕量訓練省資源:集成了 LoRA、QLoRA、DoRA、GaLore 等輕量化訓練技術,小顯卡也能微調大模型(比如單卡 3090 就能搞定 7B 模型)。
- 硬件兼容性強:支持 CPU、RTX 系列、A100/H100、Ascend NPU、MPS 等各類硬件,不用為設備發愁。
- 開箱即用門檻低:提供命令行、Web-UI、Python 三種使用方式,零代碼也能上手。
二、核心能力:這些技術讓微調效率翻倍
ms-swift 之所以強大,離不開對前沿技術的集成,無論是訓練、推理還是量化,都有 “黑科技” 加持:
2.1 輕量訓練技術全家桶
無需全量參數訓練,用少量資源就能優化模型:
- LoRA/QLoRA:參數高效微調,顯存占用直降 90%;
- DoRA/GaLore:進一步提升微調效果,兼顧效率與性能;
- UnSloth/Liger:加速訓練過程,讓單卡訓練更快完成。
2.2 人類偏好對齊訓練方法
讓模型輸出更符合人類偏好:
- 支持 DPO/GRPO/ORPO 等主流對齊算法;
- 適配純文本和多模態模型,對話、工具調用場景都能用。
2.3 推理與量化加速
模型訓練完,部署效率也不能落下:
- 推理加速:集成 vLLM、LMDeploy 引擎,生成速度提升數倍;
- 量化技術:支持 GPTQ、AWQ、BNB 等量化方法,模型體積減半,精度損失小。
三、5 分鐘上手
3.1 安裝
- pip 一鍵安裝:
pip install ms-swift- 源碼安裝(適合開發者):
# pip install git+https://github.com/modelscope/ms-swift.git
git clone https://github.com/modelscope/ms-swift.git
cd ms-swift
pip install -e .3.2 環境要求
范圍 | 推薦 | 備注 | |
python | >=3.9 | 3.10 | |
cuda | cuda12 | 使用cpu、npu、mps則無需安裝 | |
torch | torch>=2.0 | ||
transformers | >=4.33 | 4.50 | |
modelscope | >=1.19 | ||
peft | >=0.11,<0.16 | ||
trl | >=0.13,<0.17 | 0.16 | RLHF |
deepspeed | >=0.14 | 0.14.5 | 訓練 |
vllm | >=0.5.1,<0.8 | 0.7.3 | 推理/部署/評測 |
lmdeploy | >=0.5 | 0.7.2.post1 | 推理/部署/評測 |
evalscope | >=0.11 | 評測 |
更多依賴參考 ??https://github.com/modelscope/ms-swift/blob/main/requirements/install_all.sh??
3.3 10 分鐘微調實戰:以 Qwen2.5-7B 為例
用單卡 3090(22GB 顯存)就能搞定自我認知微調,步驟超簡單:
3.3.1 命令行方式
# 22GB
CUDA_VISIBLE_DEVICES=0 \
swift sft \
--model Qwen/Qwen2.5-7B-Instruct \
--train_type lora \
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
'AI-ModelScope/alpaca-gpt4-data-en#500' \
'swift/self-cognition#500' \
--torch_dtype bfloat16 \
--num_train_epochs 1 \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--learning_rate 1e-4 \
--lora_rank 8 \
--lora_alpha 32 \
--target_modules all-linear \
--gradient_accumulation_steps 16 \
--eval_steps 50 \
--save_steps 50 \
--save_total_limit 5 \
--logging_steps 5 \
--max_length 2048 \
--output_dir output \
--system 'You are a helpful assistant.' \
--warmup_ratio 0.05 \
--dataloader_num_workers 4 \
--model_author swift \
--model_name swift-robot- 如果要使用自定義數據集進行訓練,參考 ??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 <dataset_path>
- 默認使用ModelScope下載模型和數據集。如果要使用HuggingFace,指定--use_hf true即可
- --model_author和--model_name參數只有當數據集中包含swift/self-cognition時才生效
3.3.2 訓練后推理
使用訓練后的權重推理命令:
# 交互式推理
CUDA_VISIBLE_DEVICES=0 \
swift infer \
--adapters output/vx-xxx/checkpoint-xxx \
--stream true \
--temperature 0 \
--max_new_tokens 2048
# merge-lora并使用vLLM進行推理加速
CUDA_VISIBLE_DEVICES=0 \
swift infer \
--adapters output/vx-xxx/checkpoint-xxx \
--stream true \
--merge_lora true \
--infer_backend vllm \
--max_model_len 8192 \
--temperature 0 \
--max_new_tokens 2048adapters文件夾中包含訓練的參數文件??args.json???,不需要額外指定???--model???,???--system???,swift會自動讀取這些參數。如果要關閉此行為,可以設置???--load_args false???。
3.3.3 模型推送到ModelScope
CUDA_VISIBLE_DEVICES=0 \
swift export \
--adapters output/vx-xxx/checkpoint-xxx \
--push_to_hub true \
--hub_model_id '<your-model-id>' \
--hub_token '<your-sdk-token>' \
--use_hf false3.3.4 零代碼微調:Web-UI 界面
Web-UI是基于gradio界面技術的零門檻訓練、部署方案。更多信息可以查看 ??https://swift.readthedocs.io/zh-cn/latest/GetStarted/Web-UI.html??
只需一行命令啟動可視化界面,點點鼠標就能訓練:
swift web-ui3.3.5 使用python訓練和推理
ms-swift也支持使用python的方式進行訓練和推理。下面給出訓練和推理的關鍵代碼,更多詳情可以查看 ??https://github.com/modelscope/ms-swift/blob/main/examples/notebook/qwen2_5-self-cognition/self-cognition-sft.ipynb??
訓練
# 獲取模型和template,并加入可訓練的LoRA模塊
model, tokenizer = get_model_tokenizer(model_id_or_path, ...)
template = get_template(model.model_meta.template, tokenizer, ...)
model = Swift.prepare_model(model, lora_config)
# 下載并載入數據集,并將文本encode成tokens
train_dataset, val_dataset = load_dataset(dataset_id_or_path, ...)
train_dataset = EncodePreprocessor(template=template)(train_dataset, num_proc=num_proc)
val_dataset = EncodePreprocessor(template=template)(val_dataset, num_proc=num_proc)
# 進行訓練
trainer = Seq2SeqTrainer(
model=model,
args=training_args,
data_collator=template.data_collator,
train_dataset=train_dataset,
eval_dataset=val_dataset,
template=template,
)
trainer.train()推理
# 使用原生pytorch引擎進行推理
engine = PtEngine(model_id_or_path, adapters=[lora_checkpoint])
infer_request = InferRequest(messages=[{'role': 'user', 'content': 'who are you?'}])
request_config = RequestConfig(max_tokens=max_new_tokens, temperature=temperature)
resp_list = engine.infer([infer_request], request_config)
print(f'response: {resp_list[0].choices[0].message.content}')四、從訓練到部署完整流程
完整流程從訓練到部署demo可查看 ??https://github.com/modelscope/ms-swift/tree/main/examples??
4.1 支持的訓練方法

4.2 預訓練
# 8*A100
NPROC_PER_NODE=8 \
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
swift pt \
--model Qwen/Qwen2.5-7B \
--dataset swift/chinese-c4 \
--streaming true \
--train_type full \
--deepspeed zero2 \
--output_dir output \
--max_steps 100000 \
...4.2 微調
CUDA_VISIBLE_DEVICES=0 swift sft \
--model Qwen/Qwen2.5-7B-Instruct \
--dataset AI-ModelScope/alpaca-gpt4-data-zh \
--train_type lora \
--output_dir output \
...4.3 RLHF
CUDA_VISIBLE_DEVICES=0 swift rlhf \
--rlhf_type dpo \
--model Qwen/Qwen2.5-7B-Instruct \
--dataset hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
--train_type lora \
--output_dir output \
...4.4 推理
CUDA_VISIBLE_DEVICES=0 swift infer \
--model Qwen/Qwen2.5-7B-Instruct \
--stream true \
--infer_backend pt \
--max_new_tokens 2048
# LoRA
CUDA_VISIBLE_DEVICES=0 swift infer \
--model Qwen/Qwen2.5-7B-Instruct \
--adapters swift/test_lora \
--stream true \
--infer_backend pt \
--temperature 0 \
--max_new_tokens 20484.5 界面推理
CUDA_VISIBLE_DEVICES=0 swift app \
--model Qwen/Qwen2.5-7B-Instruct \
--stream true \
--infer_backend pt \
--max_new_tokens 2048 \
--lang zh4.6 部署
CUDA_VISIBLE_DEVICES=0 swift deploy \
--model Qwen/Qwen2.5-7B-Instruct \
--infer_backend vllm4.7 采樣
CUDA_VISIBLE_DEVICES=0 swift sample \
--model LLM-Research/Meta-Llama-3.1-8B-Instruct \
--sampler_engine pt \
--num_return_sequences 5 \
--dataset AI-ModelScope/alpaca-gpt4-data-zh#54.8 評測
CUDA_VISIBLE_DEVICES=0 swift eval \
--model Qwen/Qwen2.5-7B-Instruct \
--infer_backend lmdeploy \
--eval_backend OpenCompass \
--eval_dataset ARC_c4.9 量化
CUDA_VISIBLE_DEVICES=0 swift export \
--model Qwen/Qwen2.5-7B-Instruct \
--quant_bits 4 --quant_method awq \
--dataset AI-ModelScope/alpaca-gpt4-data-zh \
--output_dir Qwen2.5-7B-Instruct-AWQ4.10 模型推送
swift export \
--model <model-path> \
--push_to_hub true \
--hub_model_id '<model-id>' \
--hub_token '<sdk-token>'五、 參數
- num_train_epochs
定義:訓練的 epoch 數(默認值為 3)。1 個 epoch 指模型完整遍歷一次訓練數據集
示例:若有 1000 條訓練樣本,??num_train_epochs=3?? 表示模型會遍歷數據 3 次
作用:逐步優化模型參數,提升擬合能力
注意:過多 epoch 可能導致過擬合(模型記住訓練數據而非泛化)
- split_dataset_ratio
定義:訓練集與驗證集的劃分比例(訓練集占比)
示例:??split_dataset_ratio=0.8?? 表示 1000 條樣本中,800 條用于訓練,200 條用于驗證
作用:區分訓練數據(模型學習)和驗證數據(調參、選最優模型),部分場景含測試集(最終評估)
- per_device_train_batch_size
定義:每個設備的訓練批量大小(GRPO 中特指 completion 批次大?。?/p>
總批量計算:??總 batch size = per_device_train_batch_size × 設備數量??(如多 GPU 場景)
示例:??per_device_train_batch_size=16?? 表示單設備每次用 16 個樣本更新參數,2 個 GPU 總批量為 32
影響與建議如下表:
方面 | 影響 / 建議 |
訓練速度 | 批量越大,硬件并行能力利用率越高,訓練越快。 |
內存占用 | 批量過大會導致 OOM(顯存不足),建議從小值(2→4→8)逐步嘗試。 |
模型效果 | 太小易導致梯度噪聲大(不穩定),太大可能降低泛化能力。 |
場景適配 | 微調大模型推薦 1~8(配合梯度累積);多卡訓練可適當放大;BatchNorm 任務不宜過小。 |
- gradient_accumulation_steps
定義:參數更新前累積的 batch 數量(模擬大批量訓練,不增加顯存占用)
示例:??per_device_train_batch_size=4 + gradient_accumulation_steps=8?? 等效總批量為 32(顯存僅占 4 樣本的量)
推薦值如下表:
硬件場景(單卡) | 推薦值 |
A10/RTX 3090/L40(24G) | 1~4 |
T4/V100(16G) | 4~8 |
RTX 3060/2080(12G) | 8~16 |
顯存緊張 | 32 或更高(犧牲速度) |
- learning_rate
學習率大小 | 效果 | 問題 |
太大 | 更新快 | 易跳過最優解,導致震蕩 / 發散 |
太小 | 穩定但慢 | 收斂慢,可能陷入局部最小值 |
推薦值:
定義:參數更新的 “力度”(梯度調整系數),公式為 ??newParameter = oldParameter - learningRate × gradient??
影響:
任務類型 | 推薦學習率 |
圖像分類(SGD+momentum) | 0.1(配合衰減策略) |
圖像分類(Adam) | 3e-4(0.0003) |
NLP(Transformer 微調) | 2e-5 ~ 5e-5 |
強化學習 | 1e-4 ~ 1e-5 |
大模型微調 | 2e-5 ~ 5e-5 |
- warmup_ratio
定義:學習率預熱階段占總訓練步數的比例(預熱階段學習率從 0 逐步增至目標值)
公式:??num_warmup_steps = warmup_ratio × total_training_steps??(總步數 = epoch 數 × 每 epoch 批次數)
作用:避免初始隨機權重因大學習率導致的訓練不穩定
推薦范圍:0.01 ~ 0.2
- lora_rank
秩越?。簠翟缴?,內存占用低,但擬合能力有限;
秩越大:擬合能力強,但易過擬合
定義:LoRA 低秩矩陣的秩,控制適配矩陣的復雜度與表達能力
影響:
推薦值:
模型規模 | 推薦值 |
小模型(<1B 參數) | 8 ~ 64 |
中等模型(1B~10B) | 8 ~ 32 |
大模型(>10B) | 8 ~ 16 |
- lora_alpha
默認:??lora_alpha = 2 × lora_rank??(如 8→16、16→32);
小模型:8 ~ 32;大模型:16 ~ 64。
定義:LoRA 適配矩陣的縮放因子,公式為 ??ΔW = (α/r) × A×B^T??(r 為 lora_rank)
作用:放大低秩矩陣的影響(如 ??lora_rank=8 + lora_alpha=16?? 時縮放因子為 2)
推薦值:
- use_chat_template
[
{"role": "user", "content": "介紹一下你自己"},
{"role": "assistant", "content": "我是 InternLM,由上海人工智能實驗室開發的語言模型..."},
{"role": "user", "content": "你能幫我寫一篇關于夏天的文章嗎?"}
]
<|User|>: 介紹一下你自己
<|Assistant|>: 我是 InternLM...
<|User|>: 你能幫我寫一篇關于夏天的文章嗎?如果啟用了 ??use_chat_template = true??,系統會自動將這段對話轉換為類似下面的字符串:
定義:決定是否在推理或訓練過程中自動應用模型內置的“對話格式模板”來組織輸入文本
值:true 和 false
例如,你傳入如下對話歷史:
- target_modules
LLM 中自動選擇除 ??lm_head?? 外的線性層并附加tuner;
多模態 LLM 默認僅在 LLM 附加調優器,可通過 ??freeze_llm??? 、???freeze_vit???、???freeze_aligner???等參數控制
- 定義:指定接入 LoRA 或其他調優器的模塊(默認 ?
?all-linear??) - 行為:
- save_steps
定義:每隔多少步保存一次模型狀態(權重、優化器等,默認 500)
作用:支持中斷后從最近 checkpoint 續訓,便于篩選最優模型
推薦值:
場景 | 推薦值 |
小數據集 / 快速實驗 | 50 ~ 100 |
中等規模訓練 | 500 ~ 1000 |
大規模預訓練 | 1000 ~ 10000 |
- save_total_limit
定義:最多保留的模型 checkpoint 數量(超出自動刪除較早文件)
作用:節省磁盤空間,例如 ??save_total_limit=2?? 僅保留最近 2 個 checkpoint
- logging_steps
定義:每隔多少步打印訓練狀態(loss、學習率等,默認 5)
作用:實時監控訓練進度,輔助調試模型表現
- gradient_checkpointing_kwargs
顯存不足時啟用;
新版推薦 ??use_reentrant: false??(效率更高);
老模型兼容用 ??use_reentrant: true??;
大模型微調強烈建議開啟
定義:梯度檢查點的高級配置(默認 None),用于節省顯存
原理:前向傳播僅保留部分激活值,反向傳播時重新計算,以時間換內存
建議:
- dataloader_num_workers
定義:PyTorch DataLoader 用于數據加載的子進程數量
作用:并行處理數據讀取、預處理等任務,加速數據供給主訓練進程
六、接入SwanLab
6.1 安裝swanlab
pip install swanlab6.2 CLI微調
只需要在ms-swift的CLI中添加??--report_to???和???--swanlab_project???兩個參數,即可使用SwanLab進行實驗跟蹤與可視化:
swift sft \
...
--report_to swanlab \
--swanlab_project swift-robot \
...運行指令后,可以在SwanLab看到訓練過程:

支持的完整參數:
- ?
?swanlab_token??: SwanLab的api-key - ?
?swanlab_project??: swanlab的project - ?
?swanlab_workspace??: 默認為None,會使用api-key對應的username - ?
?swanlab_exp_name??: 實驗名,可以為空,為空時默認傳入--output_dir的值 - ?
?swanlab_mode??: 可選cloud和local,云模式或者本地模式
6.3 WebUI微調
啟動WebUI
swift web-ui啟動后,會自動打開瀏覽器,顯示微調界面(或者訪問 ??http://localhost:7860/?? ):

在下方的「訓練記錄」模塊中,在??訓練記錄方式???部分選擇???swanlab???:

還可以在「訓練記錄」模塊的其他填寫更細致的swanlab參數,包括:
- ?
?swanlab_token??: SwanLab的api-key - ?
?swanlab_project??: swanlab的project - ?
?swanlab_workspace??: 默認為None,會使用api-key對應的username - ?
?swanlab_exp_name??: 實驗名,可以為空,為空時默認傳入--output_dir的值 - ?
?swanlab_mode??: 可選cloud和local,云模式或者本地模式
6.4 Python代碼微調
這部分更詳細的可以查閱 ??https://docs.swanlab.cn/guide_cloud/integration/integration-swift.html#_3-python%E4%BB%A3%E7%A0%81%E5%BE%AE%E8%B0%83??
引入SwanLabCallback
from swanlab.integration.transformers import SwanLabCallback引入Trainer
from swanlab.integration.transformers import SwanLabCallback
from swift import Seq2SeqTrainer, Seq2SeqTrainingArguments
···
#實例化SwanLabCallback
swanlab_callback = SwanLabCallback(project="swift-visualization")
trainer = Seq2SeqTrainer(
...
callbacks=[swanlab_callback],
)
trainer.train()使用SwanLabCallback
# Lora微調一個Qwen2-0.5B模型
from swanlab.integration.transformers import SwanLabCallback
from swift import Seq2SeqTrainer, Seq2SeqTrainingArguments
from swift.llm import get_model_tokenizer, load_dataset, get_template, EncodePreprocessor
from swift.utils import get_logger, find_all_linears, get_model_parameter_info, plot_images, seed_everything
from swift.tuners import Swift, LoraConfig
from swift.trainers import Seq2SeqTrainer, Seq2SeqTrainingArguments
from functools import partial
import os
logger = get_logger()
seed_everything(42)
# Hyperparameters for training
# model
model_id_or_path = 'Qwen/Qwen2.5-3B-Instruct' # model_id or model_path
system = 'You are a helpful assistant.'
output_dir = 'output'
# dataset
dataset = ['AI-ModelScope/alpaca-gpt4-data-zh#500', 'AI-ModelScope/alpaca-gpt4-data-en#500',
'swift/self-cognition#500'] # dataset_id or dataset_path
data_seed = 42
max_length = 2048
split_dataset_ratio = 0.01 # Split validation set
num_proc = 4 # The number of processes for data loading.
# The following two parameters are used to override the placeholders in the self-cognition dataset.
model_name = ['小黃', 'Xiao Huang'] # The Chinese name and English name of the model
model_author = ['魔搭', 'ModelScope'] # The Chinese name and English name of the model author
# lora
lora_rank = 8
lora_alpha = 32
# training_args
training_args = Seq2SeqTrainingArguments(
output_dir=output_dir,
learning_rate=1e-4,
per_device_train_batch_size=1,
per_device_eval_batch_size=1,
gradient_checkpointing=True,
weight_decay=0.1,
lr_scheduler_type='cosine',
warmup_ratio=0.05,
logging_first_step=True,
save_strategy='steps',
save_steps=50,
eval_strategy='steps',
eval_steps=50,
gradient_accumulation_steps=16,
num_train_epochs=1,
metric_for_best_model='loss',
save_total_limit=5,
logging_steps=5,
dataloader_num_workers=1,
data_seed=data_seed,
)
output_dir = os.path.abspath(os.path.expanduser(output_dir))
logger.info(f'output_dir: {output_dir}')
# Obtain the model and template, and add a trainable Lora layer on the model.
model, tokenizer = get_model_tokenizer(model_id_or_path)
logger.info(f'model_info: {model.model_info}')
template = get_template(model.model_meta.template, tokenizer, default_system=system, max_length=max_length)
template.set_mode('train')
target_modules = find_all_linears(model)
lora_config = LoraConfig(task_type='CAUSAL_LM', r=lora_rank, lora_alpha=lora_alpha,
target_modules=target_modules)
model = Swift.prepare_model(model, lora_config)
logger.info(f'lora_config: {lora_config}')
# Print model structure and trainable parameters.
logger.info(f'model: {model}')
model_parameter_info = get_model_parameter_info(model)
logger.info(f'model_parameter_info: {model_parameter_info}')
# Download and load the dataset, split it into a training set and a validation set,
# and encode the text data into tokens.
train_dataset, val_dataset = load_dataset(dataset, split_dataset_ratio=split_dataset_ratio, num_proc=num_proc,
model_name=model_name, model_author=model_author, seed=data_seed)
logger.info(f'train_dataset: {train_dataset}')
logger.info(f'val_dataset: {val_dataset}')
logger.info(f'train_dataset[0]: {train_dataset[0]}')
train_dataset = EncodePreprocessor(template=template)(train_dataset, num_proc=num_proc)
val_dataset = EncodePreprocessor(template=template)(val_dataset, num_proc=num_proc)
logger.info(f'encoded_train_dataset[0]: {train_dataset[0]}')
# Print a sample
template.print_inputs(train_dataset[0])
# Get the trainer and start the training.
model.enable_input_require_grads() # Compatible with gradient checkpointing
swanlab_callback = SwanLabCallback(
project="swift-visualization",
experiment_name="lora-qwen2-0.5b",
descriptinotallow="Lora微調一個Qwen2-0.5B模型"
)
trainer = Seq2SeqTrainer(
model=model,
args=training_args,
data_collator=template.data_collator,
train_dataset=train_dataset,
eval_dataset=val_dataset,
template=template,
callbacks=[swanlab_callback],
)
trainer.train()
last_model_checkpoint = trainer.state.last_model_checkpoint
logger.info(f'last_model_checkpoint: {last_model_checkpoint}')運行可視化結果:

筆者能力有限,歡迎批評指正或者在留言區討論參考:
- ??https://blog.csdn.net/2401_89025022/article/details/146997066??
- ??https://cloud.tencent.com/developer/article/2550538??
- ??https://docs.swanlab.cn/guide_cloud/integration/integration-swift.html#_3-python%E4%BB%A3%E7%A0%81%E5%BE%AE%E8%B0%83??
本文轉載自??鴻煊的學習筆記??,作者:乘風破浪jxj

















