Subject 28

Large Language Models (LLMs)

Large language models are transformer-based systems trained on massive text corpora to predict tokens, follow instructions, and perform a wide variety of language tasks through prompting, fine-tuning, and tool use.

Beginner

An LLM is a very large neural network trained to predict the next token in text. Because it learns broad language patterns from enormous datasets, it can answer questions, summarize, write code, classify text, and more.

Data collection -> pretraining -> alignment / instruction tuning -> deployment -> prompting / tools / retrieval
llm_capabilities = ["summarization", "classification", "reasoning", "code generation", "tool use"]
print(llm_capabilities)

Real-world example: a company assistant can summarize meetings, search internal policy documents, draft emails, and help engineers inspect logs, all using variations of the same base model.

Batch Size in LLM Training and Inference

Batch size appears at two stages of the LLM lifecycle — pretraining and inference serving — with different trade-offs in each.

During pretraining

During inference (serving)

Key distinction: in training, batch size affects gradient quality and convergence. In inference, batch size affects throughput and latency. Both are constrained by GPU memory, but for different reasons (activations during training, KV cache during inference).

Advanced

At engineering level, an LLM is not just a model checkpoint. It is part of a full system involving tokenization, inference infrastructure, retrieval, prompt management, observability, evaluation, privacy controls, and product constraints. Capability emerges from the interaction between the model and these system components.

Key engineering realities

system_layers = {
    "model": "decoder-only transformer",
    "retrieval": "optional external knowledge",
    "validation": "schema and policy checks",
    "observability": "latency, cost, and quality traces"
}
print(system_layers)

The strongest practical mental model is that LLMs are probabilistic reasoning-and-generation engines that need surrounding structure to become reliable software components.

Do not judge an LLM by a single demo. Judge it by measured behavior across real tasks, failure cases, and operational constraints.

Practice

Build