Skip to content
← Free FDE training guides

Free learning / 45-minute Model 101 lab

Model 101: from learned patterns to generated text

Understand parameters, context and inference before building an agent. Train a tiny inspectable model, follow token selection and change one cause at a time.

No account needed. Use your own copy for writing and keep the original as a reference.

Engineering lab library / Run locally

See what the model actually learned

Inspect the learned table and each token decision. Change sampling and training separately, then explain why a fluent result still needs evidence.

Real training and generation in a tiny word-bigram model. It is not an LLM: no neural network, attention, provider call or GPU. All phrases are fictional.

  1. Start here / Python 3.11+ · Standard library

    Train and inspect a tiny language model

    Compare learned counts, token probabilities, generated text and parameter fingerprints.

    Python 3.11+ standard library · No GPU, network or account

An original 45-minute lesson for an engineer meeting language models for the first time. Start with the explanation, follow the visual, predict a result, then inspect a small program. The maintenance phrases below are fictional text, not advice about equipment.

1. Understand the model before building the agent

A large language model (LLM) is a trained neural network: software whose many numerical parameters were adjusted using data. A language-generating model uses those numbers and its current input to calculate scores for possible next tokens. A token is a unit of encoded content; it need not be a whole word. The surrounding program chooses a token, adds it to the working sequence and continues until a stopping condition. A model is neither a programming language nor an agent framework.

That surrounding program includes a provider's serving runtime: when you call an API, your application may set supported generation options while the service performs token selection. You do not need to implement the decoding loop yourself to use a hosted model.

Think of a function with two inputs: a saved parameter set and this request's working context. Training changes the parameter set. Ordinary inference uses it to calculate an output. Giving the function a different request can change the output without rewriting the saved parameters. This analogy does not mean the model is a database lookup or that its output has been verified.

NameWhat it doesWhat it does not establish
Parameters / weightsLearned numbers used by the network's calculationsAn approved, current company procedure
ContextInstructions, messages and evidence supplied for this requestA permanent update to the model's weights
InferenceCalculates outputs using a trained modelTruth, permission or completed business work
DecodingSelects output tokens from the model's scoresWhether the generated statement is supported
Training / fine-tuningUpdates learned parameters from examples and an objectiveThat every future response will be correct
Agent applicationGives the model tools and enforces the working loopUnlimited permission to act

An FDE needs these distinctions to diagnose the right part of a system. A stale procedure may require better retrieval and source checks. An output limit may need a smaller task. Neither observation alone demonstrates a need to retrain a model. Provider logging, retention and any later training use are separate service policies; “inference does not update these weights” is not a privacy promise.

UNDERSTAND THE SYSTEM

What changes when a model writes the next word?

Follow an inspectable word-bigram model. Training counts adjacent words; inference uses the learned table. This original teaching model is not an LLM: it sees only one prior word and has no neural network or attention. The downloadable program performs these calculations locally.

FOLLOW THE WORK

Watch one example, step by step.

9 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Training examples

The five fictional phrases contain three inspection examples and two repair examples. These are training inputs, not this request's prompt.

CONNECTED TO
  • Train: Learned table
Read the full worked example
  1. 01
    Learn from examples

    Training counts adjacent words. After needs, inspection occurred three times and repair twice. These learned counts stay fixed during the following inference calls.

    TRAINING: 3 inspection + 2 repair → a learned table

  2. 02
    Supply this request

    The prompt is the pump needs. At temperature 1, the learned needs row gives inspection 3/5 and repair 2/5. A new prompt is an input, not an update to the model's parameters.

    INFERENCE: Input changes · learned table stays fixed

  3. 03
    Choose the largest

    Greedy decoding selects inspection. The next step selects the end marker. The completed continuation does not establish what a real machine needs.

    GREEDY: inspection · end-token · parameters unchanged

  4. 04
    Sample another continuation

    With the same learned table and input, seed 0 draws about 0.844. Inspection occupies the first 0.6 of the interval; the draw lands on repair. One model can produce different outputs.

    SAMPLED: repair · end-token · parameters unchanged

  5. 05
    Lower the temperature

    Temperature 0.5 makes the normalized masses 9/13 and 4/13. Repair becomes less likely, but the same draw still selects it. Lower temperature does not verify a claim or erase every alternative.

    COOLER: repair probability: 0.4 → about 0.308

  6. 06
    Change an earlier word

    The prompt now says the valve needs. This toy uses only the last word needs, so its trace matches the pump prompt. That is a limitation of this one-word conditional model, not evidence that a Transformer ignores earlier context.

    EARLIER CONTEXT: Different prompt · same last word · same trace

  7. 07
    Stop at the output limit

    With one step allowed, the model selects inspection and reaches its limit before selecting the end marker. The visible word matches greedy, but the completion evidence differs. Do not invent the missing end-token observation or assume a larger limit will fix an unrelated failure.

    OUTPUT LIMIT: inspection · token-limit · no end token selected

  8. 08
    Find no learned transition

    The prompt ends with compressor, which has no learned row. The program produces an empty trace and stops before token selection. A modern LLM can instead generate fluent unsupported content on unfamiliar input; this toy's explicit unseen-context stop is not a general safety property of language models.

    UNSEEN CONTEXT: Empty trace · unseen-context · no token selected

  9. 09
    Train a different model

    Four additional repair examples create a separate learned table with counts 3 and 6. Greedy now chooses repair from the same prompt. The model differs from the base; this inference call still leaves its own parameters unchanged.

    RETRAINED: New training data → new table → changed prediction

