16 of 174 subtitles documented + 1 independent supplementary unit(s) · Writing progress, not your learning progress · Videos not visually reviewed

Supplement: what does a language model actually receive and produce?

This independent prerequisite fills a gap in the course introduction. It describes the common autoregressive generative language models used in our examples, not every AI architecture, multimodal model, or generation method.

Objective and entry check

Explain the path from text to response and locate information in model weights, current input, or application storage.

Does reading a PDF update model weights? Is every word exactly one token? If the next request omits a previously stated name, must the model know it?

Entry answer

Reading is not automatically training; words and tokens differ; access to the earlier name depends on application/service state management supplying it again. Merely using the same model does not create personal conversation memory.

Why model language?

Language contains dependencies: the continuation of “Today I went to…” depends on preceding text. Modeling sequence probabilities supports tasks such as speech recognition and text generation. This problem predates modern chatbots; LLMs did not begin the history of language modeling.

The 2017 Transformer paper introduced an attention-based sequence-transduction architecture with translation experiments. It was not originally a chat product or agent; the architecture later became widely used in language models. Original paper

You do not need every attention equation to begin application development. You do need to know that the model computes with numerical input and learned parameters; local files and the internet do not automatically enter that computation.

Attention combines information from relevant parts of the available sequence with different weights; the model need not rely only on the last word. Model weights are adjustable numbers in its computations. Training changes those parameters to learn patterns. Ordinary response generation, or inference, uses the existing parameters rather than retraining them for every new message. Files and internet data still need an application path into the input.

First: text becomes token IDs

A tokenizer converts text into pieces and numerical IDs using a model-specific vocabulary and rules. Pieces may be words, word fragments, punctuation, or other patterns. Word count in Persian or English is not exact token count. The tokenizer must match the model. Tokenizer tutorial

For illustration only, we might draw Mina | teaches | Python | . on paper. This is not measured output from a real tokenizer or a claim that the sentence always contains four tokens. Exact counts require the actual model's tokenizer.

Token IDs identify vocabulary entries: a larger ID does not indicate a more important token. The model maps IDs to numerical representations it can process. The immediate distinction is that a tokenizer prepares input; it does not answer the question.

Next: the model generates incrementally

Autoregressive generation scores possible next tokens based on the available sequence. A decoding strategy selects from those scores; the chosen token joins the sequence, and generation continues until a stopping condition or limit. Text-generation guide

For an illustrative continuation of “The capital of France is…”, generation might first produce part of “Paris” and then continue using that new part. This is not a measured token trace from a particular model. Output token IDs are eventually decoded into text for the application to display.

This does not mean a model simply pastes the globally most frequent word or cannot perform complex transformations. Output is incremental, while learned computations and patterns can be complex. Conversely, a fluent continuation is not a factual guarantee.

Temperature changes how strongly output probabilities favor some token choices over others, without adding an external truth source. Even a more probable choice can be wrong. Low temperature does not turn an answer into evidence. Supported settings depend on the model and service. Generation strategies

How does chat fit this process?

Applications construct messages with roles: system for general instructions supported by the model, user for user messages, and assistant for assistant replies. A model-appropriate chat template represents this structure in the format it expects; a textual causal model ultimately processes tokens. Writing “system” inside ordinary text is not necessarily the same as supplying a structured role. Chat templates

Roles help structure instructions and conversation. They are not operating-system permissions or tool access controls. “Do not reveal a private file” in a prompt does not revoke the executing program's filesystem access.

Conceptual path from messages to tokens and response

Three different meanings of memory

Information location What it contains What changes it
Model weights Learned parameters Training or adaptation
Current-call context Accessible instructions, messages, and data Request construction/context management
Application state/storage Files, database records, history, checkpoints Application code and infrastructure

Fine-tuning continues training on selected data to adapt the model toward a goal. It updates trainable parameters; supplying a few examples in a request does not necessarily do so. Saving a name in a database does not update model weights either. The application must retrieve and expose it when needed. These boundaries tell us where to investigate failures.

Context is finite. History, instructions, and tool data consume space, and generation has limits too. Capacity and accounting depend on the model/API. More supplied text does not guarantee better answers. Claude's context explanation

Worked example: an apparently forgotten name

In turn one, a user says “My name is Mina.” In turn two, they ask “What is my name?” If the application sends only the new question, the introduction is absent from that request. Including history makes the name visible. A service may preserve history through a conversation identifier; that still involves state management rather than personal memory arising merely from using the same model.

context_lab.py constructs both cases using ChatPromptTemplate and inspects the resulting messages. It verifies information presence/absence in the request. It does not run a real model or measure its recall ability.

python context_lab.py

Another example: the document arrived, but the answer is wrong

Suppose a document states that full-time annual leave is 20 days. The question concerns part-time employees. Even if loading and context assembly succeed, this evidence is insufficient. Check three different things: did the right data arrive, is it sufficient for the question, and does the answer remain faithful to it?

RAG ordinarily brings relevant evidence into generation input rather than permanently training the model. Search results are data too; an instruction embedded in a page should not become execution authority merely because it appeared in a tool result.

Independent practice

  1. A name exists in a database but not in the request. Which boundary needs inspection?
  2. Why is len(text.split()) not an exact token count?
  3. An exception-free, fluent response derives part-time entitlement from the full-time rule. What failed?
  4. Does our context example establish that a real model answers the name correctly?
Answer 1

The boundary between application storage and context assembly. Check retrieval and request inclusion, or whether service-managed state supplied the information according to its contract.

Answer 2

Whitespace splitting is a word-separation rule; a tokenizer uses its own vocabulary and rules and may split a word into several pieces.

Answer 3

Evidence sufficiency and answer fidelity. Technical completion does not validate that semantic generalization.

Answer 4

No. It checks message construction and inspection. Actual model performance requires a separate evaluation with appropriate criteria.

Continuation and scope

Explain “text, tokens, model, generation, message” without the lesson and distinguish the three information locations. Then continue to why LangChain exists. If the distinction remains unclear, reconstruct the name example across those locations on paper.

This supplementary lesson does not count as a reviewed course video. Examples and the diagram are original teaching material; primary references appear beside claims and were checked on 2026-10-16. Transformer training details and attention mathematics are not fully covered by this introductory prerequisite; its current purpose is understanding the model/application boundary.