Skip to main content
Back to Insights
DEEP DIVE15 min read

Inside AI: how models learn, generate, and act

Explore training, model architectures, retrieval, and tool use through three interactive demonstrations.

An AI application combines several mechanisms that are often described as if they were the same thing. Training changes a model’s parameters. Inference uses those parameters. Retrieval supplies outside information. Tool use can change something beyond the model. Understanding these boundaries makes it easier to diagnose failures and design meaningful tests.

We will follow a fictional business handling orders and customer requests. Basic algebra is helpful for the training example; the other demonstrations can be explored without it. For the broader vocabulary, start with AI, explained and its interactive concept map.

1. Learning changes parameters

Suppose we want to predict handling time from order size. A linear model predicts ŷ = wx + b. Training chooses the weight w and bias b to reduce a loss: here, mean squared error between predicted and observed values. Gradient descent calculates how the loss changes with each parameter and takes a step in the opposite direction. The learning rate controls the size of that step.

Try it: fit a line, one update at a time

Actual gradient descent in your browser, on invented data. This is a two-parameter linear model, not a neural network or a live AI service. Change a setting to restart.

Normalized input x: −1 to 1 · output y: −2.5 to 2.5

Updates: 0 · Mean squared error: 0.831 · w = 0.000, b = 0.000

The model starts at y = 0. Train it, then compare a small learning rate with the overshooting setting. Training error alone does not measure performance on unseen data.

Show the update rule

Prediction: ŷ = wx + b. Loss: mean((ŷ − y)²). Each update subtracts learning rate × gradient from w and b. All 24 points contribute to each update. The noise pattern is fixed so comparisons are reproducible.

A neural network adds layers and nonlinear transformations, often with many more parameters. Backpropagation applies the chain rule to calculate gradients through those layers; an optimizer uses the gradients to update parameters. The tiny linear experiment above illustrates optimization, not the representational capacity or training behavior of a large network.

Where do the training targets come from?

Supervised learning uses supplied targets, such as historical handling times. Self-supervised learning constructs targets from the data itself—for example, predicting a following token. Unsupervised methods seek structure without supplied answer labels, such as grouping similar orders. Reinforcement learning uses rewards associated with actions and outcomes.

These categories describe learning signals. They are not architectures, and a system can use multiple training stages. A Transformer is not synonymous with self-supervision; a generative model is not a separate learning-signal category.

2. Architecture shapes how information is processed

The arrangement of a model affects its assumptions about the input. Local patterns matter in images; order matters in event streams and language. Architecture is a design choice to evaluate against a task, not a ladder on which newer names automatically win.

Compare the path through a model

Select an architecture and step through its conceptual flow. These diagrams do not run trained models.

Example input: Structured features

ItemsDistanceUrgency
  1. 1Numerical features
  2. 2Weighted combinations + nonlinearities
  3. 3Predicted handling time

Stage 1: Numerical features

Values move through layers without recurrent state. A tabular prediction can use a feedforward network, but a linear model or tree may be a better baseline.

Feature preparation and evaluation matter more than adding layers.

In scaled dot-product attention, a model computes queries Q, keys K, and values V from representations. The expression softmax(QKᵀ / √dₖ)V forms weighted combinations of values. Masks control which positions may contribute. Multi-head attention performs several such operations; residual connections, normalization, and feedforward blocks also contribute to a Transformer’s behavior.

Other ways to represent or generate data

Autoencoders learn to reconstruct inputs through a representation. Variational autoencoders add a probabilistic latent-variable formulation. GANs train a generator alongside a discriminator. Diffusion models learn a process for reversing noise corruption. These are different modeling approaches, not interchangeable names for language models.

Choosing among them requires a task, suitable data, and evaluation. A list of architectures cannot tell you whether a particular business application is accurate, economical, or safe.

3. Inference uses the learned model

Training and fine-tuning update parameters. During ordinary inference, the parameters remain fixed while the model processes an input. A prompt can change the answer without changing the model’s weights. Applications may separately store conversations or run later training processes; that is different from learning weights during every request.

An autoregressive language model predicts a distribution over the next token given the preceding context, then repeats the process. Tokens may be words, word fragments, or other units. A decoding rule selects from those probabilities. Temperature changes the distribution used for sampling; it is not a truthfulness control. Fluent output needs task-specific evaluation.

4. Retrieval supplies context, not new weights

An embedding represents an input as a numerical vector. A retrieval system can compare query and document vectors to find candidate passages, often alongside keyword search and reranking. Similarity is a search signal, not proof that a passage is correct, current, or permitted for this user.

In retrieval-augmented generation, selected material is supplied to the generator. For an order-support assistant, that might be an approved returns policy. Changing the policy index can change available context without retraining the language model. Retrieval can still miss a passage or supply irrelevant information, and generation can misstate what was retrieved. Evaluate both stages.

5. Tool use crosses an application boundary

Drafting a reply and sending it are different operations. A model may propose a tool call, but application code should validate its arguments and enforce permissions before execution. An agent can repeat a cycle of choosing actions, receiving results, and deciding what to do next; the surrounding system needs limits, logging, and a way to stop or escalate.

Trace a request from question to action

A scripted simulation. No model, private data, retrieval service, or messaging tool is connected.

Request

A staff member asks: ‘What is the return window, and can you draft a reply?’

Try denying policy access, disabling retrieval, and proposing a send. The simulation makes the boundaries visible. It does not show that a real model would reliably abstain: the authorization and approval gates must be implemented outside the model. Retrieved documents and tool results are also untrusted inputs, not permission to take new actions.

6. Test the layer that can fail

  • Predictive model: compare with a simple baseline on held-out data. For forecasting, respect time order and avoid leaking future information into training.
  • Retriever: check whether relevant, authorized material appears in the retrieved results.
  • Generator: assess correctness, support from sources, and appropriate handling of missing information.
  • Tool workflow: test permission enforcement, invalid arguments, repeated actions, failures, and escalation.
  • Whole application: measure completion quality, latency, cost, human corrections, and recovery when dependencies fail.

A lower training loss is one signal. It does not establish useful generalization, factual answers, or correct authorization. Keep evidence for each layer and test the complete workflow before treating the combined system as dependable.

Sources and deeper reading

The examples and simulations are illustrative. These references explain the underlying methods.

Return to the practical questions in AI, explained

Read the cookie policy