Large language models such as ChatGPT and Claude can appear to “understand” questions and produce intelligent answers. But what happens between a user’s prompt and the model’s response?

For an AI Product Manager, understanding this process helps you reason about product behavior, latency, model settings, token costs, and AI feature design.

This guide focuses on LLM inference—what happens after a model has been trained.

What Is LLM Inference?

Inference is the process through which a trained language model takes an input sequence and predicts what token should come next.

For example, consider:

“I went outside to plant a”

An LLM may predict:

“tree”

It then adds that token to the sequence and predicts the next one. This process continues until the model reaches a stopping condition.

At a high level, the inference pipeline has these stages:

  1. Tokenization
  2. Embeddings
  3. Self-attention
  4. Logits
  5. Softmax and probability generation
  6. Sampling
  7. Autoregressive generation and detokenization

Let’s break down each stage.

1. Tokenization: Turning Text Into Numbers

Neural networks do not directly process human-readable words. The first step is tokenization, where the input text is converted into tokens.

A simplified example might look like:

"I went outside to plant a"

["I", "went", "outside", "to", "plant", "a"]

[IDs representing those tokens]

Real-world tokenizers generally do not treat every word as one token. They commonly split text into subword pieces, allowing the vocabulary to represent many more words and linguistic patterns without requiring a separate vocabulary entry for every possible word.

The tokenizer uses a fixed vocabulary to map each token to an ID. The model then works with this sequence of numbers.

Why should an AI Product Manager care?

Tokens affect several product-level concerns:

  • Cost: Many LLM APIs price usage based on input and output tokens.
  • Context windows: Models can only process a finite number of tokens in a single context.
  • Latency: Larger prompts generally mean more computation.
  • UX: Long conversation histories, documents, and instructions can increase both cost and response time.

Tokenization is therefore not just an engineering detail—it can directly influence product economics and user experience.

2. Embeddings: Giving Tokens Numerical Representations

Token IDs are identifiers, not meaningful representations by themselves. The model maps each token ID to a learned numerical vector using an embedding matrix.

Conceptually:

Token ID

Embedding lookup

Vector of numbers

For example, a token might be represented by a vector containing hundreds or thousands of numerical dimensions.

During training, these representations are learned. Tokens with related usage patterns can develop similar representations in the model’s learned space.

The model also needs information about position. “The dog chased the cat” and “The cat chased the dog” contain the same words but have different meanings because their order changes. Positional information helps the model account for sequence order.

The resulting numerical representation is passed deeper into the transformer.

AI Product Manager takeaway

Embeddings are particularly important when thinking about AI products involving:

  • semantic search,
  • recommendation,
  • retrieval-augmented generation (RAG),
  • document similarity,
  • clustering,
  • vector databases.

While the embedding process inside a generative LLM is part of inference, separate embedding models are also commonly used to represent documents and queries for retrieval systems.

3. Self-Attention: Adding Context

This is one of the most important ideas behind transformer models. A token’s meaning depends on surrounding tokens.

Self-attention allows each token to consider other tokens in the sequence and determine which ones are relevant to its representation.

A simplified way to think about attention is:

“Given this token, which other tokens should I pay attention to?”

Attention uses three learned projections:

  • Query (Q): What information am I looking for?
  • Key (K): How can other tokens match what I am looking for?
  • Value (V): What information should be provided if a token receives attention?

For a token, the model compares its query with other tokens’ keys, typically using a dot product. These scores are normalized using softmax to produce attention weights.

The weighted values are then combined to create a context-aware representation.

Why is it called multi-head attention?

Transformers generally use multiple attention heads.

Different heads can learn different relationships within the sequence. Their outputs are combined before being passed onward through the transformer architecture.

AI Product Manager takeaway

Self-attention helps explain why context quality matters.

If an AI product sends an enormous amount of irrelevant information into a model, the model is not necessarily receiving “more intelligence.” You may simply be increasing token usage, computation, and noise.

This is one reason good context construction, retrieval, prompt design, and conversation-history management matter in AI product development.

4. Logits: Scoring the Possible Next Tokens

After the transformer processes the sequence, the model needs to predict the next token. In autoregressive generation, the representation at the last position produces scores for possible next tokens.

These raw scores are called logits.

Conceptually:

Context representation

Linear projection

Logits for vocabulary

If the vocabulary contains tens of thousands of possible tokens, the model produces a score for each possible next token.

A logit is not yet a probability. The values can be positive or negative and are not normalized.

Think of logits as raw “votes” for possible next tokens.

5. Softmax: Turning Scores Into Probabilities

The next step is to transform logits into a probability distribution.

This is done using the softmax function.

Conceptually:

Logits

Softmax

Probability distribution

The resulting values are positive and sum to 1. For example:

