liveBook · Manning

Gradient descent

As explained in Building Specialized AI Systems

Gradient descent is an optimization algorithm that iteratively adjusts model parameters in the direction that decreases a loss function.

Gradient descent is the iterative optimization algorithm that adjusts model parameters to reduce a loss function. Fine-tuning starts with pretrained weights and adapts them to a specific task rather than learning from random parameters. section 3.0 section 3.1.2

A model’s parameters determine how inputs become outputs. The loss function converts the model’s current error into one number: lower loss is better. Gradient descent uses the slope of that loss to choose parameter changes that should make the next prediction less wrong. section 3.1.2

A basic training loop follows these steps:

  • Read input and target batches from a data loader. section 3.1.2
  • Run the model to produce outputs. section 3.1.2
  • Calculate loss by comparing outputs with targets. section 3.1.2
  • Clear previous gradients, backpropagate the loss, and let the optimizer update parameters. section 3.1.2
  • Monitor loss periodically to track training progress. section 3.1.2

Sentiment fine-tuning

Suppose a model predicts “positive” with 30% probability when the correct label is “positive.” Cross-entropy loss penalizes this uncertainty, and gradient descent adjusts parameters so future predictions can become more confident and accurate. section 3.1.2

Figure 3.5 Gradient descent principle illustrated with a single weight variable. For LLMs, the same principle applies to billions of parameters.

Shows gradient descent as movement toward a lower-loss valley using a single weight, while the same principle applies across billions of language-model parameters. section 3.1.2

How Building Specialized AI Systems covers it

How deep it goes
Explains parameters, loss, directional updates, backpropagation, and optimizers through a conceptual loop and code listing.
Examples
Uses sentiment classification, a hiking-in-fog analogy, a single-weight figure, and a basic training-loop listing.
What you can do after
Operate/configure a training loop that computes loss, backpropagates gradients, updates parameters, and monitors progress.
How it connects
Connects loss functions, backpropagation, optimizers, supervised fine-tuning, and parameter-efficient fine-tuning.

Also explained in

Compare how 24 books explain gradient descent →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Specialized AI Systems. The section links point to the parts of the book it draws on.