Read the connections in plain English
  1. 01
    Training examples → Learned table

    The learning procedure creates the model's parameters from examples.

  2. 02
    Learned table → Next-token probabilities

    Inference reads the saved values without updating them in this exercise.

  3. 03
    Request context → Next-token probabilities

    The toy selects the row for the last word; a Transformer computes representations from its permitted context.

  4. 04
    Next-token probabilities → Token selection

    The decoding strategy operates on the computed distribution.

  5. 05
    Token selection → Generated text

    A selected word joins the working context for the next step; the end token or limit stops generation.

Check your understanding: If the output changes, must the model have been retrained?

No. Context, decoding settings and sampled choices can change an output while parameters remain fixed. Inspect the actual model/version, request, settings and result. A low temperature is not a correctness check.

2. Meet a model small enough to inspect

The lab trains a word-bigram model. “Bigram” means a pair of successive tokens. It counts which word follows another in five fictional phrases, then turns those counts into a probability distribution. It splits on spaces and uses a special <end> marker. Real LLM tokenizers use richer vocabularies.

Its entire training collection is:

Text example
the pump needs inspection
the pump needs inspection
the pump needs inspection
the pump needs repair
the valve needs repair

After needs, the learned table has three inspection occurrences and two repair occurrences. At temperature 1, these become 3/5 and 2/5. A probability distribution allocates a total of 1 across possible next tokens. It describes this model's next-token calculation, not confidence that a real pump needs work.

This is an actual small statistical model, not an LLM or a miniature Transformer. It remembers only the immediately previous word; it has no neural layers, attention, embeddings, instruction following or factual reasoning. A generative Transformer computes with learned neural weights and representations of a much larger permitted context. Causal attention lets positions use earlier context positions; it does not grant access to an external database. The toy isolates training, prediction and selection so you can explain those jobs before studying the larger architecture.

In an autoregressive Transformer, token IDs first map to learned vector representations. Neural layers combine information from allowed positions and transform the representations into next-token scores, often called logits. Decoding turns those scores into a choice under the serving policy. The representations and attention calculations depend on this request; they can change while the learned weights stay fixed. An inference key-value cache also holds computed working state, not a new training update. None of these computations automatically reads the current company procedure from an external system.

3. Predict and run seven cases

Download fde-model-first-inference.py into your practice folder. Use Python 3.11 or later; no packages, model download, GPU, key or account are required. The program runs in memory, writes no files and makes no network calls.

Code example
python3 --version
python3 fde-model-first-inference.py compare
python3 fde-model-first-inference.py sampled

Before running, predict the continuation, stop reason and whether the model's parameters changed. Then compare your prediction with trace, parameters_before, parameters_after and model_changed_from_base.

CaseWhat changesExpected observation
greedyPick the largest next-token probabilityinspection, then <end>
sampledDraw from the same distribution, seed 0repair, then <end>; weights unchanged
coolerSampling temperature becomes 0.5, same seedrepair still appears; its first-step probability drops from 0.4 to about 0.308
earlier-contextReplace pump with valve in the promptStill inspection: this toy sees only the last word needs
output-limitAllow just one generation stepinspection with token-limit, without observing <end>
unseenEnd the prompt with compressorEmpty continuation and unseen-context
retrainedTrain a separate model with four extra repair phrasesCounts become 3:6; greedy chooses repair; the model fingerprint differs from the base

The fingerprint summarizes the learned count table to make equality visible. It is not a credential or security attestation. Each inference result should show identical before/after fingerprints, including inference on the separately retrained model. Training changes a model; generation does not mutate it here.

4. Follow one prediction through the program

Read the train, distribution and generate functions in that order.

  1. train counts adjacent word pairs. Repeated examples affect the table.
  2. distribution turns the relevant row into probabilities. At temperature 1, these are the relative counts. The code uses logarithms and softmax, which converts scores into nonnegative values that sum to 1.
  3. generate either selects the largest probability (greedy decoding) or takes a pseudo-random draw from the distribution (sampling).
  4. The chosen word becomes the next context word. The loop stops on <end>, an absent transition or the explicit step limit.

For sampling, temperature rescales scores before normalization. A smaller positive temperature concentrates mass on stronger candidates; it does not verify a claim or make all other tokens impossible. The lab's temperature 0.5 turns the 3:2 counts into normalized 9:4 masses. With seed 0 the first draw is about 0.844, so it still lands on repair. Greedy is a separate mode; do not divide by zero. Production parameter names, supported settings and repeatability depend on the selected model and serving system.

