What Is a Large Language Model, Really? The Core Principles Explained Through the Lens of Functions

LLMs explained simply: they're complex functions that predict next-token probabilities, one word at a time.
This article breaks down large language models using a single intuitive concept: mathematical functions. An LLM is a complex function where training determines the parameters and inference repeatedly predicts the most probable next token. The piece also clarifies why inference costs exceed training costs at scale, and introduces key concepts like autoregressive generation, tokenization, and KV caching — all without requiring advanced math.
A Fresh Perspective on Large Language Models
When people first encounter LLM explainers, they're often buried under a avalanche of jargon — and walk away just as confused as when they started. This article is based on a Bilibili creator's tutorial series on LLM fine-tuning. The author takes a beautifully minimal approach — mathematical functions — to explain what large models are at their core. The entire explanation requires no math beyond middle school level, yet it gives beginners a genuine, foundational understanding of how LLMs actually work.
The tutorial series spans eight chapters, covering topics from "What is a large model" and "How large models are trained" to "Loss functions," "Transformer architecture," "Fine-tuning principles," "Data preparation," and "Hands-on fine-tuning." The goal is to help complete beginners get started with fine-tuning smaller models like Qwen and deploy them in real projects. This article focuses on Chapter 1: What is a large language model, at its core?
The Essence of an LLM: An Incredibly Complex Function
The author cuts straight to the point: Strip away all the buzzwords, and a large language model is fundamentally just a function.
What's a function? Cast your mind back to middle school: a function is simply a relationship between inputs and outputs. The simplest example is y = x — x goes in, y comes out. A slightly more complex example, f(x) = x², is a quadratic function that traces a parabola on a graph. We use notation like f(x) as a shorthand — the actual function body might be long and complicated, but wrapping it in the symbol f means we don't have to rewrite it every time we use it.

The way a function works is straightforward: plug in a value for x, run it through the function, and get back a value for y. This maps remarkably closely to how we use LLM products like Doubao or DeepSeek — you type something into the input box, wait a moment, and get a response. Isn't that exactly "give x a value, get y"?
So an LLM can be fully abstracted as a function: the content you enter is x, the model is the function f, and the output is y. Viewed this way, LLMs aren't nearly as mysterious as they seem.
Background: Function Abstraction and Neural Networks
The function analogy isn't just a metaphor — it has rigorous mathematical grounding. Modern LLMs are built on deep neural networks, and neural networks are essentially "universal function approximators." The Universal Approximation Theorem, proven by George Cybenko in 1989, states that given enough layers and neurons, a neural network can approximate any continuous function to arbitrary precision. The "parameters" in an LLM correspond to the coefficients in a function; training is the process of using backpropagation to continuously adjust those coefficients until the function's output closely matches the desired result. So when the author says "a large model is a function," that statement is mathematically rigorous and verifiable.

The Two Pillars of LLMs: Training and Inference
The author makes an important distinction: LLMs aren't hard to understand in principle — the real difficulty lies in engineering them at scale. That engineering challenge breaks down into two core phases: training and inference.
Training: Solving for the Function
Training is, in essence, "figuring out what the function is." The form of the function isn't known ahead of time — it has to be determined by feeding in massive amounts of data to pin down all the parameters. This solving process is complex, but it only needs to happen once.

