<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>长上下文 on AI 观察</title><link>https://ai.wujiong.cc/tags/%E9%95%BF%E4%B8%8A%E4%B8%8B%E6%96%87/</link><description>Recent content in 长上下文 on AI 观察</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Tue, 14 Jul 2026 11:53:23 +0800</lastBuildDate><atom:link href="https://ai.wujiong.cc/tags/%E9%95%BF%E4%B8%8A%E4%B8%8B%E6%96%87/index.xml" rel="self" type="application/rss+xml"/><item><title>RAG 还是长上下文？两种方案的成本、效果与适用场景对比</title><link>https://ai.wujiong.cc/posts/2026-07-14-rag-vs-long-context/</link><pubDate>Tue, 14 Jul 2026 11:53:23 +0800</pubDate><guid>https://ai.wujiong.cc/posts/2026-07-14-rag-vs-long-context/</guid><description>&lt;p>随着大模型的上下文窗口扩展到数十万甚至百万 Token，一个问题被反复提起：&lt;strong>既然模型能一次读完整个知识库，还有必要费力搭建 RAG 吗？&lt;/strong> 答案取决于你的数据规模、使用频率和对准确性的要求。在大多数生产场景中，两者不是二选一，而是互相补充。&lt;/p>
&lt;h2 id="两种方案的基本思路">两种方案的基本思路&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>长上下文&lt;/strong>：把相关文档全部放进提示词，让模型自己阅读和寻找答案；&lt;/li>
&lt;li>&lt;strong>RAG&lt;/strong>：先根据问题检索出最相关的少量片段，只把这些片段交给模型。&lt;/li>
&lt;/ul>
&lt;h2 id="逐项对比">逐项对比&lt;/h2>
&lt;h3 id="成本">成本&lt;/h3>
&lt;p>长上下文方案每次请求都要为全部文档付费。如果同一批文档被频繁查询，成本会迅速累积。部分服务商提供的提示缓存功能可以降低重复部分的费用，但并非所有场景都适用。RAG 每次只发送少量片段，单次成本低得多，代价是需要建设和维护检索系统。&lt;/p></description></item></channel></rss>