LLM vs Generative AI: How Language Models Work and Where They Fit

LLM vs generative AI: an LLM is one family of generative AI and a type of machine learning model. Here is how it turns tokens into text.

LLM vs Generative AI: How Language Models Work and Where They Fit
Written by TechnoLynx Published on 28 Aug 2024

An LLM is part of generative AI, but the two terms are not the same thing. A large language model is a machine learning model, typically a neural network, trained on a large amount of text for natural language processing tasks. LLMs count as generative models because there is a practical way to sample new text from the probability distribution they learn. Generative AI is the wider category. It also covers GANs, diffusion models, variational autoencoders (VAEs) and normalising flows. So the honest answer to “LLM vs generative AI” is a nesting: an LLM sits inside generative AI, and LLMs are machine learning models.

If a team treats “generative AI” and “LLM” as synonyms, it can overlook architectures better suited to its problem, such as GANs, diffusion models and VAEs. The rest of this article explains where LLMs fit, how one turns a prompt into text, which generative models are not language models, and where small language models come in.

LLM vs generative AI: a subset, not a synonym

Generative models produce new content that approximates the statistical distribution of their training data. NIST’s Generative AI Profile (AI 600-1, July 2024) explains confabulation in those terms: generative models produce outputs that approximate the distribution of their training data, and LLMs do this by predicting the next token or word. An LLM applies that idea to text, typically with a transformer trained at large scale.

The table below sets the terms side by side, since scoping conversations often stall when these words are used as if they meant the same thing.

Term What it covers Typical outputs Example families
Machine learning Models whose behaviour is learned from data rather than hand-coded Predictions, classifications, generated data Linear models, decision trees, neural networks
Deep learning Machine learning with neural networks that have very large numbers of parameters As above, at higher capacity CNNs, RNNs, transformers
Generative AI Models whose outputs approximate the distribution of their training data Text, images and other data GANs, diffusion models, VAEs, normalising flows, autoregressive models
Large language model Typically transformer-based models trained on text to predict the next token Text and code GPT-style decoder-only models such as LLaMA

A model can therefore be generative AI without being an LLM. An image diffusion model is the obvious case. Not every transformer language model is built to generate, though. BERT was trained by masking words anywhere in a sentence, which made it hard to sample from, and the simpler next-word approach used by GPT won out for generation.

How an LLM differs from machine learning in general

An LLM is a specific kind of machine learning model, so asking for “LLM vs machine learning” compares a member with its class. Machine learning is the part of AI behind LLMs. Within machine learning, deep learning refers to neural networks with very large numbers of parameters, and LLMs are deep learning models built on the transformer architecture.

Three features set an LLM apart: its training signal, architecture and scale.

First, the training signal. An LLM’s first training stage is self-supervised: it learns to predict the next tokens of a large text corpus, so the text supplies its own labels.

Second, the architecture. LLMs are generally based on the transformer, whose attention mechanism lets the model relate every element of a sequence to every other element at once, however far apart they are. Vaswani et al. (2017) proposed the transformer as an architecture based only on attention, with no recurrence or convolutions.

Third, scale. The step from earlier pre-trained language models to LLMs came from increasing parameters into the tens or hundreds of billions and training data into the gigabytes and terabytes. Performance after pretraining depends largely on compute, parameter count and dataset size, and scaling laws describe that relationship empirically.

LLMs can take on new tasks from examples placed in the prompt without changing their parameters, which is known as in-context learning. An LLM’s task is set partly by its input at inference time, without fine-tuning.

How does a large language model generate text, from tokens to output?

A large language model generates text one token at a time. At each step it predicts the next token, selects it, appends it to the sequence and repeats. A language model is, at its core, an estimate of the probability of a token or sequence of tokens appearing within a longer sequence. LLMs encode a probability distribution over strings of words that approximates the distribution of their training text.

The generation loop, step by step

  1. Tokenise the input. A tokenizer breaks the text into tokens, which may be words, parts of words or single characters. Most modern models use subword tokenisation, and OpenAI’s GPT models use a subword method called Byte-Pair Encoding. Google’s Machine Learning Crash Course gives a rule of thumb for English: one token is about four characters, or roughly three quarters of a word.
  2. Map tokens to vectors. Each token becomes an embedding vector, the numerical form the network operates on.
  3. Run the transformer. The transformer alternates attention layers, which mix information between positions, with feed-forward layers applied to each position separately. Because attention runs in parallel, processing time does not grow with window length given enough processors, but total computation grows with the square of that length.
  4. Produce a probability distribution. The output becomes a probability distribution over the vocabulary for the next token.
  5. Select a token. The decoding strategy picks the next token from that distribution. Microsoft’s .NET documentation describes the model selecting the most probable token to continue the sequence, and greedy selection of that kind is one strategy among several.
  6. Append and repeat. The chosen token is added to the sequence, which becomes the input for the next step, so the output is built one token at a time. Generation stops at a predefined length or when the model emits an end-of-sequence token.

