Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add swanlab for experiment tracking and visualization. #6401

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Zeyi-Lin
Copy link

Before submitting

如何在LLaMA Factory中使用SwanLab?

SwanLab 是一个开源的模型训练记录工具,面向AI研究者,提供了训练可视化、自动日志记录、超参数记录、实验对比、多人协同等功能。在SwanLab上,研究者能基于直观的可视化图表发现训练问题,对比多个实验找到研究灵感,并通过在线链接的分享与基于组织的多人协同训练,打破团队沟通的壁垒。

为什么要记录训练

相较于软件开发,模型训练更像一个实验科学。一个品质优秀的模型背后,往往是成千上万次实验。研究者需要不断尝试、记录、对比,积累经验,才能找到最佳的模型结构、超参数与数据配比。在这之中,如何高效进行记录与对比,对于研究效率的提升至关重要。

在LLaMA Factory中使用

方式一:CLI

在yaml配置文件中,增加如下代码(注释的部分,代表选填):

## swanlab
use_swanlab: true
swanlab_project: LLaMA-Factory
# swanlab_experiment_name: qwen2-vl-2b-lora-sft
# swanlab_workspace: your_organization_username
# swanlab_mode: cloud
# swanlab_api_key: your_api_key

然后CLI启动命令即可:

llamafactory-cli train your_config.yaml

方式二:WebUI

启动WebUI:

llamafactory-cli webui
image

在GUI中对应栏位填写参数后,启动训练后,在系统的命令行打印中找到SwanLab实验链接访问即可:

image

备注

SwanLab API Key如何获取

官网备用官网注册/登录账号,在设置中找到API Key。
如果你使用local模式,则无需 API Key。

一些交互上的想法

如果在「SwanLab 参数设置」选项卡中,能够增加一个按钮,点击跳转到对应的SwanLab链接,那用户体验就更好了:),暂时在开发上不知道要怎么写。

获取链接的代码:

import swanlab

run = swanlab.init()

print(run.public.json()["cloud"]["experiment_url"])

Copy link
Owner

@hiyouga hiyouga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for integrating the awesome SwanLab into LlamaFactory, can you see the above comments and consider solving them?

src/llamafactory/train/sft/trainer.py Show resolved Hide resolved
src/llamafactory/hparams/finetuning_args.py Outdated Show resolved Hide resolved
src/llamafactory/hparams/finetuning_args.py Outdated Show resolved Hide resolved
src/llamafactory/webui/locales.py Outdated Show resolved Hide resolved
@Zeyi-Lin
Copy link
Author

Hi, thanks for integrating the awesome SwanLab into LlamaFactory, can you see the above comments and consider solving them?

Very good suggestion, I have submitted a new commit based on your comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants