<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Context Window on KbWen Blog</title>
    <link>https://www.kbwen.com/tags/context-window/</link>
    <description>KbWen 的個人技術部落格，分享 Python、機器學習、深度學習、資料工程與 AI 開發的學習筆記與實作心得。</description>
    <generator>Hugo</generator>
    <language>zh-tw</language>
    <image>
      <url>https://www.kbwen.com/images/og-default.png</url>
      <title>KbWen Blog</title>
      <link>https://www.kbwen.com/</link>
    </image>
    
    <lastBuildDate>Sat, 20 Jun 2026 09:45:00 +0800</lastBuildDate><atom:link href="https://www.kbwen.com/tags/context-window/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Why Does AI Forget What You Said Earlier?</title>
      <link>https://www.kbwen.com/why-does-ai-forget-what-you-said/</link>
      <pubDate>Sat, 20 Jun 2026 09:45:00 +0800</pubDate><dc:creator>KbWen</dc:creator>
      <guid>https://www.kbwen.com/why-does-ai-forget-what-you-said/</guid>
      <description>Chat with an AI long enough and it ignores the rules you set up top; open a new chat and it&amp;#39;s blank. It isn&amp;#39;t &amp;#39;forgetting&amp;#39; — it has no memory. Every reply, it re-reads the whole conversation from scratch. Here&amp;#39;s what the context window is, and how it differs from ChatGPT&amp;#39;s &amp;#39;memory&amp;#39; feature.</description>
      <content:encoded><![CDATA[<blockquote>
<p><strong>TL;DR</strong>: It isn&rsquo;t &ldquo;forgetting&rdquo; — it has no memory at all. Every time it replies, it re-reads the entire conversation from the top and continues from there; &ldquo;remembering&rdquo; is just the side effect of having re-read it a moment ago. The catch is there&rsquo;s a ceiling on how much it can take in at once, called the context window. In a long chat the oldest part gets pushed past that ceiling, so this turn it never read it. Not because it&rsquo;s dumb. That part just wasn&rsquo;t in front of it.</p>
</blockquote>
<p>You&rsquo;ve probably had this happen. You start a chat and lay out the rules up top — &ldquo;reply in English only, no emoji&rdquo; — and it behaves for a while. Twenty turns later the emoji are back. Or you open a fresh chat to finish yesterday&rsquo;s conversation, and it stares back blank, as if none of it ever happened.</p>
<p>&ldquo;How did it forget already?&rdquo; But &ldquo;forget&rdquo; is the wrong word. To forget something, you have to have remembered it first. And it never did.</p>
<h2 id="it-re-reads-everything-from-scratch-every-time">It re-reads everything from scratch, every time</h2>
<p>Here&rsquo;s the part that sounds backwards at first: it has no memory. You and it go back and forth for an hour, and there&rsquo;s nothing stored in its head about where you&rsquo;ve been.</p>
<p>So how does it keep up? Because each time it&rsquo;s your turn for a reply, what happens behind the scenes is that your whole conversation so far gets handed back to it, top to bottom, and it reads the lot before writing the next line. The instant it finishes reading, it &ldquo;knows&rdquo; what came before. But it didn&rsquo;t remember that; it just re-read it a second ago.</p>
<p>Picture an amnesiac who reads fast. Every time you walk up, you hand him the whole notebook of the conversation so far. He reads it cover to cover, looks up, says his one line. In that moment he genuinely follows where you&rsquo;ve been. But nothing&rsquo;s kept in his head; it&rsquo;s all in that notebook. Walk up again, hand it over again. Underneath, all the model ever does is read what&rsquo;s in front of it and write the next word that fits.</p>
<h2 id="the-notebook-has-a-limit">The notebook has a limit</h2>
<p>The thing is, that &ldquo;conversation notebook&rdquo; can&rsquo;t be infinitely long.</p>
<p>There&rsquo;s a ceiling on how much it can take in at once, and that ceiling is the <strong>context window</strong>. It&rsquo;s measured in tokens (a token being the chunk of text the model actually reads, not quite the same as a word). These windows are big now; in ordinary back-and-forth you&rsquo;ll rarely fill one. But paste in a long document, or talk long enough, and the total runs past the ceiling. Now the app has to cut something. Usually it drops the oldest messages first (this varies: some apps cut them outright, some compress them into a short summary and keep that). Whatever got cut, the model genuinely didn&rsquo;t read this turn.</p>
<p>So those rules you set up top quietly &ldquo;stop working&rdquo; in a long chat, not because it&rsquo;s being rebellious, but because that line slid out of the window and never reached it this round. It didn&rsquo;t ignore you. It didn&rsquo;t see it.</p>
<h2 id="that-memory-feature-is-a-different-thing">That &ldquo;Memory&rdquo; feature is a different thing</h2>
<p>Worth separating out, because it&rsquo;s easy to confuse with the window.</p>
<p>&ldquo;But doesn&rsquo;t ChatGPT have a memory feature?&rdquo; It does — and it&rsquo;s a different layer from the context window we&rsquo;re talking about. That Memory feature (<a href="https://openai.com/index/memory-and-new-controls-for-chatgpt/">OpenAI describes it here</a>) is more like a cheat sheet it keeps about you. You mention &ldquo;I&rsquo;m a developer,&rdquo; &ldquo;I prefer British spelling,&rdquo; and it files that away, then slips it back in when you start a new chat. It&rsquo;s long-term and spans conversations: a condensed set of notes, not a transcript of everything you&rsquo;ve ever said.</p>
<p>The context window, by contrast, is just &ldquo;how much it can see this one turn.&rdquo; When a brand-new chat forgets everything, that&rsquo;s because this turn&rsquo;s notebook is blank. The cheat sheet may still be around, but that&rsquo;s just those few stored facts, not the whole discussion you had yesterday.</p>
<h2 id="so-what-do-you-actually-do-about-it">So what do you actually do about it</h2>
<p>Once you&rsquo;ve got that it has no memory and just re-reads, the annoying stuff stops being mysterious.</p>
<p>To make it hold onto a key setting, the dumbest and most reliable move is to put it back in front of it. Restate the important rules every so often; when you open a new chat, bring a few lines of recap with you. Open with something like &ldquo;Context: I&rsquo;m writing a polite-but-firm rejection email, keep it all in English.&rdquo; That&rsquo;s not because it&rsquo;s too dim to remember; it&rsquo;s that you&rsquo;re making sure the instruction is actually in this turn&rsquo;s notebook.</p>
<p>And when a chat gets long and starts contradicting itself, you&rsquo;re better off starting a clean one with a short recap pasted up top than wrestling the bloated one. Fresh page, clean window. Its other quirks, like <a href="/why-does-ai-give-different-answers/">giving you a different answer every time you ask the same thing</a>, run on separate machinery and aren&rsquo;t about memory at all. (If you want the practical side of juggling all this, I wrote up <a href="/how-i-use-chatgpt-claude-gemini/">how I actually use ChatGPT, Claude, and Gemini day to day</a>.)</p>
<p>The short version: it isn&rsquo;t that its memory is bad. It has no memory to use. Every line it writes, it re-reads what&rsquo;s in front of it and continues. What it can see, it works from. Whatever never made it into the notebook never happened, as far as it&rsquo;s concerned. So next time it &ldquo;forgets&rdquo; something you said, put the line back in front of it. It&rsquo;ll pick right up.</p>
<p><em>中文版：<a href="/why-ai-forgets-what-you-said/">為什麼 AI 會忘記我前面說過的話？</a></em></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>為什麼 AI 會忘記我前面說過的話？</title>
      <link>https://www.kbwen.com/why-ai-forgets-what-you-said/</link>
      <pubDate>Sat, 20 Jun 2026 09:30:00 +0800</pubDate><dc:creator>KbWen</dc:creator>
      <guid>https://www.kbwen.com/why-ai-forgets-what-you-said/</guid>
      <description>跟 AI 聊久了，它就忘記你開頭交代的事；開新對話更是整個忘光。其實它不是「忘記」，是它根本沒有記憶——每次回你都是把整段對話重讀一遍。用一個失憶但讀很快的人的畫面，聊聊 context window 是什麼，還有它跟 ChatGPT 那個「記憶」功能差在哪。</description>
      <content:encoded><![CDATA[<blockquote>
<p><strong>TL;DR</strong>：它不是「忘記」，是它根本沒有記憶。每次回你話，它做的是把整段對話從頭重讀一遍，再接下去寫。所謂「記得」，不過是每次都重看了一次。問題是它一次能讀進去的量有上限，這個範圍叫 context window（上下文視窗）。對話太長，最舊的部分就被擠出去、它這次根本沒讀到。所以與其說它「忘了」，不如說那段話從頭到尾就沒進到它眼前。</p>
</blockquote>
<p>這事你八成碰過。跟 AI 聊一個東西，開頭你交代清楚「全部用繁體中文、不要 emoji」，它前幾輪乖乖的；聊著聊著，十幾二十輪過去，又開始冒簡體、撒 emoji。或者更乾脆——昨天跟它討論到一半的事，今天開個新對話再問，它一臉茫然，好像那段話從沒發生過。</p>
<p>你會很自然地說「它怎麼又忘了」。但「忘記」這個詞有點誤導：要先「記得」過，才談得上忘。而它呢……其實從來沒有記得。</p>
<h2 id="它每次都是從頭讀一遍">它每次都是從頭讀一遍</h2>
<p>先講一件反直覺的事：它沒有記憶。你跟它聊了半天，它腦袋裡沒存著「我們剛剛聊到哪」。</p>
<p>那它怎麼接得上話？因為每次輪到它回你，背後是把你們從開頭到現在的整段對話，原封不動再餵它讀一遍，從頭讀到尾，然後往下接一句。它讀完那一瞬間「知道」前面發生了什麼，但那不是記住，是剛剛又重看了一次。</p>
<p>打個比方。它比較像一個失憶、但讀很快的人。你每次去找他，都把你們從頭到現在的對話紀錄整本塞給他，他飛快翻完，抬頭回你一句。那一刻他是真懂了你們聊到哪；可他腦子裡什麼都沒留，全靠手上那本。你下次再來，又是重新塞一次。它骨子裡一直在做的，就是讀完眼前這串、然後<a href="/llm-predicts-next-token/">接下去寫最順的那個字</a>而已。</p>
<h2 id="那本紀錄有塞不下的時候">那本紀錄，有塞不下的時候</h2>
<p>問題來了：那本「對話紀錄」不能無限長。</p>
<p>它一次能讀進去的量是有上限的，這個上限就叫 <strong>context window</strong>，上下文視窗。算的單位是 token——也就是它眼裡的文字小塊，不完全等於一個字（這個我在 <a href="/what-is-token-in-llm/">Token 是什麼</a> 裡聊得比較細，<a href="/why-ai-cant-count-letters/">草莓數 r 那篇</a>也有個積木的比喻，這篇不看也不影響）。</p>
<p>現在這個視窗開得很大，一般閒聊很難塞爆。但只要你貼了一篇長文、或一路聊了很久很久，總量超過上限，系統就得動手砍——通常是把最舊的對話先丟掉（各家做法不太一樣，有的直接砍掉、有的先壓成一小段摘要再留著）。被丟掉的那一段，它這一輪是真的沒讀到。</p>
<p>所以你開頭交代的那些規矩，聊太長之後會慢慢「失效」，多半是那句話早就滑出視窗，這一輪根本沒進到它眼前。它不是叛逆，就只是沒看到。</p>
<h2 id="那個記憶功能是另一回事">那個「記憶」功能，是另一回事</h2>
<p>你可能會說：「ChatGPT 不是有記憶功能嗎？」有，但那個跟我們在講的 context window 不是同一層的東西。</p>
<p>那個記憶（Memory）功能，比較像它幫你另外整理的一份小抄（<a href="https://openai.com/index/memory-and-new-controls-for-chatgpt/">OpenAI 官方有說明這功能</a>）。你說過「我是寫程式的」「我習慣用繁中」，它記下來，之後每開新對話，偷偷把這些塞回去提醒自己。那是跨對話、長期留著的東西，而且是濃縮過的重點，不是你們每一句話的逐字稿。</p>
<p>context window 則是「這一次，它眼前能看多少」。這兩個常被當成同一回事，其實根本不在同一層。你新開一個對話它忘得一乾二淨，就因為這一次的對話紀錄是空白的——那份小抄也許還在，但它頂多是幾條濃縮的重點，不是你們昨天那整段對話。</p>
<h2 id="知道這件事之後可以怎麼用">知道這件事之後，可以怎麼用</h2>
<p>想通它沒記憶、全靠重讀，有些原本很煩的狀況就順了。</p>
<p>要它記住某個關鍵設定，最土也最有效的辦法就是「再貼一次」。重要的規矩，過一陣子重申一遍；開新對話時，把前情提要濃縮成幾句帶上去（像開頭先丟一句「承上次：我在寫一封婉拒信，語氣要客氣但堅定，全程用繁中」，把關鍵設定一次交代清楚）。這不是它笨到要你複述，是你得確保那段話這一輪真的出現在它面前——出現了，它就讀得到。</p>
<p>還有一招：一個對話聊到又臭又長、前後打架的時候，與其在裡面跟它盧，不如乾脆開個乾淨的新對話，把目前的結論濃縮成幾句貼進去重來。新的一頁、乾淨的視窗，往往比硬聊下去清爽得多。</p>
<p>至於它另外那些怪，比方同一個問題<a href="/why-ai-gives-different-answers/">每次答案都不一樣</a>，那是別的機制，跟記不記得無關，這篇就先不岔過去了。</p>
<p>說到底，它的毛病不是記性差，是壓根沒在用記性那套東西。每接一句話，它都是把眼前那本對話重讀一遍，再往下接。讀得到的就接得上，沒讀到的，對它來說就等於沒發生過。下次它又「忘了」你前面講的，先別急著嫌。多半是那句話這輪沒擺到它眼前；你補回去，它就接得回來。</p>
<p><em>English version: <a href="/why-does-ai-forget-what-you-said/">Why Does AI Forget What You Said Earlier?</a></em></p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