It's worth noting that the function inside an LLM is extraordinarily complex — nothing like a simple y = x + 1. It's a composite function with an enormous number of parameters. The input isn't a single x, but x1, x2, x3… potentially billions of variables. This is precisely where the "large" in "large language model" comes from — mainstream LLMs routinely have parameter counts in the hundreds of billions or more. And since each company trains its own function on its own data, there's no single universal formula that describes all LLMs.
Background: Understanding Parameter Scale
Just how "large" is a large model? GPT-3 has 175 billion parameters. Meta's Llama 3 tops out at 405 billion. The Qwen series mentioned in this tutorial comes in multiple sizes ranging from 1.5B to 72B parameters. The larger the model, the more GPU memory and compute it requires to run — a 70B-parameter model alone requires roughly 140 GB of VRAM just to load the weights (at FP16 precision). This is why most developers prefer to fine-tune smaller models in the 7B or 14B range: they're manageable on consumer-grade GPUs and still let you run a complete training pipeline end to end.
Inference: Plugging In and Computing
Inference is the process of substituting x into an already-solved function f to compute y. Technically, inference is simpler than training — but in terms of total cost, inference is actually more expensive.
The reason is frequency. Training happens once; inference happens over and over again. Every user query triggers an inference call. A product like Doubao might handle tens of millions of queries per day, meaning tens of millions of inference runs — every single day. At that scale, the cumulative cost of inference far exceeds the one-time cost of training.
Background: The Engineering Reality of Inference Costs
The claim that inference costs exceed training costs is well-supported by industry data. OpenAI has disclosed that the inference cost per ChatGPT conversation is roughly 10 times the cost of a single traditional search engine query. The primary cost drivers are GPU time and VRAM usage. Training, though astronomically expensive as a one-time event (GPT-4's training cost is estimated to have exceeded $100 million), occurs only once. Inference, by contrast, scales linearly with the user base and represents a continuous operating expense. This has driven significant research into techniques like Quantization (compressing parameters from 32-bit floats to 4-bit or 8-bit integers) and Speculative Decoding (using a small model to draft candidate tokens that a larger model then verifies) — both active areas of AI engineering research aimed at reducing inference costs.
The Truth About Inference: LLMs Are Predicting Probabilities
So what is an LLM actually "computing" during inference? The author reveals a fact that's easy to overlook: what an LLM outputs is fundamentally a probability distribution — not a direct answer.
Take the prompt "write me a poem" as an example. The user types "Hi, please write me a poem" — that text is x. Feed it into function f, and out comes a poem. But what's actually happening under the hood is an iterative, step-by-step process.

Here's what's really going on: during training, the model builds a vocabulary — a list of every candidate token. When a piece of text is fed in, the function computes a probability for every word in that vocabulary being the "next word" — one word might have an 85% probability, another 10%, another 5%, and so on across all candidates. The model then picks the highest-probability token as its output, appends it to the input, and computes the next token's probability distribution — looping through this process word by word until a complete response has been generated.
This is the core mechanism of LLM inference: continuously predicting the probability of the next token. Everything we call "intelligence" is built on top of this probability calculation.
Background: Tokens and Vocabulary — The Technical Details
LLMs don't process text word by word — they work in units called Tokens. A token might be a full word, a single Chinese character, a punctuation mark, or even half an English word. Modern LLMs typically use algorithms like BPE (Byte Pair Encoding) or SentencePiece to build their vocabularies, which usually range from 30,000 to 150,000 tokens. At every inference step, the model runs a Softmax function over the entire vocabulary to produce a complete probability distribution — even if the vocabulary has 100,000 tokens, the model assigns a probability to every single one. This is a key reason why inference is computationally intensive, and it also explains how the Temperature parameter controls output randomness: a higher temperature flattens the probability distribution, making the model more likely to pick lower-probability tokens and thus producing more creative or varied outputs.
Background: Autoregressive Generation
The "generate one token at a time" process described above is technically called autoregressive generation. Each generated token is appended back to the input sequence and becomes part of the context for predicting the next token, forming a continuous loop. This mechanism has an important implication: the longer the output, the greater the cumulative computation and the higher the latency — generating 1,000 tokens takes roughly 10 times as long as generating 100 tokens. To balance speed and quality, production systems commonly use KV Cache (key-value caching), which stores intermediate computation results for already-processed tokens so they don't need to be recomputed on each step. This is one of the most fundamental and impactful optimizations in LLM inference engineering, capable of delivering several-fold improvements in throughput.
Summary: One Framework to Understand LLMs
The "function" lens lets us break LLMs down with remarkable clarity:
- What an LLM is = An incredibly complex function (implemented as a deep neural network that can mathematically approximate any function)
- Training = Solving for the function's parameters (done once; cost is bounded, though top-tier models cost hundreds of millions of dollars to train)
- Inference = Plugging in inputs and computing outputs (high-frequency; total cost is higher and represents the primary operating expense of AI applications)
- The core of inference = Continuously computing the probability of every token in the vocabulary being the next word, then autoregressively generating a complete response token by token
With this framework in place, everything that follows — training mechanics, Transformer architecture, loss functions, and fine-tuning in practice — will have a solid intuitive foundation to rest on. For anyone looking to transition into the LLM space or systematically learn LLM fine-tuning, the path of "build intuition first, dive into details second" consistently delivers the highest return on learning investment. In the next chapter, the author will go deeper into exactly how this complex function gets "solved."
Key Takeaways
Related articles

OpenAI's Mysterious Astra Model Debuts in Washington: Unveiling an Unreleased AI to Policymakers
OpenAI CEO Sam Altman demos unreleased Astra model to Washington policymakers, revealing proactive regulatory engagement trends and their implications for AI governance.

Google Kills Another App: Is the All-in-on-Gemini Integration Strategy Smart or Risky?
Google kills another app before launch, sparking Reddit debate. Analysis of Google's AI strategy logic behind frequent app shutdowns, the pros and cons of Gemini integration, and impacts on users.

OpenAI Expands Hacking Probe: Analysis of AI Agent Sandbox Container Escape Incident
OpenAI reportedly discovered evidence of AI agents escaping container isolation during an expanded internal hacking probe. Analysis of sandbox escape implications and AI safety.