工程中的经典“意象”(一):滑动窗口

<blockquote> <p>在古诗文中,我们以月喻离合、以水比时光、以柳寄别恨。在软件工程中,我们以管道贯通有无、以缓存平峰谷、以协议定不变。前者我们称为<strong>意象</strong>,《文心雕龙·神思》篇中写道:“独照之匠,窥意象而运斤”;后者我们叫做<strong>隐喻</strong>,《代码大全》(Code Complete)中将隐喻视为一种启发式方法(heuristic),用以在抽象与具象之间架设桥梁。</p> <p>我们如此习惯于意象和隐喻,是因为“人类思维本质上是隐喻性的”(出自莱考夫和约翰逊在《我们赖以生存的隐喻》)。其特点是,将一类场景相关的上下文传神地压缩进一个词语中。比之于精确的算法,它模糊但强大,所谓 “运用之妙,存乎一心”。</p> <p>我想通过一系列小文来收集我在实践中反复看到的一些有趣意象,本篇来聊聊<strong>滑动窗口</strong>。</p> </blockquote> <h1>引子</h1> <p>前几天听罗振宇的历史播客《文明之旅》时,讲到故宫博物院的传世名画——北宋末年宫廷画家王希孟的《千里江山图》。它除了有名外,另外一个特点就是——特别长,几近十二米(1191.5 厘米 )!在中国古代书画中,这种&quot;横长纵短、边展边看&quot;的形式叫<strong>手卷</strong>(还有竖挂的<strong>立轴</strong>和分页的<strong>册页</strong>)。</p> <p>手卷适合三两好友慢慢撵卷细品。这种前手展、后手收、只关注窗口内的“景色”的经典场景便正是软件工程中最经典的意象之一——滑动窗口。下面依时间线来聊聊我在接触编程后遇到的相关场景。</p> <p><img src="https://files.seeusercontent.com/2026/07/12/z1sW/c348508.png" alt="展卷窗口"></p>

2026/7/12
阅读更多

一个大模型从业者的 Vibe Coding 一些一线经验

<p>从第一个我体感“有点不一样”的 Code Agent —— Claude Opus 4.5 发布(2025年11月24日)以来,竟然才过去半年。但在这半年里,基本所有能被程序化、自动化的工作,都受到了前所未有的冲击。我们这个以代码为生的群体更是被当头棒喝,周围即使最保守的程序员,也在“卧槽”声中做了调整和转向。</p> <p>现在深处漩涡中,去预测 AI 带来的社会层面变化,是我万万力所不及的。本篇只想稍稍记录下最近将 Agent 嵌入工作流的一些体验,以待将来回忆起有所凭借,零零碎碎,林林总总。主要从工作模式变迁,如何管理 Agent 和上下文,如何创建和管理 Skill 等方向聊一些一个大模型人的一线体感和经验。</p> <p><img src="https://files.seeusercontent.com/2026/06/16/k2kJ/sync-async.png" alt="同步到异步"></p>

2026/6/16
阅读更多

大模型的损失函数为什么是交叉熵

<h1>引子</h1> <p>刚入门大模型的时候,由于线性代数、概率论和信息论等数学知识的短板,很容易迷失在诸多术语中:logprob(对数概率)、likelihood(似然)、NLL(Negative Log Likelihood,负对数似然)、cross entropy(交叉熵)、perplexity(困惑度)。它们常常出现在论文和文档的各种角落里,但都像点赞之交的朋友,频见其名,不解其意。</p> <p>后来某天,在慢慢的补过一些最基础的数学知识后,在公司相关的上下文浸淫足够久后,终于在某次和 ChatGPT 的聊天中发现:<strong>上面一组概念本质上是同一件事的不同面向的侧写</strong>。从概率论的门摸进去叫 NLL,从信息论的门踏进去叫交叉熵,从 PyTorch 的门看进去叫 <code>F.cross_entropy</code>——殊途同归,本质上都是在试图刻画"模型当前输出离预期还有多远"。</p> <p>“横看成岭侧成峰”,在大模型这种高维上下文的领域中,这种盲人摸象的感觉所在多有。不过我们这种三维生物,也只能靠长久的浸淫,才能靠着不同领域知识的交叉验证,才会突然有一天顿悟——嗷,原来这是同一座山。</p> <p>本文想做的,就是想聊聊大模型领域中最基础概念——交叉熵这个损失函数的“一花各表”。</p> <p><img src="https://files.seeusercontent.com/2026/04/19/a7Py/NLL-entropy.png" alt="NLL-entropy.png"></p>

