Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

黄山的油菜花黄山的油菜花
+1

在使用 Hugging Face 开发的 TRL 库进行大模型微调时,可以通过配置 SFTTrainer 的参数来控制模型结果保存的频次。以下是具体的步骤和相关参数的说明:

1. 安装必要的库

首先,确保你已经安装了必要的库:

pip install transformers datasets trl accelerate

2. 配置 SFTTrainer

在使用 SFTTrainer 时,可以通过传递 TrainingArguments 来配置模型保存的频次。TrainingArguments 是 Hugging Face transformers 库中的一个类,用于控制训练过程中的各种参数。

以下是一个示例代码,展示了如何配置 SFTTrainer 并设置模型保存频次:


from transformers import TrainingArguments, Trainer
from trl import SFTTrainer
from datasets import load_dataset

加载数据集

dataset = load_dataset(“your_dataset_name”)

定义训练参数

training_args = TrainingArguments(
output_dir=”./results”, # 模型保存路径
save_steps=500, # 每500步保存一次模型
save_total_limit=3, # 最多保存3个模型检查点
evaluation_strategy=”steps”, # 评估策略
eval_steps=500, # 每500步进行一次评估


[1] https://blog.csdn.net/FrenzyTechAI/article/details/135864583
[2] https://huggingface.co/docs/transformers/main/zh/main_classes/trainer
[3] https://blog.csdn.net/u012856866/article/details/139502628
[4] https://cloud.tencent.com/developer/news/1349507
[5] https://www.cnblogs.com/chirp/p/18161175
[6] http://www.coreui.cn/news/402931.html
[7] https://www.aqwu.net/wp/?p=4012
[8] https://www.jiqizhixin.com/articles/2024-05-06-8
[9] https://huggingface.co/blog/zh/trl-peft

Views: 86

+1

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注