Vol. 07 · LLM Foundations

From a Neuron to an LLM

The route from linear regression to transformer: classical ML models and their limit, biological neuron and perceptron, deep networks and representations, recurrence and its problems, attention as a breakthrough, transformer as architecture and LLM as a result of scale.

Retrieval answer

The route from linear regression to transformer: classical ML models and their limit, biological neuron and perceptron, deep networks and representations, recurrence and its problems, attention as a breakthrough, transformer as architecture and LLM as a result of scale. ML is not a “smart program”. This New Runtime record is an evidence-linked retrieval unit.

01

Classic ML: models before neural networks

3 cards
01Classical MLThe essence of machine learning2 source notes

ML is not a “smart program”. This is the selection of parameters of a mathematical function so that it correctly maps the input to the output. Difference with conventional programming: rules are not written manually, they are calculated from data.

Source-complete notesthree ways to write a program · key insight
three ways to write a programsql
Normal programming:
  rules = person writes by hand
  output = rules(input)
  → works as long as there are few rules and they are clear

Machine learning:
  model = fit(inputs, outputs) ← from data!
  output = model(new_input)
  → rules are found by the algorithm itself

Deep learning (ML subtype):
  model = very flexible function (neural network)
  → finds rules even where
     a person cannot formulate them

key insight

  • data + algorithm = model
  • model = function with trained parameters
02Classical MLLinear models and their ceiling1 visual1 source note

Linear regression, logistic regression, SVM all construct a straight line (or hyperplane) separating classes. They work great on simple tasks, but the real world is nonlinear. How to distinguish a cat from a dog with a straight line by pixels?

Source-complete noteswhat did you do before

what did you do before

  • feature engineering: manually created x² and x₁ x₂
  • requires expert knowledge of the task
  • does not scale to images/text
03Classical MLThe Problem of Manual Features1 source note

Classic models - SVM, Random Forest, Gradient Boosting - are excellent when the characteristics are well defined: price, area, age. But using raw data (pixels, symbols, sound), you first need to come up with signs. This is called feature engineering - and this is where they hit the ceiling.

Source-complete notesclassic NLP pipeline to neural networks
classic NLP pipeline to neural networkssql
# Task: determine the sentiment of the review

Hand signs (2000s):
  "good"+1, "bad"-1
  number of exclamation marks → feature
  TF-IDF by dictionary → sparse vector 50k
  sentence length, capital letters...

Problem 1: "not bad" = "good"?
Problem 2: "Test!" — positive or sarcasm?
Problem 3: new words, slang → not in the dictionary

→ a person cannot come up with ALL the necessary signs
→ the neural network finds them itself from the data
02

Neuron and Network: where do the names come from?

4 cards
04NeuronBiological neuron → model1 visual1 source note

Neural networks are so named because they are mathematically inspired by the neurons of the brain. A biological neuron collects signals from dendrites, sums them up, and if the sum exceeds a threshold, it “shoots” through the axon. It is this logic that is reproduced by an artificial neuron.

Visual model · Concept treeTrace the hierarchy and branches that make up Biological neuron → model.
Source-complete notesanalogy

analogy

  • dendrite = input feature x
  • synapse strength = weight w
  • response threshold = activation function
  • the analogy is simplified - the brain is more complex
05NeuronNeuron mathematics1 source note

One neuron is a linear function plus nonlinearity. The linear part weighs the inputs; the activation function decides "how active" the neuron is. Without activation, a neuron is simply a linear regression.

Source-complete notesactivation formula and functions
activation formula and functionstypescript
z = w₁ x₁ + w₂ x₂ ++ wₙ xₙ + b
output = f(z) ← activation function

Activation functions:

Sigmoid: f(z) = 1 / (1 + e^-z) → [0,1]
          historically the first, now rare

ReLU: f(z) = max(0, z) → [0,∞)
          standard for hidden layers

SiLU/Swish: f(z) = z sigmoid(z) → smooth ReLU
          used in modern LLM (SwiGLU)

# Why nonlinearity is critical:
without f(z): 100 layer network = one linear function
with f(z): the network can approximate ANY function
06NeuronWhy "network": layers of neurons1 visual1 source note

One neuron is weak. When neurons are connected in layers, and layers are connected in series, a network emerges. Each layer transforms the input's representation: the first layer sees raw pixels, the last layer sees abstract concepts. This is called a feature hierarchy.

Visual model · Concept treeTrace the hierarchy and branches that make up Why "network": layers of neurons.
Source-complete noteswhy "neural NETWORK"

