技巧精选

Reasoning from scratch 第5讲:对数概率打分与自我改进

精选理由

Raschka 又更新了,这期手把手教你用 PyTorch 算 token 概率给模型答案打分,还搭了一个 self-refinement 循环,最后跑 MATH-500 看效果。

Sebastian Raschka 发布 Reasoning from scratch 系列第 5 期视频,讲解推理时扩展中的两个基础概念。

正文

前半部分用 PyTorch 从零计算 token 概率和序列的对数似然,并解释数值稳定性处理,用它构建基于规则和平均对数概率的答案打分器。后半部分演示自我改进(self-refinement)流程:让 LLM 生成批评意见再修改答案,并用 MATH-500 基准评估效果。

原文 · Sebastian Raschka

Reasoning from scratch, round number 5! This time, talking about log-probability scoring (also a great fundamental concept for loss functions like cross-entropy in pre-training and distillation) and self-refinement.

00:00 Introduction and inference-time scaling recap 05:02 Loading the pretrained LLM 08:00 Comparing and scoring model answers 10:18 Building a rule-based scorer 17:53 Token probabilities and sequence likelihood 26:47 Computing token probabilities in PyTorch 30:12 Token indexing and shifted targets 37:27 Log probabilities and numerical stability 45:57 Scoring answers with average log probabilities 56:24 How self-refinement works 59:07 Generating critiques and revised answers 1:01:00 Implementing the self-refinement loop 1:05:57 MATH-500 evaluation results 1:07:35 Takeaways and next steps

产业坐标与信源核验

本条情报归属 AITOP「技巧」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:PyTorch、推理模型、MATH-500、对数概率,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。

信源核验说明:本文原始线索采编自「Sebastian Raschka」(@rasbt),经 AITOP 多维评分管线结构化提炼。

Reasoning from scratch 第5讲:对数概率打分与自我改进|AI热报