Repeating the loop gives an arbitrarily long string that is, by the laws of probability, a sample from the learned distribution. This factorisation into successive conditional probabilities is what defines autoregressive models.

Training objective and decoding strategy are separate choices

Training teaches the model to predict the next token. Decoding decides how to use those predictions. Holtzman et al. found that likelihood works well as a training objective, yet using likelihood as the decoding objective produces text that is bland and strangely repetitive.

For engineers, the takeaway is that the decoding objective, not only the trained weights, shapes output quality. Before judging a model weak, we would check its decoding configuration (greedy versus sampling, temperature, length limits). In the Hugging Face Transformers library, the generate() API handles text generation for every model with generative capabilities.

Generating text this way also explains why LLMs confabulate. NIST’s profile describes confabulation as a natural result of how generative models are designed: they produce outputs that approximate their training distribution. Confabulated content is presented confidently even when it is false.

The author of one set of lecture notes on LLMs points out that a model trained only to predict each next word can solve word problems that seem to require intelligence, and says that at present nobody really understands how this works.

Generative models that are not language models

Beyond language models, generative AI also includes GANs, diffusion models, VAEs and normalising flows. Each one models data in a different way.

  • Generative adversarial networks (GANs). Goodfellow et al. (2014) train two models together: a generator that captures the data distribution and a discriminator that estimates whether a sample came from real data. The generator is trained to make the discriminator wrong, which amounts to a two-player minimax game.
  • Variational autoencoders (VAEs). Kingma and Welling introduced a stochastic variational inference and learning algorithm for models with continuous latent variables. It uses a reparameterised lower bound that standard stochastic gradient methods can optimise. In practice VAEs are valued for structured latent representations.
  • Diffusion models. Rombach et al. describe diffusion models as a sequence of denoising autoencoders that build up an image, and they state that diffusion models achieve state-of-the-art synthesis results on image data.
  • Normalising flows. Flows are used for tractable density estimation.
  • Other autoregressive models. Autoregressive models also serve sequential generation.

Each architecture differs in the training data it needs, how controllable its output is and its latency. We would choose a family by output modality and those constraints first, and only then by which models are popular. For how these generative AI models are built and trained, see the wider explainer, and for the network basics they share, see the neural networks behind generative AI.

What is a small language model, and when does it beat an LLM?

A small language model (SLM) is a language model with far fewer parameters than an LLM. One 2024 survey, Small Language Models: Survey, Measurements, and Insights, defines its scope as transformer-based, decoder-only models with 100 million to 5 billion parameters and covers 70 open-source SLMs. Compare that with LLaMA models from 7 to 70 billion parameters, or PaLM at 540 billion.

Small does not have to mean weak. The Phi-3 technical report describes phi-3-mini as a 3.8 billion parameter model trained on 3.3 trillion tokens. It scored 69% on MMLU, which the authors say rivals Mixtral 8x7B and GPT-3.5, while being small enough to run on a phone.

A second 2024 survey, by Wang et al., notes that LLMs often need cloud APIs, which raises privacy concerns, limits real-time use on edge devices and increases fine-tuning costs. The same survey says LLMs often underperform in specialised domains such as healthcare and law, and that SLMs suit work that needs local data handling, minimal inference latency and domain adaptation through lightweight fine-tuning.

Situation Leans towards Why
Data cannot leave the device or premises SLM Local inference avoids sending data to cloud APIs
Tight latency budget or edge hardware SLM Lower inference latency
Narrow domain with your own data to fine-tune on SLM Fine-tuning is cheaper and adaptation is easier
Broad, open-ended tasks driven by prompting LLM Strong in-context and few-shot performance without fine-tuning

We would settle the SLM-or-LLM choice by the deployment constraint (where the model must run, how fast and on whose data) before benchmark scores come into it. The comparison of small and large language models covers the trade-offs in more detail.

From definitions to an engineering decision

Getting the terms right is what lets you scope the work. If the output is text and the task changes with the prompt, we would start from an LLM or SLM, then settle model size, decoding and where inference runs. If the output is an image, a sound or a synthetic dataset, a diffusion model, GAN or VAE is probably the better starting point, and an LLM may only be the interface. Teams that skip this step miss architectures better suited to their problem.

TechnoLynx’s Generative & Agentic AI R&D works across this split, from transformers to diffusion, VAE and GAN models, and builds the chosen architecture into products. Before committing to a family, the question to answer is which constraint you cannot relax: output modality, latency, data locality or cost.

Back See Blogs
arrow icon