why "neural NETWORK"

  • neuro - from neuron biology
  • network - neurons connected to each other
  • output of one neuron = input of the next
07NeuronUniversal approximation theorem1 source note

It has been mathematically proven (Cybenko, 1989): a neural network with one hidden layer and a sufficient number of neurons can approximate any continuous function with any accuracy. This explains why neural networks are so versatile - they are not limited to a specific form of function.

Source-complete noteswhat does this mean in practice
what does this mean in practicetext
Theorem: ∃ network W such that
  |W(x) − f(x)| < ε for any x

In other words, a neural network can learn:
  ✓ grammar rules (no one wrote explicitly)
  ✓ what does “cat” mean based on thousands of photos
  ✓ connection between words in the text
  ✓ style of a specific author

But: the theorem says “exists”, not “how to find”
  → you need enough data
  → training needed (backprop + optimizer)
  → the right architecture is needed
03

Deep Learning: Why Depth

3 cards
08Deep LearningShallow vs Deep Network: Hierarchy of Features1 visual1 source note

A “deep” neural network is simply a network with many layers. But depth is not just quantity: each layer builds more abstract representations on top of the previous one. This is what allows deep networks to understand images, sound and text without manual cues.

Visual model · Process flowFollow the sequence behind Shallow vs Deep Network: Hierarchy of Features and locate where work or state changes.
Complete view · 4 layers
Source-complete notesdeep learning = automatic feature engineering

deep learning = automatic feature engineering

  • signs are learned, not invented
  • works on raw data: pixels, tokens, PCM
  • requires a lot of data and calculations
  • interpretability is worse than linear ones
09Deep LearningHow a neural network learns1 source note

Learning is an iterative process of minimizing error. The model makes a prediction, compares it with the correct answer, calculates “how much it was wrong” (loss), and slightly adjusts all the weights in the right direction.

Source-complete notesgradient descent loop
gradient descent looppython
① Forward pass:
  prediction = model(x) ← through all layers

② Loss (error function):
  L = loss_fn(prediction, y_true)
  for example cross-entropy: how wrong is the probability?

③ Backward pass (backpropagation):
  gradients = ∂L/∂W ← chain rule across all layers
  "how to change each weight to reduce L?"

④ Update (optimizer):
  W ← W - lr gradients ← small step

⑤ Repeat a million times
  → the weights gradually “correctly” describe the data
10Deep LearningWhy neural networks replaced the classics1 source note

Until 2012, SVM and Random Forest won most benchmarks. In 2012, AlexNet (CNN) reduced the error on ImageNet from 26% to 16%—by half. Since then, neural networks have dominated wherever there is a lot of data and complex features.

Source-complete notestable
Classic MLNeural network
SignsHand EngineeringAutomatically
Raw dataBadOkay
Data scalePlateau at 10k–100kGrows with data
InterpretabilityHigh"Black box"
ComputationsCPU, fastGPU, expensive
Best problemstabular datatext, photo, audio
04

The text problem: sequences and RNNs

3 cards
11SequencesWhy is text more complex than a picture?1 source note

A picture is a fixed grid of pixels. The text is a sequence of variable length, where the order is critical: “the dog bit the man” ≠ “the man bit the dog.” A regular MLP does not know the concept of “before” and “after” - a special architecture is needed.

Source-complete notesspecificity of the text
specificity of the texttext
Problem 1 - variable length:
  "Yes." → 2 tokens
  "War and Peace" → ~580,000 tokens
  → MLP requires a fixed input

Problem 2 - long-distance dependencies:
  "The neighbor's cat around the corner meowed."
  → “meowed” depends on “cat” after 9 words

Problem 3 - order is important:
  "not good" ≠ "good"
  "I just left" ≠ "I just left"

Problem 4 - context changes meaning:
  "key" → door?  spring?  way to solve?
12SequencesRNN: Recurrent Network1 visual1 source note

RNN (Recurrent Neural Network) solves the problem of sequences through “memory”: it processes tokens one by one, passing the hidden state h forward. h is a “compressed memory” of everything that has been read up to this point.

Visual model · Formula mapConnect the quantities and operations that determine RNN: Recurrent Network.
Source-complete notessolutions on top of RNN

solutions on top of RNN

  • LSTM - gated memory cell (1997)
  • GRU - simplified LSTM (2014)
  • still bad at >500 tokens
  • sequential processing = cannot be parallelized
13SequencesBottleneck: vector bottleneck1 visual

