CS336.wiki
CS336 中文实验手册/训练与生成
反馈与讨论
ASSIGNMENT 01 / 5.3

组合训练循环

2026 春季 · v26.0.3原文 p. 36–37对照 PDF ↗

5.3 训练循环#

现在终于可以把全部组件放进主训练脚本。

让不同超参数的训练任务容易启动会很有价值,例如通过命令行参数控制,因为后续会反复比较不同选择对训练的影响。

练习 training_together4 分

把组件组合起来

交付物: 编写训练脚本,对用户提供的输入运行训练循环。建议至少支持:

  • 配置和控制模型、优化器的各种超参数。
  • 使用 np.memmap 以内存高效的方式加载大型训练集、验证集。
  • 将检查点保存到用户指定路径。
  • 定期记录训练与验证表现,可输出到控制台,或发送到 Weights & Biases 等外部服务。

一起把这一章读得更好

发现翻译、公式或排版错误?欢迎反馈。概念疑问和学习心得,也可以在本章讨论中交流。

直接选中正文,点击旁边的「反馈这处错误」,即可在页内填写并提交,无需登录。
English original 展开本章英文原文 PDF 文本提取

下列文本提取自本地原版 PDF。图表和公式的准确布局请对照 PDF。

5.3 Training loop
Now, it’s finally time to put all of the components you implemented together into your main training
script. It will pay off to make it easy to start training runs with different hyperparameters (e.g., by taking
them as command-line arguments), since you will be doing these many times later to study how different
choices impact training.


 Problem (training_together): Put it together (4 points)


    Deliverable: Write a script that runs a training loop to train your model on user-provided input.
    In particular, we recommend that your training script allow for (at least) the following:
    • Ability to configure and control the various model and optimizer hyperparameters.
    • Memory-efficient loading of large training and validation datasets with np.memmap.
    • Serializing checkpoints to a user-provided path.

      • Periodically logging training and validation performance (e.g., to console and/or an external
        service like Weights and Biases).9

关于这一章的疑问、理解与心得,都可以在这里交流。阅读无需登录;发表评论或回复时使用 GitHub 账号。

正在加载本章讨论…

欢迎交流概念与阅读疑问,请勿发布作业完整实现或题目答案。

输入中文、英文术语或题号,例如 RoPE、检查点、train_bpe。