CS336.wiki
CS336 中文实验手册/实验与消融
反馈与讨论
ASSIGNMENT 01 / 7.1

实验方法与记录

2026 春季 · v26.0.3原文 p. 38–39对照 PDF ↗

7 实验#

现在把全部内容组合起来,在预训练数据上训练小型语言模型。

7.1 如何运行实验与交付物#

理解 Transformer 各架构组件作用的最好办法,是亲自修改并运行;动手经验无法替代。

因此,需要做到快速实验、一致地比较、记录做过的事:

  • 为了快速实验,使用简单的 TinyStories 数据与小规模模型;其非嵌入参数约 12.5M,总参数取决于是否绑定 token embedding 与 LM head。
  • 为了保持比较一致,系统地消融组件、调整超参数。
  • 为了保存记录,提交实验日志与每次实验对应的学习曲线。

为绘制损失曲线,务必定期评估验证损失,同时记录梯度更新步数和真实经过时间(wall-clock time)。Weights & Biases 一类日志基础设施可能有帮助。

练习 experiment_log3 分

实验记录

为训练与评估代码创建实验跟踪基础设施,能按梯度步数与真实经过时间跟踪实验和损失曲线。

交付物: 实验日志基础设施代码,以及记录本节后续问题全部尝试的实验日志文档。

一起把这一章读得更好

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

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

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

7 Experiments
Now it is time to put everything together and train (small) language models on a pretraining dataset.

7.1 How to Run Experiments and Deliverables
The best way to understand the rationale behind the architectural components of a Transformer is to
actually modify it and run it yourself. There is no substitute for hands-on experience.
To this end, it’s important to be able to experiment quickly, consistently, and keep records of what
you did. To experiment quickly, we will be running many experiments on a small-scale model (about 17M
total parameters) and simple dataset (TinyStories). To do things consistently, you will ablate components
and vary hyperparameters in a systematic way, and to keep records we will ask you to submit a log of
your experiments and learning curves associated with each experiment.
To make it possible to submit loss curves, make sure to periodically evaluate validation losses and
record both the number of steps and wall-clock times. You might find logging infrastructure such
as Weights and Biases helpful.


 Problem (experiment_log): Experiment logging (3 points)


   For your training and evaluation code, create experiment tracking infrastructure that allows you
   to track your experiments and loss curves with respect to gradient steps and wall-clock time.

    Deliverable: Logging infrastructure code for your experiments and an experiment log (a
    document of all the things you tried) for the assignment problems below in this section.

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

正在加载本章讨论…

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

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