Writing/AI Architecture

LLMs Demystified: Tokens, Context Windows & RAG.

By James Chia·14 Sep 2026·⏱️ 90s Read

If you strip away the marketing terms, Large Language Models are sophisticated mathematical engines that calculate which word fragment should come next. Understanding three core mechanics will make you a far better system builder.

1. Tokens: The Currency of AI

Models don't read words or characters; they process tokens (chunks of roughly 3 to 4 letters in English). When you send a prompt, every word is split into numeric token IDs. You pay for both the input tokens sent and the output tokens generated.

Pro-tip: Dense formatting, unnecessary whitespace, or dumping thousands of lines of irrelevant boilerplate directly inflates your latency and API bills.

2. The Context Window: Working RAM

The context window is the model’s active working memory. While modern models boast 128,000 to over 1,000,000 token capacities, more context is not always better.

Research consistently shows that attention degrades when critical details are buried in the middle of massive contexts. For predictable results, keep your prompts tight, relevant, and well-structured.

3. RAG vs. Fine-Tuning

When teams want an AI to understand company data, their first instinct is often: "Let's fine-tune a custom model." In 95% of real-world use cases, this is the wrong choice. Fine-tuning is slow, expensive to update, and does not reliably prevent hallucinations.

The industry standard is Retrieval-Augmented Generation (RAG): store your documents in a searchable database, fetch the 3 to 5 most relevant paragraphs when a query arrives, and feed them directly into the context window. It is cheaper, updates instantly, and can cite exact sources.

Bottom Line:Don't try to train an AI on your knowledge. Keep your knowledge in clean, searchable databases, and let the model do what it does best: read, synthesize, and format.