如何在使用 saimpletransformers 时在 wandb 中记录工件?

How to log artifacts in wandb while using saimpletransformers?

我正在使用 simpletransformers. I would also like to use wandb to track model artifacts. As I understand from wandb docs 创建一个问答模型,有一个用于 simpletransformers 的集成接触点,但没有提到日志工件。

我想记录在训练、验证和测试阶段生成的工件,例如 train.json、eval.json、test.json、output/nbest_predictions_test.json 和表现最好的模型。

目前 simpleTransformers 不支持 training/testing 脚本中的日志工件。但您可以手动完成:

import os 

with wandb.init(id=model.wandb_run_id, resume="allow", project=wandb_project) as training_run:
    for dir in sorted(os.listdir("outputs")):
        if "checkpoint" in dir:
            artifact = wandb.Artifact("model-checkpoints", type="checkpoints")
            artifact.add_dir("outputs" + "/" + dir)
            training_run.log_artifact(artifact)

如需了解更多信息,您可以在 SimpleTransofrmer 的 README.md

中查看 W&B 笔记本