Tokens và Context Windows

Điều gì tokens và context windows là, vì sao LLMs có them, và vì sao đó context-window limit là đó mechanical reason AI tìm kiếm chunks và retrieves nội dung của bạn thay vì reading toàn bộ các trang.

Xuất bản lần đầu: 3 thg 7, 2026 · Cập nhật lần cuối: 8 thg 8, 2026 · Advanced
Ngôn ngữ

MỘT token là đó smallest unit of text an LLM xử lý — khoảng 4 characters, hoặc về ¾ of an English word (100 tokens ≈ 60–80 words theo Google). Tokenization splits text (và images, audio, video) vào những units. MỘT context window là đó maximum number of tokens một model có thể hold tại khi — input plus output combined — như ngắn-term memory; Google Gemini có thể accept lên để 1 million tokens. Nội dung bên ngoài đó window là invisible, không dần forgotten. Này matters cho AI tìm kiếm vì không đầy đủ trang hoặc site fits trong một window, so retrieval các hệ thống select và chunk nội dung của bạn trước an LLM bao giờ sees điều này — mà là đó mechanical reason chunking, passage-cấp độ retrieval, và 'giữ điều này clear và self-contained' advice exist. MỘT bigger context window không có nghĩa là an AI đọc của bạn toàn bộ site, và Google says có không ideal trang length và không requirement để fragment nội dung cho AI.

TL;DR — MỘT token là đó unit an LLM xử lý — một sub-word fragment, ~4 characters, với 100 tokens ≈ 60–80 English words (Google). Tokenization splits all input và output — text, images, audio, video — vào tokens; đó model known set là của nó vocabulary. MỘT context window là đó total token budget shared by input (hệ thống prompt + history + retrieved tài liệu + của bạn query) và output (đó phản hồi) — Google analogy là ngắn-term memory. Nội dung bên ngoài đó window là invisible, không dần forgotten. Windows scaled từ ~2K tokens để 1M+ (Gemini), với một hardware ceiling (“thermal limit” (bản dịch) «thermal limit» of TPUs). Đó reason này matters cho tìm kiếm: các hệ thống manage cost và relevance by selecting và chunking trước an LLM sees của bạn nội dung — và “Lost in the Middle” (bản dịch) «Lost trong đó Middle» có nghĩa là ngay cả điều gì trong đó window không dùng evenly. MỘT bigger window không có nghĩa là AI đọc của bạn toàn bộ site.

Điều gì một token thực ra là

Tokenization maps text vào integer token IDs dùng một model-compatible encoding; token boundaries không phải đó giống nhau as word boundaries. Evidence for this claim OpenAI models process text as tokens, and token boundaries may be whole words or parts of words. Scope: OpenAI tokenization; token counts depend on the model-compatible encoding. Confidence: high · Verified: OpenAI: What are tokens? Context-window sizes là sản phẩm và model metadata, không một vĩnh viễn thuộc tính of all language models. Evidence for this claim Context-window limits are documented per model and can differ across model versions. Scope: OpenAI model metadata; published limits are product-specific and can change. Confidence: high · Verified: OpenAI: Models

Google là blunt về đó granularity: “Gemini and other generative AI models process input and output at a granularity called a token.” (bản dịch) «Gemini và other generative AI models xử lý input và output tại một granularity called một token.» MỘT token không phải một word và không một character — đây là một fragment. As Google tài liệu put điều này, “Long words are broken up into several tokens. The set of all tokens used by the model is called the vocabulary, and the process of splitting text into tokens is called tokenization.” (bản dịch) «Dài words là hỏng lên vào several tokens. Đó set of all tokens dùng by đó model là called đó vocabulary, và đó xử lý of splitting text vào tokens là called tokenization.»

Đó citable rule of thumb, straight từ Google: “For Gemini models, a token is equivalent to about 4 characters. 100 tokens is equal to about 60-80 English words.” (bản dịch) «Cho Gemini models, một token là tương đương để về 4 characters. 100 tokens là equal để về 60-80 English words.» So khoảng ¾ of một word theo token, on average — nhưng average là đang làm hoạt động ở đó. Punctuation, non-English text, code, và unusual hoặc dài words tokenize ít hơn efficiently (hơn tokens theo word), mà là chính xác vì sao counting words là một poor way để estimate token usage.