Candidate tokenProbability
tree0.62
flower0.14
garden0.08
house0.03
other tokens0.13

The model now has a probability distribution over its vocabulary.

Temperature

A generation setting called temperature can modify this distribution. Lower temperature generally concentrates probability on high-probability tokens; higher temperature makes lower-probability alternatives more likely.

In product terms:

  • Lower temperature: more predictable and deterministic output
  • Higher temperature: more varied and exploratory output

Temperature should not be treated as a universal “creativity slider.” Its effect depends on the model and the rest of the decoding configuration.

6. Sampling: Choosing the Next Token

A probability distribution still needs to produce an actual token.

That is the job of sampling or decoding.

One simple strategy is greedy decoding, where the system selects the token with the highest probability.

If:

tree   → 0.62
flower → 0.14
garden → 0.08

greedy decoding selects:

tree

Other decoding approaches can sample from the distribution rather than always selecting the highest-probability token.

The selected token ID is appended to the sequence.

"I went outside to plant a"

"I went outside to plant a tree"

The model then predicts the next token.

7. The Autoregressive Loop

This is the central mechanism behind text generation. After one token is generated, the process continues with the expanded sequence:

Input

Tokenization

Embeddings

Transformer / self-attention

Logits

Softmax

Sampling

New token

Repeat

The loop continues token by token.

For example:

I went outside to plant a
→ tree
→ in
→ the
→ ground

Generation stops at an end-of-sequence condition or configured generation limit.

Why this matters for AI products

This helps explain why output length affects latency and cost: generating a long response requires producing many tokens.

For an AI Product Manager, this creates an important product trade-off:

More output can provide more value, but it can also increase cost, latency, and the opportunity for errors.

8. Detokenization: Turning Tokens Back Into Text

Once generation is complete, the token IDs need to be converted back into human-readable text.

This is essentially the reverse of tokenization:

Token IDs

Vocabulary lookup

Text

The user finally receives a readable response.

So the overall flow is:

Human text

Tokenization

Token IDs

Embeddings + positional information

Transformer / self-attention

Logits

Softmax

Sampling / decoding

New token

Autoregressive loop

Detokenization

Human-readable response

What AI Product Managers Should Understand About LLM Inference

You do not need to memorize every matrix multiplication. Instead, focus on the product implications of the pipeline.

1. Tokens are a product constraint

Token usage influences API costs, context limits, and potentially latency.

When designing an AI feature, ask:

  • How much context does the model actually need?
  • Are we sending redundant history?
  • Can retrieval reduce irrelevant context?
  • How long should the output be?

2. Context is critical

Self-attention allows the model to use information from the input sequence. This makes context engineering a major part of AI product design.

A strong AI feature usually needs the right context, not simply the maximum amount of context.

3. Generation is probabilistic

The model produces a probability distribution and a decoding process selects tokens from it.

This means AI outputs are not guaranteed to be identical or correct every time.

Product teams should therefore design for:

  • evaluation,
  • guardrails,
  • fallback behavior,
  • human review where appropriate,
  • monitoring,
  • user feedback.

4. Temperature is only one generation parameter

Changing temperature can affect output variation, but it is not a complete solution for controlling model behavior.

AI PMs should understand the broader generation and evaluation setup rather than relying on one parameter to solve quality problems.

5. LLMs predict tokens, not facts

At inference time, the fundamental operation is next-token prediction based on learned parameters and provided context.

An LLM can produce fluent and convincing text without guaranteeing that every statement is factually correct. This is one reason retrieval, tool use, structured outputs, validation, and evaluation are important in production AI systems.

LLM Inference vs. LLM Training

A useful distinction is:

Training changes the model’s learned parameters based on training data and an optimization process.

Inference uses those learned parameters to process new input and generate output.

As an AI Product Manager, you will more often interact with inference-level concerns when building applications:

  • model selection,
  • prompt and context design,
  • token usage,
  • latency,
  • cost,
  • output quality,
  • temperature and decoding,
  • evaluation,
  • safety and reliability.

Final Takeaway

A transformer-based LLM does not simply “think of an answer” and then type it out. At a high level, it:

  1. Converts text into tokens.
  2. Maps tokens into numerical representations.
  3. Uses attention to incorporate contextual relationships.
  4. Produces logits for possible next tokens.
  5. Converts logits into probabilities.
  6. Uses a decoding strategy to select a token.
  7. Repeats the process autoregressively.
  8. Converts the resulting tokens back into readable text.

For an AI Product Manager, this pipeline provides a foundation for decisions around LLM cost, latency, context windows, prompt engineering, RAG, evaluation, and user experience.

You do not need to become a machine-learning researcher. You need enough understanding to connect model behavior → engineering constraints → product decisions.

AI PM principle: You don’t need to build the transformer, but you should understand enough about inference to make better decisions about the AI product built on top of it.