终身学习¶
Implementing LLM Speculative Sampling in Under 100 Lines of Code
Introduction
Today we'll explore and implement DeepMind's paper: Accelerating large language model decoding with speculative sampling 1. I'll demonstrate how to reproduce this technique in less than 100 lines of code while achieving more than 2x speedup in inference time.
LLM Speculative Sampling
前言
今天我们将介绍并复现 Deepmind 的一篇关于 LLM Speculative Sampling 的论文:Accelerating large language model decoding with speculative sampling1. 我们将用不到 100 行代码来复现这篇论文,并得到 2 倍以上的速度提升。
Deepseek GRPO 中的 KL Divergence
起
在 Deepseek R1 发布之后,看到了论文中 RL 的算法用的是 GRPO,而 GRPO 是在之前 Deepseek Math 的论文中被提出来的。GRPO 的目标函数如下:
\[ \begin{aligned} \mathcal{J}_{GRPO}(\theta) &= \mathbb{E}_{[q \sim P(Q), \{o_i\}_{i=1}^G \sim \pi_{\theta_{old}}(O\mid q)]} \frac{1}{G}\sum_{i=1}^G \frac{1}{|o_i|} \sum_{t=1}^{|o_i|} \Biggl\{ \min \Biggl[ \frac{\pi_\theta(o_{i,t} \mid q, o_{i,<t})}{\pi_{\theta_{old}}(o_{i,t} \mid q, o_{i,<t})} \hat{A}_{i,t}, \text{clip}\Biggl( \frac{\pi_\theta(o_{i,t} \mid q, o_{i,<t})}{\pi_{\theta_{old}}(o_{i,t} \mid q, o_{i,<t})}, 1 - \epsilon, 1 + \epsilon \Biggr) \hat{A}_{i,t} \Biggr] \\ &\quad - \beta \, \mathbb{D}_{KL}\left[\pi_{\theta} \parallel \pi_{ref}\right] \Biggr\} \end{aligned} \]
大语言模型与深度学习书籍推荐
前言
之前在朋友圈/推特上推荐的几本 NLP/LLM 的书大家都比较喜欢,这里为了方便大家查阅,统一整理了一下 (另外加上了一些深度学习基础知识学习的书籍), 同时也发在公众号上方便大家收藏查阅。
斯坦福小镇 (AI-Town) 系统解读
核心要点
本文解读了斯坦福小镇(AI-Town)项目,重点关注其在生成式代理方面的创新架构设计。 主要包含以下几个关键部分:
- 记忆系统(Memory Stream):长期记忆模块
- 反思机制(Reflection):高层次推理能力
- 计划系统(Planning):行为规划与执行
- 评估方法(Evaluation):代理行为的可信度验证
启发与应用
本文的核心概念对游戏 NPC 设计具有重要的参考价值,特别是在:
- NPC 记忆系统的设计
- 行为的真实性和可信度
- 动态社交关系的构建
- 环境互动的自然性