Skip to main content

What is a context window in AI?

The Tasadr team · ·4 min read

A context window is the amount of text an AI model can take in at once. Google compares it to short-term memory. Everything the model reads to answer you, your question and the pages it fetched, has to fit inside it, so write your page so its answer arrives clearly in a short passage.

Also known as context window · context length · context size · token limit · نافذة السياق

On this page (7)
  1. What is a context window?

    It is the amount of text a model is given in one go. It is counted in units called tokens, and Google's documentation likens it to short-term memory: what falls out of the window is not seen by the model when it writes its answer.

    It holds your question, the system's instructions and the text the engine fetched from pages. In some models the written answer shares the same window. So an engine may not read a long page whole, and may use only passages from it.

  2. Do big windows replace retrieval?

    Not entirely. Google's documentation says retrieval with vector databases was historically the answer when windows were small, and that a large window sometimes lets you provide all the information up front. It also says retrieval tools are still useful, and that context caching can lower the cost of repeated questions over the same data.

    For your site the result is that an engine fetching web pages for your customer's question needs to find a usable passage on your page. A page's length alone does not guarantee it is read whole.

    A small window and a large window
    AspectSmall windowLarge window
    What fitsA few selected passagesLong or many documents
    Role of retrievalEssential for picking passagesStill useful, and may be simpler
    What helps your pageA short passage that answers clearlyThe clear passage too, since length does not add understanding
  3. An Arab-market example: a freight company in Riyadh

    An illustrative example. A fictional freight company at riyadh-cargo.example published its price list in a 100-page file, and a customer asks ChatGPT "how much to ship 20 kilos to Jeddah?".

    If the page has a short table giving the price by weight and destination in a clear passage, the engine finds the answer quickly. If the answer is buried on page 60 of a huge file it may not reach it, because what enters the window is what the engine picked from the page, not the whole file.

  4. What should you do with your pages because the window is limited?

    Put what you most want cited in a short, self-contained passage near the top of the page or under a heading that asks its question.

    • Put the answer in the first sentence of the section, not at the end of the page.
    • Split a long page into sections with question headings.
    • Write figures and prices as text or a readable table, not an image.
    • Do not hide the key fact only inside a long file. Put it on a page.
    • Check whether the engine cites your pages in Answer Tracking.

Sources

  1. Long context · Google AI Studio ·

Frequently asked questions

What is a token?

A unit of text a model splits language into, which may be a word, part of a word or a mark. The window's size is counted in them. Google's documentation gives no formal definition.

Why does a chatbot forget what I said at the start of a conversation?

A long conversation can exceed the context window, so the oldest part falls out, and the model no longer sees it when it writes its reply.

Should I shorten my pages because of the context window?

No. A thorough page helps your reader. Make each section carry a clear, self-contained answer, since an engine does not necessarily read everything on a page.