In the translation task (seq2seq), the encoder compressed an entire sentence into a single fixed-size vector. Then the decoder turned it into translation. With long sentences, the vector could not retain all the information - the quality dropped.

Visual model · ComparisonContrast the alternatives in Bottleneck: vector bottleneck under the same frame.
Complete view · 4 layers
05

Attention: the heart of modern NLP

3 cards
14AttentionIntuition Attention: “what to look for”1 visual1 source note

Attention is a soft search mechanism: instead of reading all the information at once, the model learns to assign importance weights. For each position, it calculates how “relevant” each other position is right now.

Visual model · Formula mapConnect the quantities and operations that determine Intuition Attention: “what to look for”.
Source-complete notesrevolutionism

revolutionism

  • direct access to any token - no attenuation
  • weights are calculated dynamically depending on the context
  • parallel to all positions
  • Bahdanau 2015 - first attention for NLP
15AttentionSelf-Attention: “attention to yourself”2 source notes

In the original attention decoder looked at the encoder. Self-attention is when a sequence looks at itself. Each token is simultaneously a query, a key, and a value. This allows you to build contextual representations without recurrence.

Source-complete notesmechanics Q, K, V · vs recurrence
mechanics Q, K, Vtex
For each token x_i:
Q_i = x_i · W_Q ← “what am I looking for?”
K_j = x_j · W_K ← “what am I offering?”
V_j = x_j · W_V ← “what am I returning?”

score(i,j) = Q_i·K_jᵀ / √d_k
α_ij = softmax(score)
out_i = Σⱼ α_ij · V_j

Result: "key" in the context of "door"
has a different vector than the “key” in the “spring”
→ contextual embeddings!

vs recurrence

  • O(1) steps between any tokens (RNN: O(n))
  • parallel processing of the entire sequence
  • O(n²) memory - expensive on long contexts
16AttentionMulti-Head: several types of attention1 source note

One attention mechanism answers one “question”. Multi-head attention launches several parallel attentions with different weights - each head specializes in its own type of connections: syntax, coreference, semantics, position.

Source-complete noteswhat different heads teach
what different heads teachtext
Head 1: syntactic connections
  “the cat meowed” - the head sees the subject↔predicate

Head 2: coreference
  "Masha went home. She was tired."
  — the head notices “she” = “Masha”

Head 3: Positional Patterns
  — monitors neighboring tokens

Head 4: semantic proximity
  - "king" ↔ "monarch" ↔ "ruler"

→ concatenation of all heads → W_O → final vector
→ each token gets a “comprehensive” understanding of the context
06

Transformer: «Attention Is All You Need»

3 cards
17Transformer2017: «Attention Is All You Need»1 source note

Vaswani et al. (Google, 2017) proposed to remove recurrence completely and build an architecture based only on attention and MLP. The result is better quality, 3x faster training. This became the foundation for all LLMs.

Source-complete noteswhat has changed
what has changedtext
Before (RNN/LSTM seq2seq):
  processing: sequential (token by token)
  long dependencies: lost
  training on 8 GPU: weeks
  context: ~200–500 tokens

After (Transformer):
  processing: parallel (all tokens at once)
  long dependencies: direct O(1) access
  training: days
  context: scalable (hundreds of thousands, 1M+, for some models up to ~2M)

The key idea is positional embeddings:
  “if there is no recurrence, how can we know the order?”
  → add position information to the token vector itself
18TransformerTransformer block: anatomy1 visual

One transformer block is two subblocks with residual connections. Self-attention “mixes” information between positions - it recognizes the context. The MLP “thinks” about each position independently—applies knowledge. LLM = stack of such blocks.

Visual model · Formula mapConnect the quantities and operations that determine Transformer block: anatomy.
19TransformerWhy block stack = Language Model2 source notes

The job of the language model is to predict the next token. A stack of transformer blocks builds an increasingly deeper representation of the context, and the final linear layer (LM Head) converts it into probabilities over a dictionary. Training in “guess the next word” gives language abilities.

Source-complete noteslanguage modeling · scale laws (Kaplan et al. 2020)
language modelingtext
Task: P(next token | all previous ones)

Entrance: "Moscow - the capital"
  ↓ × 32 transformer blocks
  ↓ LM Head (d_model → vocab_size)
  ↓ softmax
Probabilities:
  "Russia" → 0.71
  "Russia." → 0.12
  "Russia," → 0.08
  "world" → 0.02 …

Training: on trillions of text tokens
learning to guess the next word → side
effect: the model “understands” language, facts, logic

