<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>珩宇的Blog</title>
        <link>https://notion-next-delta-six-93.vercel.app/</link>
        <description>HengYu coding</description>
        <lastBuildDate>Wed, 02 Sep 2026 07:40:37 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en-US</language>
        <copyright>All rights reserved 2026, 珩宇Coding</copyright>
        <item>
            <title><![CDATA[我的第一篇博客]]></title>
            <link>https://notion-next-delta-six-93.vercel.app/article/di-0-yi-pian-BLOG</link>
            <guid>https://notion-next-delta-six-93.vercel.app/article/di-0-yi-pian-BLOG</guid>
            <pubDate>Fri, 19 May 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[一篇博客也不知道写点啥，就先写一下如何建站的吧！ 首先，为啥要弄这个博客呢？ - 一个程序员的好奇心 - 真的想学点东西 - 装x 就是这几点原因造就了这个站点，下面说一下技术吧。  Hexo 这就不用多说了，点击快速建站Hexo。这是我接触到的第一个博客框架，没用过其他的，感觉上手还是挺简单的，官网介绍的比较详细，轻松运行]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-3744f74cf15e813ea23ac0943b583702"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><blockquote class="notion-quote notion-block-3b34f74cf15e8095a83fed43753d5335"><div>已迁移至NotionNext - 2026</div></blockquote><blockquote class="notion-quote notion-block-3744f74cf15e81bdb602d2e6f8b69300"><div><span class="notion-default">已迁移至Hugo - 2025</span></div></blockquote><div class="notion-text notion-block-3744f74cf15e8166a728e5c6bf1f6296"><span class="notion-default">第一篇博客也不知道写点啥，就先写一下如何建站的吧！</span></div><div class="notion-text notion-block-3744f74cf15e819e8614f70a1d83a5e0"><span class="notion-default">首先，为啥要弄这个博客呢？</span></div><ul class="notion-list notion-list-disc notion-block-3744f74cf15e8166b25dfada3e595fed"><li><span class="notion-default">一个程序员的好奇心</span></li></ul><ul class="notion-list notion-list-disc notion-block-3744f74cf15e81bb9e57fee490855281"><li><span class="notion-default">真的想学点东西</span></li></ul><ul class="notion-list notion-list-disc notion-block-3744f74cf15e8174bef9f5391971720a"><li><span class="notion-default">装x</span></li></ul><div class="notion-text notion-block-3744f74cf15e81789fe2fe0fec48bc85"><span class="notion-default">就是这几点原因造就了这个站点，下面说一下技术吧。</span></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3744f74cf15e81b08f50f6449ba96197" data-id="3744f74cf15e81b08f50f6449ba96197"><span><div id="3744f74cf15e81b08f50f6449ba96197" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3744f74cf15e81b08f50f6449ba96197" title="Hexo"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><span class="notion-default">Hexo</span></span></span></h3><div class="notion-text notion-block-3744f74cf15e81cdb2c6c8bdaf19226c"><span class="notion-default">这就不用多说了，点击快速建站</span><span class="notion-default"><a class="notion-link" href="https://hexo.io/zh-cn/index.html &quot;Hexo主页&quot;" target="_blank" rel="noopener noreferrer">Hexo</a></span><span class="notion-default">。这是我接触到的第一个博客框架，没用过其他的，感觉上手还是挺简单的，官网介绍的比较详细，轻松运行。</span></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3744f74cf15e8133b938d0dcfb20c3e7" data-id="3744f74cf15e8133b938d0dcfb20c3e7"><span><div id="3744f74cf15e8133b938d0dcfb20c3e7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3744f74cf15e8133b938d0dcfb20c3e7" title="主题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><span class="notion-default">主题</span></span></span></h3><div class="notion-text notion-block-3744f74cf15e8114a616ffb6122df707"><span class="notion-default">我用的是Fluid，点击</span><span class="notion-default"><a class="notion-link" href="https://hexo.fluid-dev.com/docs/start/#搭建-hexo-博客" target="_blank" rel="noopener noreferrer">Fluid官方介绍</a></span><span class="notion-default"> ，各主题应该大同小异可去Hexo官网选择。</span></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3744f74cf15e811a8c6de807047dedac" data-id="3744f74cf15e811a8c6de807047dedac"><span><div id="3744f74cf15e811a8c6de807047dedac" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3744f74cf15e811a8c6de807047dedac" title="站点计数与评论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><span class="notion-default">站点计数与评论</span></span></span></h3><div class="notion-text notion-block-3744f74cf15e81da8fc5cca3745f2779"><span class="notion-default">计数和评论放在一起是因为都用到了</span><span class="notion-default"><a class="notion-link" href="https://www.leancloud.cn" target="_blank" rel="noopener noreferrer">LeanCloud</a></span><span class="notion-default">，一个基于Docker的云计算平台，分国内版和海外版，我用的是海外版，因为不需要实名。计数和评论都调用了此平台的API，网上有很多其他博主写的详细教程。</span></div><div class="notion-text notion-block-3744f74cf15e81e5a60bfad398785b0e"><span class="notion-default">评论功能还用到了</span><span class="notion-default"><a class="notion-link" href="https://vercel.com/dashboard" target="_blank" rel="noopener noreferrer">Vercel</a></span><span class="notion-default">，一个网站托管服务，类似GitHub Pages，主要用它部署了</span><span class="notion-default"><a class="notion-link" href="https://waline.js.org" target="_blank" rel="noopener noreferrer">Waline</a></span><span class="notion-default">，一款简洁安全的评论系统，挺牛的系统，登录、回复、表情、图片、管理评论啥啥都有。</span></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3744f74cf15e81679d0ec925ad5edef5" data-id="3744f74cf15e81679d0ec925ad5edef5"><span><div id="3744f74cf15e81679d0ec925ad5edef5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3744f74cf15e81679d0ec925ad5edef5" title="域名"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><span class="notion-default">域名</span></span></span></h3><div class="notion-text notion-block-3744f74cf15e8108872dd2a03841256a"><span class="notion-default">之前申请过阿里、腾讯的域名，那一个麻烦申请过的朋友应该都清楚，也是准备建站的时候才了解到</span><span class="notion-default"><a class="notion-link" href="https://namesilo-china.com" target="_blank" rel="noopener noreferrer">NameSilo</a></span><span class="notion-default">，国外的一个域名服务网站，价格低，主要是续费也是差不多价格，学习使用域名的话，这个挺好的，还可以配置50个二级域名，自己玩够够的了。</span></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3744f74cf15e81e7abeedf29e69185d9" data-id="3744f74cf15e81e7abeedf29e69185d9"><span><div id="3744f74cf15e81e7abeedf29e69185d9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3744f74cf15e81e7abeedf29e69185d9" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><span class="notion-default">总结</span></span></span></h3><div class="notion-text notion-block-3744f74cf15e816da775e28c2c534a5a"><span class="notion-default">第一次写博客，不知道写啥，慢慢学习吧。</span></div><div class="notion-text notion-block-3744f74cf15e8199ae15d3230b8dc051"><span class="notion-default">上面说到的技术都是粗略介绍了一下，之后有时间或者有需求的话做个系列介绍。</span></div><div class="notion-text notion-block-3744f74cf15e81dfa1d9d8e27c3b3eff"><span class="notion-default">学习的时间不多，逐渐优化完善吧。</span></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[子代理与多智能体协作：我如何用 Agent 团队维护博客]]></title>
            <link>https://notion-next-delta-six-93.vercel.app/article/multi-agent-blog-maintenance</link>
            <guid>https://notion-next-delta-six-93.vercel.app/article/multi-agent-blog-maintenance</guid>
            <pubDate>Tue, 10 Feb 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[把博客维护拆给一支 AI 子代理团队：写作、审校、代码、部署各司其职，主代理编排验收，聊聊什么任务适合并行拆分，以及上下文隔离带来的好处。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-3b24f74cf15e81358381c43df45edf11"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-3b24f74cf15e812aba69fc49e7b53776">博客写到第三年，维护成本开始超过写作本身：旧文章要更新、错别字要校、主题代码要改、部署要盯。去年下半年 AI 编程工具的子代理（subagent）能力成熟后，我把博客维护拆给了一个「Agent 团队」，跑了小半年，聊聊怎么分工的，以及哪些地方其实不适合拆。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81ef9533e20f73823575" data-id="3b24f74cf15e81ef9533e20f73823575"><span><div id="3b24f74cf15e81ef9533e20f73823575" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81ef9533e20f73823575" title="为什么要拆：上下文隔离"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">为什么要拆：上下文隔离</span></span></h3><div class="notion-text notion-block-3b24f74cf15e8121bb52f1babf02c92e">最早我就是一个主 Agent 干所有事，问题很快暴露：<b>所有任务挤在同一个上下文里</b>。让它改完主题 CSS 再校对文章，上下文里全是代码细节，校对质量肉眼可见地下降；而且长上下文费 token、容易跑偏。</div><div class="notion-text notion-block-3b24f74cf15e81d386b3d2e81af124d6">子代理的核心价值不是「人多力量大」，而是<b>每个子代理带着干净的上下文上场</b>。校对代理的上下文里只有文章和校对规则，代码代理的上下文里只有仓库，互不污染。主代理只拿到它们返回的结论，自己的上下文保持精简。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e8195a718e562652d27cf" data-id="3b24f74cf15e8195a718e562652d27cf"><span><div id="3b24f74cf15e8195a718e562652d27cf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e8195a718e562652d27cf" title="我的分工"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">我的分工</span></span></h3><div class="notion-text notion-block-3b24f74cf15e8102878ac62cdde878b5">主代理负责编排：接需求、拆任务、派活、验收。下面四个专职：</div><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81d7a8c8fbfd427e2453"><li><b>写作代理</b>：按大纲出初稿，带博客的文体规范（第一人称、禁用 AI 腔）</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81c39dc1efdf1d72c8ab"><li><b>审校代理</b>：只读不改，输出错别字、时间线矛盾、事实存疑清单</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e8182bc0ec063cb1a02af"><li><b>代码代理</b>：主题样式和脚本改动，能跑构建命令自己验证</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81e5bcf1d0c2b8221c2a"><li><b>部署代理</b>：只碰构建和发布，权限收到最小</li></ul><div class="notion-text notion-block-3b24f74cf15e810aa041f124e8061acb">每个子代理就是一个带角色提示词的定义文件，例如审校代理：</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81c99a9bf3c3c0fd44a2" data-id="3b24f74cf15e81c99a9bf3c3c0fd44a2"><span><div id="3b24f74cf15e81c99a9bf3c3c0fd44a2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81c99a9bf3c3c0fd44a2" title="什么适合并行，什么必须串行"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">什么适合并行，什么必须串行</span></span></h3><div class="notion-text notion-block-3b24f74cf15e8138b01fc71032de7eca"><b>适合拆的</b>：相互独立、输入明确的任务。比如同时审校 5 篇旧文章，5 个审校代理并行跑，几分钟全回来；又比如「给 20 篇文章批量生成摘要」这种天然可分的活。</div><div class="notion-text notion-block-3b24f74cf15e818e9265fcf27636a8d4"><b>不适合拆的</b>：任务之间有强依赖，或者需求本身模糊。我试过让写作代理和审校代理「并行」处理同一篇新稿——审校拿到的是半成品，两边返工，比串行还慢。<b>判断标准很简单：B 的输入依赖 A 的产出，就别并行</b>。另外拆任务本身有成本：每个子代理都要重新加载背景，两分钟能写完的小段落，拆出去反而多花十分钟。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e8127b22aede3f7509b00" data-id="3b24f74cf15e8127b22aede3f7509b00"><span><div id="3b24f74cf15e8127b22aede3f7509b00" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e8127b22aede3f7509b00" title="踩过的坑"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">踩过的坑</span></span></h3><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e8130b84bc963f661ce6f"><li><b>子代理没有主代理的记忆</b>。派活时背景必须写全：文件路径、文体要求、边界条件。我一开始只写「校对一下这篇文章」，它把我博客里故意保留的港台译名全「修正」了</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81f4adb0e886d675bc98"><li><b>两个代理别同时写同一个文件</b>。并行写作时代码代理和写作代理同时改了同一篇带代码的文章，合并冲突搞了半天。现在的规矩：写文件的任务互斥，只读的任务随便并行</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e815682a2ebad1f4ab562"><li><b>主代理要验收，不能直接转发</b>。子代理返回的结果主代理得抽查再汇总，有次审校代理漏报了一个明显的版本错误，直接转给我就丢人了</li></ul><div class="notion-text notion-block-3b24f74cf15e81c1bd51dc21bf1bde38">现在的状态：一篇文章从初稿到发布，我只做两件事——给大纲、终审，中间环节 Agent 团队自己转，周末维护时间从一天缩到两小时。多智能体不是银弹，但对「流程固定、角色清晰」的重复劳动，它是真的好用。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RAG 进阶：分块、重排与混合检索调优笔记]]></title>
            <link>https://notion-next-delta-six-93.vercel.app/article/rag-tuning-chunk-rerank</link>
            <guid>https://notion-next-delta-six-93.vercel.app/article/rag-tuning-chunk-rerank</guid>
            <pubDate>Tue, 21 Oct 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[RAG 系统调优实录：语义分块、向量加 BM25 混合检索、rerank 重排三步走，用自建评测集量化每一步的召回提升，先修分块再修检索。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-3b24f74cf15e817b9eecea3026743c01"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-3b24f74cf15e81dd9374ee2b04555466">去年我给博客知识库做了个入门版 RAG：固定 500 字分块 + 向量检索，demo 很好看，真用起来经常答非所问。最近花了两周做系统性调优，用自建评测集量化了每一步的收益，记录一下。</div><div class="notion-text notion-block-3b24f74cf15e81e193f6fca2d5e6ea41">先说评测：<b>没有评测集，调优就是瞎蒙</b>。我从真实提问记录里挑了 60 个问题，人工标注每个问题对应的正确文档片段，指标用「召回命中率」：检索结果里是否包含标注片段。后面每个数字都是拿它跑出来的。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81b2bfd8f16fec854fa5" data-id="3b24f74cf15e81b2bfd8f16fec854fa5"><span><div id="3b24f74cf15e81b2bfd8f16fec854fa5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81b2bfd8f16fec854fa5" title="第一步：分块，从「固定」到「语义」"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第一步：分块，从「固定」到「语义」</span></span></h3><div class="notion-text notion-block-3b24f74cf15e811991bde0877b45a136">原来的固定分块有个致命问题：一个知识点经常被拦腰切断，前后两块各自语义残缺。改成语义分块——按 Markdown 标题层级切段，段落超过 800 字再按句号二次切分，块间保留 80 字重叠。</div><div class="notion-text notion-block-3b24f74cf15e8111a178d5b80f72b693"><b>召回命中率：68% → 76%</b>。收益比预期大，因为很多「差一点命中」的 case，其实是块边界把答案切碎了。</div><div class="notion-text notion-block-3b24f74cf15e81219764e7161cf6a752"><b>注意点</b>：语义分块不是越小越好。块太小会丢上下文（比如代码块和它的说明文字被拆开），我给代码块加了特殊处理，不允许从中间切开。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e8117a3f7e3775ad8f0c3" data-id="3b24f74cf15e8117a3f7e3775ad8f0c3"><span><div id="3b24f74cf15e8117a3f7e3775ad8f0c3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e8117a3f7e3775ad8f0c3" title="第二步：混合检索，向量 + BM25"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第二步：混合检索，向量 + BM25</span></span></h3><div class="notion-text notion-block-3b24f74cf15e81caadacf534030bfa5e">向量检索擅长语义相近，但遇到<b>精确关键词</b>会翻车：错误码、配置项名这种字符串，向量模型看来就是一串乱码，相似度乱打。这类 query 正是关键词检索 BM25 的主场。</div><div class="notion-text notion-block-3b24f74cf15e81e6bec7c5ebd4c73535">做法是两路各召回 top 20，用 RRF(Reciprocal Rank Fusion）融合：</div><div class="notion-text notion-block-3b24f74cf15e8133b2eae1bbe7348cb3"><b>召回命中率：76% → 85%</b>。提升全部来自那些含专有名词、错误码的问题，语义类问题基本持平——符合预期。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81408abdcf3fe9c59a85" data-id="3b24f74cf15e81408abdcf3fe9c59a85"><span><div id="3b24f74cf15e81408abdcf3fe9c59a85" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81408abdcf3fe9c59a85" title="第三步：Rerank 重排"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第三步：Rerank 重排</span></span></h3><div class="notion-text notion-block-3b24f74cf15e81f28292d0784d232df7">前两步解决「找得到」，重排解决「排得前」。向量相似度是粗排，我加了 bge-reranker-v2-m3 做精排：把 query 和候选块逐对打分，融合后的 top 20 重排，取 top 5 进上下文。</div><div class="notion-text notion-block-3b24f74cf15e813abb1ff02e2dea6e46"><b>召回命中率（top 5):85% → 92%</b>。重排模型吃算力，我在本地用 CPU 跑，20 个候选大概 1.5 秒，能接受；对延迟敏感的场景可以换更小的 reranker，或者只重排 top 10。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81009533c6fa9de21f00" data-id="3b24f74cf15e81009533c6fa9de21f00"><span><div id="3b24f74cf15e81009533c6fa9de21f00" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81009533c6fa9de21f00" title="汇总与心得"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">汇总与心得</span></span></h3><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81d0bb52d63c2a07fb1d"><li>固定分块基线：68%</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e8167b702df1d986d379e"><li>语义分块：76%(+8)</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81d78070c821eb36f045"><li>混合检索：85%(+9)</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e817e9430e42268029fe4"><li>Rerank:92%(+7)</li></ul><div class="notion-text notion-block-3b24f74cf15e81bc81aac39441d0270c">三步都是「每一步修一类明确的失败 case」，而不是玄学调参。顺序也有讲究：<b>先修分块再修检索</b>，分块质量是上限，检索和重排只是在逼近这个上限。另外每改一步都重跑评测集——有一次我「顺手优化」了重叠长度，命中率掉了 3 个点，没有评测集根本发现不了。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[用 AI 学英语：我的 Anki + LLM 组合拳]]></title>
            <link>https://notion-next-delta-six-93.vercel.app/article/ai-english-learning-anki</link>
            <guid>https://notion-next-delta-six-93.vercel.app/article/ai-english-learning-anki</guid>
            <pubDate>Tue, 09 Sep 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[我的英语词汇学习流程：阅读中收集生词，让 LLM 批量生成带词根拆解和例句的卡片，导入 Anki 间隔重复，半年词汇量从 5500 涨到 8000。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-3b24f74cf15e81158174f422a37a154d"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-3b24f74cf15e8178974bd0095f94b157">做后端开发的，英语是绕不过去的坎：文档、RFC、论文、GitHub issue 全是英文。我的词汇量一直停在「连蒙带猜能读」的水平，今年初下决心系统补一下。折腾了几轮，最后稳定下来的组合是：<b>阅读中收集生词 → LLM 生成卡片 → Anki 间隔重复</b>。坚持半年，说说具体做法。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81f3916ef3b97d1976d7" data-id="3b24f74cf15e81f3916ef3b97d1976d7"><span><div id="3b24f74cf15e81f3916ef3b97d1976d7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81f3916ef3b97d1976d7" title="流程总览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">流程总览</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-3b24f74cf15e8149a86cf6945b874d64" style="list-style-type:decimal"><li>平时读英文文档和文章，遇到「看着眼熟但想不起来」的词，随手记到一个 txt 里，一行一个词，带上出处句子</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-3b24f74cf15e8181b6c3d9489632421a" style="list-style-type:decimal"><li>攒到 20~30 个，丢给 LLM，用固定模板批量生成卡片</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-3b24f74cf15e81b9a21febf5fad349f6" style="list-style-type:decimal"><li>导出成 TSV，导入 Anki，每天刷牙后复习 15 分钟</li></ol><div class="notion-text notion-block-3b24f74cf15e81898a3de0bf52e3a233">关键思路：<b>生词必须来自自己的真实阅读</b>。直接背词表我试过，记不住也用不上；自己阅读中遇到的词有上下文加持，记得牢得多。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e8146b7e1d7ff38b616a9" data-id="3b24f74cf15e8146b7e1d7ff38b616a9"><span><div id="3b24f74cf15e8146b7e1d7ff38b616a9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e8146b7e1d7ff38b616a9" title="卡片怎么生成"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">卡片怎么生成</span></span></h3><div class="notion-text notion-block-3b24f74cf15e816d813fc02e6542b9ba">卡片正面是单词和音标，背面是释义、词根拆解和例句。我的 prompt 模板：</div><div class="notion-text notion-block-3b24f74cf15e81f3be84f073bbc9ba42">生成的内容直接存成 <code class="notion-inline-code">.tsv</code>,Anki 里「文件 → 导入」选 Tab 分隔，字段映射到卡片模板即可，一次两分钟搞定。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e814a89acd94840563215" data-id="3b24f74cf15e814a89acd94840563215"><span><div id="3b24f74cf15e814a89acd94840563215" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e814a89acd94840563215" title="为什么 LLM 在这里比词典好用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">为什么 LLM 在这里比词典好用</span></span></h3><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81a085dbdf7fea596b6d"><li><b>词根拆解</b>是词典给不了的。比如 <code class="notion-inline-code">idempotent</code>（幂等）,LLM 会拆成 <code class="notion-inline-code">idem</code>（相同）+ <code class="notion-inline-code">potent</code>（能力），再顺手关联 <code class="notion-inline-code">identical</code>，一串词就盘活了</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81d2a3acdde648dcef32"><li><b>例句可控</b>：让例句限定在编程语境，读技术文章时能直接碰上，形成闭环</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81259e74ec28ccd5db05"><li><b>批量</b>：一次 30 个词，手工做卡片要一晚上</li></ul><div class="notion-text notion-block-3b24f74cf15e816da6c0f9dd52f38db6"><b>注意点：LLM 会编错</b>。我碰到过音标标错、词根乱拆（把 <code class="notion-inline-code">cache</code> 硬拆成不存在的词根）的情况。所以现在每张卡片导入前我会扫一眼，拿不准的查一下词典，三十张卡抽查大概十分钟。千万别闭着眼睛全信。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e8185b7b7dec74b42161c" data-id="3b24f74cf15e8185b7b7dec74b42161c"><span><div id="3b24f74cf15e8185b7b7dec74b42161c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e8185b7b7dec74b42161c" title="半年之后"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">半年之后</span></span></h3><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81d8b45dc17e7270d528"><li>Anki 里积累了 1400 多张卡，每天复习量稳定在 80~100 张（新卡控制在每天 15 张，再多复习会堆成山）</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81cd93c2d58717d75933"><li>用词汇量测试网站测，从年初的 5500 左右涨到 8000 上下</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e8111b28bd6be741498ec"><li>最明显的变化不是数字：读英文文档时「卡住查词」的频率大概降了一半，长文能一口气读下来了</li></ul><div class="notion-text notion-block-3b24f74cf15e8157a6d9d7aada7a912a">背单词这事没有任何技巧能替代重复，LLM 只是帮你把「值得重复的材料」生产出来。工具省下来的时间，都得老老实实还给复习。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[上下文工程：比 Prompt 更重要的是给模型什么信息]]></title>
            <link>https://notion-next-delta-six-93.vercel.app/article/context-engineering-notes</link>
            <guid>https://notion-next-delta-six-93.vercel.app/article/context-engineering-notes</guid>
            <pubDate>Tue, 19 Aug 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[从 prompt engineering 到 context engineering：如何组织系统提示、检索与记忆，为什么上下文窗口不是越大越好，以及压缩裁剪策略。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-3b24f74cf15e81489847fd0157cd3cfc"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-3b24f74cf15e817a9e57c6092d93775d">去年大家还在卷 prompt engineering，各种「万能 prompt 模板」满天飞。今年风向明显变了，业内开始讲 context engineering（上下文工程）——Karpathy 和 Shopify 的 CEO 都聊过这个词。我自己的体感也一样：同一个模型，prompt 改来改去提升有限，但把「喂给它什么信息」理清楚之后，效果立刻不一样。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e8190935fd8ae6d678d3a" data-id="3b24f74cf15e8190935fd8ae6d678d3a"><span><div id="3b24f74cf15e8190935fd8ae6d678d3a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e8190935fd8ae6d678d3a" title="上下文里装的到底是什么"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">上下文里装的到底是什么</span></span></h3><div class="notion-text notion-block-3b24f74cf15e81efa344d9bbbd7452af">一次 LLM 调用的输入，远不止你敲的那句话：</div><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e811697b0f35727674441"><li>系统提示：角色、规则、输出格式</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e8115a7bbd7a354da45a2"><li>工具定义：函数签名和描述</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81a5a887e187b39d1811"><li>检索结果：RAG 捞回来的文档片段</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e817686ccd4b52ff5236f"><li>记忆：用户偏好、历史结论</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e813784ace29c6f42d194"><li>对话历史：包括之前每一轮工具的返回</li></ul><div class="notion-text notion-block-3b24f74cf15e811f92abde9649eba393">prompt engineering 关注的是「最后那句指令怎么写」;context engineering 关注的是<b>这一整盘东西怎么组织、放什么、不放什么</b>。模型没有自己的信息来源，你塞给它什么，它的世界就是什么。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e815e8dcbc27717608e27" data-id="3b24f74cf15e815e8dcbc27717608e27"><span><div id="3b24f74cf15e815e8dcbc27717608e27" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e815e8dcbc27717608e27" title="窗口不是越大越好"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">窗口不是越大越好</span></span></h3><div class="notion-text notion-block-3b24f74cf15e8193b265c32fca1235fb">现在模型动不动上百万 token 的窗口，很容易产生「全塞进去再说」的冲动。我的教训是别这么做。</div><div class="notion-text notion-block-3b24f74cf15e81d0880bf4cf0ab08008">2023 年那篇 Lost in the Middle 的论文就指出，模型对上下文<b>开头和结尾的内容印象最深，中间部分容易「迷失」</b>。我在自己的知识库问答里验证过：检索结果从 3 段加到 15 段，答案质量不升反降，模型经常引用错片段。</div><div class="notion-text notion-block-3b24f74cf15e8127861ec0a4bfde33b6">另外两个现实问题：</div><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81c4bd52d0b4fb5e1e2b"><li><b>成本线性增长</b>:10 万 token 的输入，每轮对话都重新计费</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e812eae7bd3ca22ff1415"><li><b>噪声稀释信号</b>：无关内容越多，模型越容易被带偏</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81f5babafe5d1ee7ce00" data-id="3b24f74cf15e81f5babafe5d1ee7ce00"><span><div id="3b24f74cf15e81f5babafe5d1ee7ce00" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81f5babafe5d1ee7ce00" title="实战中的压缩与裁剪"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">实战中的压缩与裁剪</span></span></h3><div class="notion-text notion-block-3b24f74cf15e8193925ed3ef5f5e5715">我现在组上下文的策略，按收益排序：</div><ol start="1" class="notion-list notion-list-numbered notion-block-3b24f74cf15e8104ba99e9c66485508b" style="list-style-type:decimal"><li><b>先删再加</b>。历史消息里的工具返回（比如一整段命令输出、整个文件的 dump）在后续轮次里直接裁掉或换成一行摘要，它们大多已经完成使命了</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-3b24f74cf15e81d6b60cfa4276d3e1bd" style="list-style-type:decimal"><li><b>检索求精不求多</b>。RAG 只放 top 3~5，宁可少放</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-3b24f74cf15e81dea9d0d66a1c4d9500" style="list-style-type:decimal"><li><b>稳定内容往前放</b>。系统提示、工具定义这些不变的内容放最前面，还能吃到 KV cache 的前缀命中，省钱</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-3b24f74cf15e81d0bb5fda920e90b694" style="list-style-type:decimal"><li><b>记忆结构化</b>。别记流水账，维护一份几十行的「用户档案/项目状态」文档，每轮更新，比塞 50 轮历史对话有效得多</li></ol><div class="notion-text notion-block-3b24f74cf15e8102953de94b3003f556">一个简化版的组装逻辑大概长这样：</div><div class="notion-text notion-block-3b24f74cf15e819e9e85efd716354278"><b>最大的坑</b>是我曾把一个工具返回的两万行日志原样留在上下文里，后面每一轮都带着它计费，模型还总拿日志里的旧错误说事。加了一行「工具返回超过 500 token 自动截断」之后，成本降了一半，答案反而更准。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81aaaae8e8b5f6c51643" data-id="3b24f74cf15e81aaaae8e8b5f6c51643"><span><div id="3b24f74cf15e81aaaae8e8b5f6c51643" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81aaaae8e8b5f6c51643" title="一句话总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一句话总结</span></span></h3><div class="notion-text notion-block-3b24f74cf15e81b4aec6c6766feedd61">prompt 是「怎么问」,context 是「给它看什么」。模型能力差不多的情况下，后者的差距就是应用效果的差距。与其收藏 prompt 模板，不如花时间把你喂给模型的信息管好。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[结构化输出与 JSON Schema：把 LLM 接进后端接口的正确姿势]]></title>
            <link>https://notion-next-delta-six-93.vercel.app/article/llm-structured-output-backend</link>
            <guid>https://notion-next-delta-six-93.vercel.app/article/llm-structured-output-backend</guid>
            <pubDate>Tue, 24 Jun 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[把 LLM 接进 .NET 后端的实践：用 JSON Schema 强约束输出，强类型反序列化加业务校验与重试，告别靠 prompt 求 JSON。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-3b24f74cf15e812ab4fcc008a39bdcb7"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-3b24f74cf15e81fda9e4d593c40bfed7">最近在做一个功能：从用户粘贴的网页正文里抽取标题、标签和摘要，存进博客数据库。调大模型做抽取不难，难的是接口的返回值要被代码消费——必须能稳定反序列化成强类型，一次都不能崩。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81e0ba26d7038634a74a" data-id="3b24f74cf15e81e0ba26d7038634a74a"><span><div id="3b24f74cf15e81e0ba26d7038634a74a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81e0ba26d7038634a74a" title="早期做法：靠 prompt 求 JSON"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">早期做法：靠 prompt 求 JSON</span></span></h3><div class="notion-text notion-block-3b24f74cf15e81a3ada5c396ce5ffd67">最开始我的做法是祖传 prompt：</div><blockquote class="notion-quote notion-block-3b24f74cf15e813a8baded9f9b670674"><div>请严格按照以下 JSON 格式返回，不要输出任何其他内容……</div></blockquote><div class="notion-text notion-block-3b24f74cf15e81429c80e090fdbd90a5">然后 C# 里 <code class="notion-inline-code">JsonSerializer.Deserialize&lt;T&gt;(content)</code>。跑十次能成九次，剩下一次可能是：外面包了层 markdown 代码块标记、JSON 前面多了句「好的，以下是结果」、或者字段名给你换成中文。线上接口可不能接受 90% 的成功率，只能写一堆正则兜底，越写越丑。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81dcbbc2c3bac2ca9d70" data-id="3b24f74cf15e81dcbbc2c3bac2ca9d70"><span><div id="3b24f74cf15e81dcbbc2c3bac2ca9d70" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81dcbbc2c3bac2ca9d70" title="Structured Outputs：让 schema 成为硬约束"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Structured Outputs：让 schema 成为硬约束</span></span></h3><div class="notion-text notion-block-3b24f74cf15e814b8dc4c8964dd5ddf3">OpenAI 在 2024 年 8 月推出了 Structured Outputs：请求时把 JSON Schema 传给 <code class="notion-inline-code">response_format</code>，模型输出被约束在 schema 内，<b>格式层面保证合法</b>。我这边用的是官方 OpenAI .NET SDK(2.x)：</div><div class="notion-text notion-block-3b24f74cf15e8133b713cde38bcc37f0">到这里反序列化基本不会再炸了。<b>注意点：strict 模式下 `required` 必须列出所有字段</b>，可选字段要用 <code class="notion-inline-code">[&quot;string&quot;, &quot;null&quot;]</code> 这样的类型并集表达，我第一次写就因为漏了 required 被直接拒绝。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e814cbcf6ed75a5c44921" data-id="3b24f74cf15e814cbcf6ed75a5c44921"><span><div id="3b24f74cf15e814cbcf6ed75a5c44921" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e814cbcf6ed75a5c44921" title="格式合法不等于内容正确"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">格式合法不等于内容正确</span></span></h3><div class="notion-text notion-block-3b24f74cf15e81679cf2fe2a3ae649fa">Schema 只能保证「是合法 JSON 且字段齐全」，保证不了「tag 不超过 5 个」「summary 不超过 200 字」这种业务规则。所以校验分两层：schema 层交给模型提供方，业务层自己写，失败就重试，重试时把错误原因带回去：</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3b24f74cf15e81e0affcd7a4527b211a" data-id="3b24f74cf15e81e0affcd7a4527b211a"><span><div id="3b24f74cf15e81e0affcd7a4527b211a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b24f74cf15e81e0affcd7a4527b211a" title="一些经验"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一些经验</span></span></h3><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81f09c1ae686108401f8"><li>模型选便宜的就够：<code class="notion-inline-code">gpt-4o-mini</code> 做抽取绰绰有余，别把预算花在格式上</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e81ad8df5e45cce69927d"><li>Schema 里给每个字段写 <code class="notion-inline-code">description</code> 说清语义，抽取质量明显更好</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e8153af98c8e50ee463b7"><li>重试不是万能的：prompt 本身有歧义时，重试三次也是错三次，先把指令写清楚</li></ul><ul class="notion-list notion-list-disc notion-block-3b24f74cf15e8124b83efd0bf8e5889a"><li>留好原始返回的日志，线上排查全靠它</li></ul><div class="notion-text notion-block-3b24f74cf15e818e87e6d16f58086cfb">从「求模型返回 JSON」到「用 schema 约束 JSON」，改动不过几十行代码，但接口的稳定性从「祈祷」变成了「可承诺」。这是我觉得今年把 LLM 接进后端最值得做的一件事。</div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>