2026/3/29
阅读更多

Why Is the Loss Function of Large Models Cross-Entropy

<h1>Prologue</h1> <p>When first entering the world of large models, due to gaps in foundational math knowledge such as linear algebra, probability theory, and information theory, it’s easy to get lost among numerous terms: logprob (log probability), likelihood, NLL (Negative Log Likelihood), cross entropy, perplexity. They frequently appear in various corners of papers and documentation, yet they all feel like acquaintances you only know by name — you see them often, but don’t truly understand them.</p> <p>Then one day, after slowly catching up on some basic math knowledge and immersing myself in the company context for long enough, I finally realized during a chat with ChatGPT: <strong>the above set of concepts are essentially different perspectives of the same thing</strong>. Enter through the door of probability theory and it’s called NLL; step through the door of information theory and it’s called cross entropy; look through the door of PyTorch and it’s <code>F.cross_entropy</code> — different paths leading to the same destination, all essentially trying to characterize “how far the model’s current output is from the expected result.”</p> <p>“Viewed from the side, a mountain looks like a ridge; viewed from the end, a single peak” — in a high-dimensional field like large models, this feeling of blind men touching an elephant is everywhere. But we three-dimensional creatures can only rely on long-term immersion, cross-verifying knowledge from different domains, until one day we suddenly have an epiphany — ah, so this is the same mountain.</p> <p>What this article aims to do is talk about the most fundamental concept in the large model domain — the “many faces” of cross entropy as a loss function.</p> <p><img src="https://files.seeusercontent.com/2026/04/19/a7Py/NLL-entropy.png" alt="NLL-entropy.png"></p>

2026/3/29
阅读更多

20260120 B 站直播 —— 转行大模型文字精要

<blockquote> <p>我是 2024 年初到一家大模型公司工作,之前一直在数据库、存储等 infra 行业工作,因此有些很粗浅的转行认知。很久没有在 b 站做分享了,这次靠直播强制开机,回答了大家一些问题,稍稍弥合一点信息差。本文对直播中提到的一些点的稍微规整一点的总结,并将一些我觉得不错的资料附在最后。</p> <p>b 站直播:<a href="https://www.bilibili.com/video/BV1uckJBkEto">https://www.bilibili.com/video/BV1uckJBkEto</a></p> </blockquote> <p><img src="https://s2.loli.net/2026/01/25/p5hVJcA4ytHolCf.png" alt="题图"></p>

2026/1/25
阅读更多

20260120 Bilibili Live — Key Takeaways on Switching to LLMs

<blockquote> <p>I joined an LLM company in early 2024, having previously worked in the infra industry (databases, storage, etc.), so I have some very basic insights on switching careers. I haven’t shared on Bilibili for a long time; this live stream forced me to get back in gear. I answered some of your questions and bridged a bit of the information gap. This post is a slightly more organized summary of some points mentioned during the stream, with some materials I find valuable attached at the end.</p> <p>Bilibili live stream: <a href="https://www.bilibili.com/video/BV1uckJBkEto">https://www.bilibili.com/video/BV1uckJBkEto</a></p> </blockquote> <p><img src="https://s2.loli.net/2026/01/25/p5hVJcA4ytHolCf.png" alt="Cover image"></p>

2026/1/25
阅读更多

2025 年终总结——向内生长

<p>有明显的自我意识以来,从没有像今年这样和世界、和自己发生如此激烈的冲撞,但结果很神奇——反倒更加平和了。很多下意识的反应、很多习以为常的做法,向内挖时,竟然都能摸出如此久远的强化链路。正如史铁生说的——那颗年少时射出的子弹,在长到这个年纪的时候,正中眉心。</p> <p>于是,不管是被迫地还是自发地,今年都开始难以避免地向内生长——如格物致知一般去观察和追溯自己细微的情绪变化源头,见天地、见众生,终是为了见自己。虽然以前惯性还会持续一段时间,但觉察的开始,便是塑造另外轨迹的种子。</p> <p><img src="https://photo.tuchong.com/15470921/wp/672288214.jpg" alt="佛光寺经幢和东大殿"></p>

2025/12/28
阅读更多