The earlier-context and unseen cases reveal limitations of this specific toy. Do not conclude that a modern LLM ignores all but one word or always refuses unfamiliar input. It may instead generate a fluent but unsupported answer.

5. Change one cause at a time

Make a copy of the file before editing. Keep predictions and actual results.

Change A — selection without training. Change SAMPLE_SEED = 0 to SAMPLE_SEED = 1 and run sampled. The continuation becomes inspection. The counts, probabilities and parameter fingerprint stay the same. Explain why two outputs do not require two models. Restore the seed before the next edit.

Change B — training without changing the prompt. Change EXTRA_REPAIR_EXAMPLES = 4 to EXTRA_REPAIR_EXAMPLES = 0 and run retrained. The learned table now equals the base model; model_changed_from_base is false and the greedy continuation returns to inspection. Explain which data changed the earlier prediction. Repetition here is a transparent teaching input, not a recommended production fine-tuning strategy.

Do not judge a model from these seven examples. This experiment verifies the specified mechanics, not language quality, reliability or workplace performance.

6. Carry the distinction into an FDE design

Your fictional assistant receives a new approved procedure: P-17 revision 3 requires a human review before a draft is sent. A generated draft omits that review. First draw where P-17 enters context, which model/version is called, where the output is checked and which application code controls sending.

Choose an observation before proposing a change:

  • If P-17 never entered the request, inspect retrieval and context construction.
  • If P-17 was present but the draft contradicts it, retain the case and evaluate the prompt/model combination. A low temperature is not a factuality control.
  • If the draft ends early, inspect the recorded completion reason and allowance.
  • If text proposes sending, the application still has to enforce permission and review. A model's words do not execute that action.

Compare repairs without teaching to the test

Use the failing case to find a hypothesis, then choose an experiment that could disprove it. This is an authored design exercise, not a result of the toy program.

ObservationFirst comparison to justify
P-17 is absent or stale in the actual requestRepair the selected context while holding the model and settings fixed
Current P-17 is present but contradictedCompare one prompt or model change against the original on relevant cases
The result stops at its output limitInspect the allowance and task size; compare supported completion, not just a longer answer
The draft proposes bypassing reviewTest the application's review and sending controls independently of the model

For a training experiment, keep fitting examples separate from development examples used to choose a candidate, and reserve a final held-out evaluation. Held out means those cases were not used to fit or select the candidate. Repeatedly tuning against a final test set makes it part of development, even if its filename still says “test.” Avoid duplicated or near-identical cases across the comparison, and include tasks that reflect the actual intended use.

Keep the original request, source revision, model/version, supported settings, output and stop reason for each case, under the appropriate data-handling policy. Count missed review requirements and unsupported instructions alongside successful drafts; include the work a person needs to check and correct them. Define what would reject the candidate before inspecting its results. A seven-case mechanic exercise cannot establish generalization or a suitable evaluation sample size.

Fine-tuning may help a persistent behavioral gap with suitable authorized examples. It is not a replacement for fresh source access, and it cannot grant permission to send. Keep the approved review requirement in trusted application code regardless of how convincing a model's output looks.

Produce a one-page explanation with the parameter set, context, decoding choice, observed result and application boundary. State what evidence would justify a training experiment and how you would compare it on held-out tasks. “We trained it” is not a substitute for evaluation.

7. Keep the work and go deeper

Keep your seven predictions, actual traces, both changed-copy outputs and the one-page design. Explain the same mechanism to a colleague without running the program. They should be able to point to what changed and what stayed fixed.

Continue with real tokenization and request budgeting, then context construction and agent engineering. The protected Model 101 lesson adds Explain/Debug/Design rehearsals, knowledge checks and a transfer discussion under existing Academy access.

Primary references, checked 25 October 2026:

The lesson and lab are original LockedIn Labs instruction. These references provide deeper study; they do not imply a vendor partnership or certification.

Before you move on

Keep the evidence of your work.

  • Seven predictions compared with actual generated continuations.
  • Two controlled edits separating sampling from changed training data.
  • A model/application diagram with current evidence and action boundaries.

Keep these in your own working copy. Reading this page does not save work or record completion.

Suggested next free session

See tokens before planning a model request

Inspect a real tokenizer and budget the request after understanding what generation does. This is a suggested sequence; choose the practice that addresses your current gap.

Open the next free guide

Free account

Give your practice a home.

Try a role exercise with account drafts and a downloadable worksheet. Keep the files you made in this guide in your own working copy.

Create a free learning account

Guided training · by application

Build toward a program.

Request structured lessons and a training seat. Scope, schedule, feedback arrangements and tuition are confirmed in writing before you commit.

Explore a training application
Have Academy access?

Use your existing training seat to open worked explanations and practice in the related lesson. Creating a free account does not grant a seat.

Open the related Academy lesson →
Back to top ↑