Chapter 6. Machine Learning Foundation
Before an LLM can generate a single word, it must learn from data. That learning process is called machine learning. Every component of a modern language model, from the neurons that detect patterns to the optimizer that adjusts billions of weights, rests on machine learning foundations that have been refined over decades.
This chapter covers the building blocks that power LLMs: how neural networks are structured, how different learning paradigms produce different kinds of models, how loss functions guide training, and how optimization algorithms help models converge. For readers who want a deeper review of the mathematical foundations (such as derivatives, probability distributions, and linear algebra) we provide supplementary material in our GitHub repository: https://aiengineeringinterviews.github.io/. That material explains the underlying “why,” while this chapter focuses on the “how” through architectures, algorithms, and practical techniques.
From Neurons to Deep Networks
The simplest neural network component is a single neuron (also called a unit or perceptron). A neuron takes an input vector , computes a weighted sum, adds a bias, applies an activation function, and generates an output vector :
Here is a vector of learnable weights, is a learnable bias, and is an activation function (such as ReLU, GELU, sigmoid, etc.). The weights determine which inputs the neuron pays attention to, and the activation function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access