Lesson 16 — Beginner

The Context Window

Model ka poora kaam-kaj ek chhote se workspace mein chalta hai — context window. System prompt, history, documents, tool outputs aur khud generated text — sab isi mein fit hote hain. Is lesson mein hum dekhenge kya-kya jagah leta hai, context aur knowledge aur memory mein kya farq hai, aur lambi context mein kya-kya bigadta hai.

⏱ 10 min• Beginner• Reasoning Models & Test-Time Compute

Context window kya hai aur kya bharta hai

WHAT

Context window model ka working memory hai — ek fixed-size jagah (tokens mein naapi jaati hai) jahan har request ka saara text fit hota hai. Usse zyada aaya toh purana hissa kat jaata hai (truncation).

WHEN

Har request mein. Tum jab bhi prompt, history, document ya tool output bhejte ho, sab isi window mein fit ho raha hota hai — chaahe tumhe dikhe na.

WHERE

Provider ki docs mein likhi hoti hai (context-window spec) — par exact limit alag-alag models mein alag hoti hai. Hamesha current docs se check karo, purani sankhya ratte mat bithao.

Ek request ka composition aisa hota hai: system instructions + conversation history + user prompt + documents + few-shot examples + tool outputs + generated content. Sab mil kar window bharte hain. Isiliye ek chhota sa feature — jaise auto-summary — bhi prompt ko itna lamba kar sakta hai ki limit aa jaaye.

Pro Tip: Apne app mein har request ka token budget track karo — system prompt, history ke kitne message, aur document ka kitna hissa ja raha hai. Pehla cost-optimization aksar yahi hota hai: itna context daal rahe ho jitni zarurat nahi.

Context ≠ knowledge ≠ memory

Interview line: Context window chahe badi ho, model ka knowledge usi ke andar hai. Naya fact chahiye toh context mein daalo (retrieval/tools), warna model guess karega. Teenon alag cheezein hain — confusion yahin se shuru hoti hai.

Lambi context mein kya-bigadta hai

SYSTEM + HISTORY + DOCUMENT (50 pages) + EXAMPLES + TOOL OUTPUT
Sab mil kar context window bharte hain.

Problem A  TRUNCATION     — limit cross → purane ya middle hisse kat jaate hain
Problem B  LOST-IN-MIDDLE  — beech mein rakha fact model dhundh nahi paata
Problem C  DILUTION        — zaroori instruction 400 pages mein kho jaati hai

Bada window kyun kaafi nahi hota

Decision rule: Document lamba hai? Seedha window mein mat daalo — retrieval (RAG) lagao. Aur window spec hamesha current provider docs se verify karo — limits badalti rehti hain, purani sankhya yaad rakhna khatarnak hai.

Exercise

Question: Context window kya bharta hai — sirf user message ya poora request payload?

Question: Training se aaya permanent gyaan kisme hai — context window ya model knowledge?

Question: Bade document mein zaroori line shuru, beech ya end mein rakhna zyada reliable hai? (do shabd)

Question: Context window ki exact limit kahan se verify karni chahiye — purani notes ya current provider docs?

Common mistakes

Desi example: Jeb ka thaila — context window ka desi analogy

Thaila fixed size ka hai — sab kuch daal doge toh zaroori chabi dab jaayegi (dilution), aur thaila phat bhi sakta hai (truncation). Isliye sirf aaj ka zaroori rakho, baaki ghar mein hi rehne do:

text
Thaila (context window) = fixed size
Sab daalna   → chabi dab gayi (dilution)
Thaila bahar → kuch gir gaya (truncation)
Sahi tareeka → sirf aaj ke 3 zaroori cheezein rakho
RAG ka matlab → baaki cheezein alag godown, mangwao zaroorat par
Interview angle — yahan se sawaal aate hain
  • Q: Context window mein kya-kya aata hai? — System prompt, history, user message, documents, examples, tool outputs aur generated content — sab mil kar.
  • Q: Context, knowledge aur memory ka farq? — Context is request ka working space, knowledge training se aaya, memory app ki zimmedaari — teeno alag.
  • Q: Lost-in-the-middle kya hai? — Lambi context mein beech ka content model ke liye kho jaata hai — isliye zaroori cheez shuru ya end rakho.
  • Q: Kya bada context window RAG ko bekaar kar deta hai? — Nahi — window badi ho sakti hai par attention evenly badi nahi; retrieval targeted context deta hai, sasta aur saaf.
Lesson complete?

Context window clear. Agla lesson — LLM Capabilities & Failure Modes — mein dekhenge model kis kaam ke liye natural hai, kahan tootta hai aur hallucination hota kyun hai.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course