<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>RAG on 老张开工了</title>
    <link>/rag/</link>
    <description>Recent content in RAG on 老张开工了</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sun, 07 Jun 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="/rag/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>上下文工程：RAG 与长上下文</title>
      <link>/posts/2026/06/context-engineering/</link>
      <pubDate>Sun, 07 Jun 2026 00:00:00 +0000</pubDate>
      <guid>/posts/2026/06/context-engineering/</guid>
      <description>如果说 prompt 工程是&amp;quot;怎么说话&amp;quot;，上下文工程就是&amp;quot;让模型能看到什么&amp;quot;。这是 2025–2026 年 AI 工程师的核心能力——因为模型能力本身已经够强，前 80% 的产出差距来自上下文喂得对不对。&#xA;4.1 三种获取&amp;quot;知识&amp;quot;的方式 模型要&amp;quot;知道事情&amp;quot;，只有三条路：&#xA;┌─────────────────────────────────────────────────────────────┐ │ 1. Pretrain ：训练时就背在脑子里了 │ │ 2. Context ：你这次对话贴进来，模型看到了 │ │ 3. Tool Call ：模型调用工具（搜索、读文件、grep）拿到结果 │ └─────────────────────────────────────────────────────────────┘ 三者构成一个预算三角：pretrain 是免费的但有时效与范围；context 是最贵但最准确；tool call 介于两者之间，但要模型&amp;quot;会调用&amp;quot;。&#xA;关键洞察：所有&amp;quot;AI 编程工具&amp;quot;——Cursor、Claude Code、Copilot Workspace、OpenCode——做的核心事都是这三种方式的自动调度。&#xA;4.2 RAG：检索增强生成 RAG 解决一个矛盾：你想让模型回答某个文档里的事，但塞全文进 context 太贵太脏。做法是先检索 → 拿到相关片段 → 把片段塞进 context。&#xA;# RAG 的极简伪代码 def answer(query: str, knowledge_base: list[str]) -&amp;gt; str: # 1. 把知识库切成 chunk 并预计算 embedding chunks = [chunk for doc in knowledge_base for chunk in split(doc, size=512)] chunk_embeddings = embed(chunks) # 2.</description>
    </item>
  </channel>
</rss>