scale laws (Kaplan et al. 2020)

  • more parameters → better
  • more data → better
  • more compute → better
  • predictable - can be planned
07

From Transformer to LLM

3 cards
20LLMThree ingredients of LLM1 source note

LLM is not a new architecture. This is a decoder-only transformer trained in three stages on a fundamentally different scale of data and calculations. GPT-2 (2019) showed: just a large transformer can already do a lot without additional training.

Source-complete notesthree stages of creating an LLM
three stages of creating an LLMtext
① Pretraining (language modeling):
  data: the entire Internet, books, code (~10T tokens)
  task: predict next token
  result: the model “knows the language” and the facts of the world

② Supervised Fine-Tuning (SFT):
  data: pairs (question → good answer), ~100k
  task: learning to follow instructions
  result: model responds as assistant

③ RLHF/DPO (alignment):
  data: human ranks answers
  task: to maximize “human preference”
  result: safe, useful, honest answer

Pretraining: 99% calculations
SFT + RLHF: 1% computation but UX critical
21LLMEmergent Abilities: abilities from scale1 source note

At a certain scale, a model suddenly exhibits abilities that smaller models did not have—not gradually, but in leaps and bounds. No one specifically taught GPT-4 to solve chemistry problems—it taught itself.

Source-complete notesexamples of emergent abilities
examples of emergent abilitiessql
Appears at ~10B+ parameters:
✓ Multi-step reasoning (chain-of-thought)
✓ Arithmetic (3-5 characters)
✓ Translation into languages not from training
✓ Analogies and metaphors

Appears at ~100B+ parameters:
✓ Coding in new languages
✓ Explain your reasoning
✓ Solving problems using symbolic logic
✓ Understanding sarcasm and irony

Why: debatable. Possibly critical mass
compressed knowledge allows you to combine them
22LLMLLM is a neural network: the full argument1 source note

Now you can collect a complete answer to the question “why LLM is a neural network.” This is not a metaphor or marketing - this is a specific architectural chain from the perceptron to the modern model.

Source-complete notesfull argument
full argumentsql
LLM is a neural network because:

"Neuro":
  consists of artificial neurons
  (weighted sum + nonlinearity)
  inspired by biological brain neurons

"Network":
  neurons are connected in layers
  output of one → input of the next
  3280 layers of transformer blocks

"Transformer":
  a special neural network where the “connections” between
  neurons are not fixed, but are calculated
  dynamically through the attention mechanism

"Language":
  trained on the predict-next-token task
  → learned grammar, facts, logic, style

Parameters: 8B–1T+ weights wᵢ,
  selected by gradient descent
  on trillions of text tokens
08

The big picture: 70 years behind one scheme

1 cards
23TransformerDevelopment line: from perceptron to GPT1 visual1 source note

Each next step solved a specific problem of the previous one. This is not a random sequence of inventions - it is a deliberate movement towards a universal sequence processor.

Visual model · Process flowFollow the sequence behind Development line: from perceptron to GPT and locate where work or state changes.
Complete view · 3 layers
Source-complete notesTimeline

Timeline

  • 1958 Perceptron Rosenblatt. One neuron. Linear classifier.
  • 1986 Backprop Rumelhart. Deep networks can be trained.
  • 1997 LSTM Hochreiter. Memory in a recurrent network.
  • 2012 AlexNet CNN defeats ImageNet. Deep learning works.
  • 2015 Attention Bahdanau. Decoder looks at the required encoder tokens.
  • 2017 Transformer Vaswani. Only attention, no recurrence.
  • 2018 BERT/GPT Pretrain on a large body → finetune to the task.
  • 2022+ LLM Scale + RLHF → ChatGPT, Claude, Gemini.

No dead end

Keep moving through the map.

Continue in sequence, switch to a related guide, or return to the seven-track learning map.

Discovery graph / next reads

Continue through New Runtime

Open the graph
  1. 01learning trackLlm FoundationsOpen the complete learning track.
  2. 02related materialLLMs in Plain EnglishContinue with another guide in this learning track.
  3. 03related materialLLM Internals: From Token to Logit to AnswerContinue with another guide in this learning track.
  4. 04related materialLLM Internals: KV Cache & GenerationContinue with another guide in this learning track.
  5. 05related materialWhat a Prompt Is and Why a Question Becomes an AnswerContinue with another guide in this learning track.

These links are also published in this page’s JSON twin and as typed edges in DiscoveryGraph v1.

Who read this page?Machine requests, hidden until opened

Loading the privacy-safe route aggregate…

Open the JSON contract