Tokens cũng không chỉ text. Google: “All input to and output from the Gemini API is tokenized, including text, image files, and other non-text modalities.” (bản dịch) «All input để và output từ đó Gemini API là tokenized, including text, image files, và other non-text modalities.» Images, audio, và video frames all become tokens cũng. Google DeepMind engineers mô tả đó context-window đo lường as “how many tokens — the smallest building blocks, like part of a word, image or video — that the model can process at once.” (bản dịch) «cách nhiều tokens — đó smallest building chặn, như part of một word, image hoặc video — đó model có thể xử lý tại khi.»

Điều gì một context window là

MỘT context window là đó maximum number of tokens một model có thể hold và reason over trong một single interaction. Google cách diễn đạt là có chủ ý đơn giản: “An analogy for the context window is short term memory.” (bản dịch) «An analogy cho đó context window là ngắn term memory.»

Đó key mechanical point là đó đây là một shared budget. Mọi thứ competes cho đó giống nhau space:

  • đó hệ thống prompt (đó instructions đó application cho đó model),
  • đó conversation history so far,
  • bất kỳ retrieved hoặc injected documents (đó passages một tìm kiếm/RAG hệ thống pulled trong),
  • của bạn input (đó hiện tại query), và
  • đó model own output (đó câu trả lời điều này generates).

Google Gemini tài liệu mô tả input và output drawing từ một shared pool. Đó chính xác accounting không universal, though: other providers publish một tách biệt maximum- output hình alongside đó context window thay vì treating điều này as một undivided budget — Anthropic model tài liệu, chẳng hạn, list một “context window” (bản dịch) «context window» size và một distinct “max output” cap side by side cho mỗi Claude model. Evidence for this claim Context-window limits are documented per model and can differ across model versions. Scope: OpenAI model metadata; published limits are product-specific and can change. Confidence: high · Verified: OpenAI: Models Kiểm tra đó tài liệu cho đó cụ thể model và sản phẩm bạn là thực ra dùng rather hơn assuming một formula áp dụng mọi nơi.

Whatever đó chính xác accounting, khi nội dung falls bên ngoài đó usable window, điều này không dần forgotten — đây là đơn giản invisible, as nếu điều này không bao giờ existed, trừ khi một hệ thống explicitly summarizes điều này và re-injects một ngắn hơn version, hoặc đó sản phẩm thay vì rejects, truncates, hoặc compacts đó yêu cầu trước đó model bao giờ sees điều này. Đó “it’s gone, not fading” (bản dịch) «đây là đã biến mất, không fading» behavior là đó part đó trips mọi người lên khi they assume an AI “remembers” một dài conversation đó way một person sẽ.

The context window is a shared request budget. Retrieval decides which source passages are worth spending part of it on. Nguồn: Google AI for Developers

A page or corpus contains many possible passages. Retrieval selects the passages most relevant to the current question. Those passages then share a model-specific context budget with system instructions, conversation history, the current query, and an output allowance. A larger window increases capacity, but it does not mean a search system routinely sends a whole page or site to the model.

© Patrick Stox LLC · CC BY 4.0 ·

Cách big context windows là — và cách fast đó changed

Đó quy mô-lên ở đây đã được dramatic. Sớm generative models handled chỉ một couple thousand tokens; đó progression ran qua khoảng 8K, thì 32K, thì 128K, trước đó jump Google flags trong của nó tài liệu: “Gemini is the first model capable of accepting 1 million tokens.” (bản dịch) «Gemini là đó đầu tiên model capable of accepting 1 million tokens.»

có một physical ceiling, though. Google DeepMind pushed để experimental 10-million- token windows, và research scientist Nikolay Savinov — một of đó research leads on đó dài-context project, ai originally targeted 128 000 tokens trước landing on 1 million — put đó limit plainly: “10 million tokens at once is already close to the thermal limit of our Tensor Processing Units.” (bản dịch) «10 million tokens tại khi là đã close để đó thermal limit of của chúng ta Tensor Processing Units.» Bigger context không free — điều này costs memory, compute, và theo nghĩa đen heat. (Google DeepMind Denis Teplyashin có described đó giống nhau cascade từ 128K để 512K để 1M để 10M, mỗi step opening new possibilities nhưng đang chạy vào harder engineering limits; research scientist Machel Reid có described điều gì nhóm thực ra làm với đó space, như feeding an entire codebase hoặc một 45-minute film vào một single prompt.)

Hai consequences worth internalizing:

  1. Đó numbers bạn see là moving targets. “The largest context window” (bản dịch) «Đó largest context window» là một hình đó giữ thay đổi; không hard-code strategy để một cụ thể token count.
  2. Bigger ≠ tự động tốt hơn. Hơn capacity không phải hơn comprehension — see “Lost in the Middle” (bản dịch) «Lost trong đó Middle» dưới.