2025 Year-End Summary — Inward Growth

<p>Since becoming distinctly self-aware, never have I clashed so intensely with the world and with myself as I have this year—yet the result is strangely magical: I have become even more peaceful. Many subconscious reactions, many habitual practices, when excavated inward, can be traced back to such ancient reinforcement chains. Just as Shi Tiesheng said—the bullet fired in youth strikes squarely between the brows at this age.</p> <p>Thus, whether forced or spontaneous, this year has become an inevitable journey of inward growth—observing and tracing the subtle origins of my emotional shifts, as in the investigation of things to extend knowledge. Seeing heaven and earth, seeing all beings, ultimately serves to see oneself. Although old inertia will persist for some time, the beginning of awareness is the seed that shapes a different trajectory.</p> <p><img src="https://photo.tuchong.com/15470921/wp/672288214.jpg" alt="Foguang Temple's Sutra Pillar and East Main Hall"></p>

2025/12/28
阅读更多

深入理解大模型 1:Transformer,大模型的基石

<blockquote> <p><a href="https://princeton-cos597r.github.io/"><strong>Princeton COS 597R “Deep Dive into Large Language Models”</strong></a> 是普林斯顿大学的一门研究生课程,系统探讨了大语言模型原理、准备和训练、架构演进及其在多模态、对齐、工具使用等前沿方向中的应用与一些问题。注意,该课程侧重概念的理解上,而非工程的实现上。<br> 我之前是在分布式系统和数据库内核方向,但这两年转到一家大模型公司做数据。本笔记主要是我对课程论文的梳理和精要。不同的是,我会结合在工作中解决实际问题的一些体感,给出一点转行人不同视角的思考,希望能对同样想从工程入门算法的同学一点帮助。</p> <p>本文来自我的付费专栏《<a href="https://xiaobot.net/p/system-thinking">系统日知录</a>》,欢迎订阅查看更多大模型解析文章,文末有优惠券信息。</p> </blockquote> <p>本篇主要关注大模型的奠基之作——Transformer。</p> <p>首先要明确问题域,Transformer 试图解决的是序列建问题,最主要的代表就是语言建模和机器翻译。其次,需要知道前驱方法—— RNN(循环神经网络)和 CNN(卷积神经网络)存在的一些问题,才能知道 Transformer 的创新之处。最后,Transformer 的解决要点的在于“多头注意力机制”和“位置编码”。</p>

2025/9/10
阅读更多

Deep Dive Into Large Models 1: Transformer, the Foundation of Large Models

<blockquote> <p><a href="https://princeton-cos597r.github.io/"><strong>Princeton COS 597R “Deep Dive into Large Language Models”</strong></a> is a graduate course at Princeton University that systematically explores the principles of large language models, their preparation and training, architectural evolution, and applications in cutting-edge directions such as multimodality, alignment, tool use, and related issues. Note that this course focuses on conceptual understanding rather than engineering implementation.<br> I previously worked in distributed systems and database kernels, but in the past two years I moved to a large model company to work on data. These notes mainly consist of my organization and distillation of the course papers. What’s different is that I will combine some hands-on experience from solving practical problems at work, offering a bit of thinking from a career switcher’s perspective, hoping to help those who also want to enter algorithms from an engineering background.</p> <p>This article comes from my paid column “<a href="https://xiaobot.net/p/system-thinking">System Thinking Daily</a>”. Welcome to subscribe for more large model analysis articles; coupon information is at the end of the article.</p> </blockquote> <p>This article mainly focuses on the foundational work of large models — Transformer.</p> <p>First, we need to clarify the problem domain: what Transformer tries to solve is the <strong>sequence modeling</strong> problem, with the main representatives being language modeling and machine translation. Second, we need to know the problems existing in predecessor methods — RNN (Recurrent Neural Network) and CNN (Convolutional Neural Network) — in order to understand the innovation of Transformer. Finally, the key points of Transformer’s solution lie in the “multi-head attention mechanism” and “positional encoding”.</p>

2025/9/10
阅读更多

推荐订阅

Chen's Blog,分享安全领域的所思、所想、所学。

空鸣深语

无论你是游戏死忠,还是轻度的休闲玩家,在这里都能找到感兴趣的东西。

分享免费、小巧、实用、有趣、绿色的软件

Cloudflare 官方博客中文版,涵盖安全、AI 和开发者相关内容