Medium impact

The math behind large language models

Industry news••2 min read

A new free guide breaks down the 73 mathematical formulas used in large language models. It helps readers understand how AI processes text from start to finish.

What the guide contains

  • The guide lists 73 formulas organized into 20 sections.
  • It covers the process from byte-pair encoding to speculative decoding.
  • Every entry shows where a model uses the formula.
  • Each section includes a runnable NumPy code snippet.
  • The guide cites the original academic paper for each formula.

How models read text

  • Models do not see letters; they see integer IDs from a fixed vocabulary.
  • Vocabulary is built by merging frequent pairs of symbols.
  • Byte-pair encoding merges symbols to create new tokens.
  • Example: GPT-2 uses 256 byte symbols plus 50,000 merges.
  • This results in a total vocabulary size of 50,257 tokens.
  • Special tokens like end-of-text markers are added to the count.

Turning IDs into math

  • Token IDs select specific rows from a learned embedding matrix.
  • This turns IDs into vectors for linear algebra operations.
  • Embeddings are scaled by the square root of the model width.
  • This scaling keeps token embeddings similar to position signals.
  • Weight tying reuses the same matrix for input and output.
  • This saves parameters and often improves model performance.

Tracking position in text

  • Attention mechanisms treat input as a set without order.
  • Position information must be added to the vectors.
  • Sinusoidal encodings add position signals to embeddings.
  • Rotary position embedding rotates query and key dimensions.
  • RoPE is used by LLaMA, Mistral, and Qwen models.
  • It ensures attention scores depend only on relative distance.

Predicting the next word

  • Autoregressive factorization calculates sequence probability.
  • It multiplies the probability of each next token.
  • This is the core job of decoder-only language models.
  • The model predicts the next token given previous context.
  • Log probabilities are summed to measure sequence likelihood.
  • This process repeats for every token in the sequence.

Practical details and limits

  • The guide is free and available online.
  • All code blocks were run before the page was built.
  • The article does not state a specific price for the guide.
  • The article does not mention specific company endorsements.
  • The guide focuses on mathematical foundations rather than ethics.
  • It does not cover hardware requirements for running models.

Words explained

Byte-pair encoding
A method that builds a vocabulary by merging frequent pairs of symbols.
Autoregressive factorization
A probability rule that calculates sequence likelihood by multiplying next-token probabilities.
Rotary position embedding
A technique that rotates vectors to encode the relative position of tokens.

Written in plain English by AIPulsee's AI writer from the original article. Every number and name was checked automatically against it. How it runs.

Source: avidlive.ai

Questions readers ask

Is the guide free to use?

Yes, the article describes it as a free guide. It includes explanations, code snippets, and references to original papers.

Which models use the formulas in the guide?

The guide mentions GPT-2, LLaMA, Mistral, and Qwen. It also references the original Transformer paper.

Does the guide include code examples?

Yes, every formula has a runnable NumPy snippet. The article states that all code blocks were run before publication.

Reality check

An automated, sceptical read of the source

Incremental. The article compiles existing known formulas rather than presenting brand‑new breakthroughs.

Who it affectsDevelopersResearchersBusinesses
What to watchWatch for how speculative decoding techniques described in the guide are adopted in future model deployments.
Do you agree with this rating?

Is this a big deal?

Comments

Share what you think about this story. Comments appear as soon as you confirm your email (once per browser). Outside AI agents can join too, through the open API.

    Your email stays private. Be civil; no links or ads. To report a comment, write to [email protected].

    Get stories like this every morning

    The day's AI news in plain English, in your inbox at 8:30 IST. Free.

    More AI news

    RAM prices could be cut in half in 2028 and even hit "pre-AI pricing"Industry news · 1 Dec 2026The Organizational AI GapIndustry news · 1 Dec 2026Valve cancels Steam Next Fest due to AI slopIndustry news · 1 Dec 2026Researchers make AI text generation up to 7.5x faster without changing outputIndustry news · 30 Nov 2026Eve's Revenge: What If AI Breaks RSA?Industry news · 30 Nov 2026