Điều gì một million tokens thực ra looks như

Abstract token được tính là hard để feel, so Google offers concrete sizing cho điều gì 1M tokens có thể hold:

  • “50,000 lines of code (with the standard 80 characters per line),” (bản dịch) «50 000 lines of code (với đó tiêu chuẩn 80 characters theo line),»
  • “All the text messages you have sent in the last 5 years,” (bản dịch) «All đó text messages bạn có đã gửi trong đó cuối cùng 5 năm,»
  • “8 average length English novels,” (bản dịch) «8 average length English novels,»
  • “Transcripts of over 200 average length podcast episodes.” (bản dịch) «Transcripts of over 200 average length podcast episodes.»

đó là genuinely enormous — và đây là chính xác vì sao đó “so the AI just reads my whole site” (bản dịch) «so đó AI chỉ đọc my toàn bộ site» assumption feels reasonable và là vẫn sai. Mà brings us để đó tìm kiếm angle.

Vì sao tokens và context windows quan trọng cho AI tìm kiếm

Này là đó cốt lõi of điều này cho anyone đang làm SEO hoặc nội dung. Không đầy đủ trang — và certainly không đầy đủ site — là reliably handed để một model toàn bộ trong một tìm kiếm scenario. Ngay cả khi một trang fits technically, feeding all of điều này có thể là uneconomical hoặc irrelevant để đó query. Đó là vì sao retrieval các hệ thống — AI Overviews, Copilot, RAG pipelines, chatbots với browsing — select, chunk, và truyền chỉ some of một trang nội dung để đó model. (Không tìm kiếm vendor publishes chính xác điều gì điều này retrieves theo query, so này là inference từ cách retrieval architectures hoạt động generally và từ công khai statements như đó ones dưới — không một claim đó mỗi AI tìm kiếm sản phẩm behaves identically.)

Đó token/context-window limit là đó mechanical reason behind một toàn bộ stack of AI- tìm kiếm behavior bạn đã know về on này site:

  • đây là vì sao chunking tồn tại — nội dung nhận split vào retrievable passages vì đó toàn bộ điều sẽ không fit, và Microsoft own Azure hướng dẫn says partitioning lớn documents vào nhỏ hơn chunks “can help you stay under the maximum token input limits of chat completion and embedding models.” (bản dịch) «có thể help bạn stay dưới đó maximum token input limits of chat completion và embedding models.»
  • đây là vì sao retrieval (đó “R” trong RAG) có để pick một handful of passages trước generation — đó model có thể chỉ là handed điều gì fits trong của nó budget.
  • đây là vì sao embedding models có của họ own token caps (nhiều top out khoảng vài thousand tokens theo input), so dài passages có để là split trước họ là ngay cả turned vào vectors.

Đó ngành own cách diễn đạt of đó vấn đề là rõ ràng. Đó llms.txt spec opens với: “Large language models increasingly rely on website information, but face a critical limitation: context windows are too small to handle most websites in their entirety.” (bản dịch) «Lớn language models increasingly rely on website information, nhưng face một cốt yếu limitation: context windows là cũng nhỏ để xử lý hầu hết websites trong của họ entirety.» đó là đó toàn bộ motivation cho đó format — ngay cả khi, as I’ll cover trong đó myths section, Google John Mueller có called llms.txt tại best một token-saving “crutch” cho coding tools, không một tìm kiếm-visibility mechanism.

”Lost in the Middle” (bản dịch) «Lost trong đó Middle» — ngay cả điều gì là trong đó window không dùng evenly

Ở đây đó subtler point. Getting nội dung của bạn vào đó window không đó finish line. Đó Stanford “Lost in the Middle” (bản dịch) «Lost trong đó Middle» nghiên cứu (Liu et al., 2023) được tìm thấy đó on đó language models và tasks they tested, models dùng information tại đó bắt đầu và end of của họ context far tốt hơn information buried trong đó middle. đó là một position effect measured on 2023-era models — không proof mỗi hiện tại model luôn bỏ qua đó middle — nhưng đây là held lên as một chung caution: stuffing hơn tokens trong không bảo đảm tốt hơn các câu trả lời, và nội dung đó leads với của nó point survives cả hai retrieval trong-context attention tốt hơn nội dung đó buries điều này.

Đó economics: vì sao AI các hệ thống là selective on purpose

có một business-model reason retrieval các hệ thống chunk aggressively thay vì feed toàn bộ các trang. Google notes đó “when billing is enabled, the cost of a call to the Gemini API is determined in part by the number of input and output tokens” (bản dịch) «khi billing là enabled, đó cost of một call để đó Gemini API là determined trong part by đó number of input và output tokens» — và output tokens typically cost several times hơn input tokens. Tokens là theo nghĩa đen metered. Đó cho AI các hệ thống một mạnh economic incentive để retrieve và truyền chỉ điều gì là necessary, mà reinforces đó giống nhau conclusion từ một khác nhau direction: selective, passage-cấp độ retrieval không một tạm thời limitation để chờ out — đây là cách những các hệ thống là designed để hoạt động.

Phổ biến myths, debunked

  • “A 1-million-token context window means the AI reads my whole website at once.” (bản dịch) «MỘT 1-million-token context window có nghĩa là đó AI đọc my toàn bộ website tại khi.» Không. Trong một tìm kiếm hoặc RAG scenario, retrieval vẫn selects và chunks nội dung trước điều này bao giờ reaches đó model window. MỘT huge window thay đổi điều gì là có thể trong principle, không điều gì một công cụ tìm kiếm hoặc AI Overview thực ra feeds itself theo query. Google line là trực tiếp on point: “There’s no ideal page length, and in the end, make pages for your audience, not just for generative AI search.” (bản dịch) «có không ideal trang length, và trong đó end, làm các trang cho của bạn audience, không chỉ cho generative AI tìm kiếm.»

  • “I need to write in exactly 200-word, token-sized chunks.” (bản dịch) «I cần để ghi trong chính xác 200-word, token-sized chunks.» Không. Google: “There’s no requirement to break your content into tiny pieces for AI to better understand it.” (bản dịch) «có không requirement để break nội dung của bạn vào tiny pieces cho AI để tốt hơn understand điều này.» Chunking happens on đó hệ thống side; của bạn job là clear, well- structured nội dung, không manual token accounting.

  • “More tokens = a smarter model / better answers.” (bản dịch) «Hơn tokens = một smarter model / tốt hơn các câu trả lời.» Không. MỘT lớn hơn window increases capacity, không comprehension — và “Lost in the Middle” (bản dịch) «Lost trong đó Middle» cho thấy models dùng đó bắt đầu và end of của họ context tốt hơn đó middle. Bigger không tự động tốt hơn.

  • “Tokens = words, so I can just count words to estimate usage.” (bản dịch) «Tokens = words, so I có thể chỉ count words để estimate usage.» Khoảng, nhưng không reliably. 100 tokens ≈ 60–80 English words là Google average, nhưng punctuation, code, non-English text, và unusual words tokenize ít hơn efficiently — mà matters khi bạn là estimating cost hoặc budget.

  • “llms.txt solves the context-window problem for my site.” (bản dịch) «llms.txt solves đó context-window vấn đề cho my site.» Đó vấn đề là real — đây là đó spec own stated motivation — nhưng Google không dùng llms.txt cho tìm kiếm, và Mueller có được diễn đạt điều này as một token-saving crutch cho AI coding tools, không an SEO cách sửa. Đó mitigations đó thực ra quan trọng là đó giống nhau fundamentals: là crawlable và được lập chỉ mục, và ghi clear, retrieval-friendly nội dung.

Điều gì này có nghĩa là cho nội dung và SEO

Strip đó jargon và đó takeaways là concrete — và họ là đó giống nhau discipline đó cho thấy lên trên này cluster:

  • Front-load đó câu trả lời. Cả hai retrieval trong-context attention favor đó bắt đầu (và end) of điều gì một model sees. Lead với của bạn point.
  • Giữ sections self-contained. Vì một passage có thể là pulled out of trang của bạn và handed để một model on của nó own, điều này nên stand on của nó own. Này là đó giống nhau logic behind good H2/H3 structure và clear topic sentences.
  • không obsess over manual chunking. Không ideal trang length, không requirement để fragment. Ghi cho humans; đó hệ thống chunks.
  • “Bigger context window” (bản dịch) «Bigger context window» ≠ “AI reads my whole site.” (bản dịch) «AI đọc my toàn bộ site.» Optimize cho đang được tìm thấy và được chọn, không cho đang ingested toàn bộ.

Tokens và context windows là đó thấp-cấp độ plumbing dưới hầu hết of này cluster: họ là đó reason grounding và retrieval có để select passages, đó reason chunking prepares text đó way điều này làm, đó constraint embeddings và semantic và vector tìm kiếm hoạt động trong, và đó limit passage xếp hạng tồn tại để hoạt động khoảng. Và they sit right tiếp theo để đó model other hard boundary — của nó knowledge cutoff — as một of đó cốt lõi limitations of bất kỳ LLM.

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.