CNSLT ACADEMY / MODEL DEPLOYMENT AND SYSTEM DESIGN

Model Inference

FOUNDATIONSBEGINNERFREE TEXT LESSONVIDEO 🔒 PRO

By the end, you should be able to explain inference, distinguish it from training, describe the major steps in text generation, identify common generation settings, and explain why inference matters to security, privacy, reliability and cost.

Model Inference

##

  1. Start with the distinction: training vs inference

Training is the process of adjusting model parameters using data and an optimisation procedure. Inference is using the resulting model to produce an output for a particular input. A useful analogy is teaching and taking an exam: training builds capability; inference uses the capability. The analogy is imperfect because deployed models may also use retrieval, tools, system instructions and post-processing.

A deployed AI feature is usually more than a model. It can include a user interface, application backend, policy checks, retrieval system, model endpoint, tools, logging and monitoring. When assessing risk, assess the whole service, not only the model.

##

  1. What happens during text inference?

A typical autoregressive text-generation path looks like this:

  1. Input assembly. The application combines the user message with system/developer instructions, conversation history and any retrieved context that is permitted.
  2. Tokenisation. Text is converted into token IDs. A token can be a word, part of a word, punctuation or another unit. Tokens are not the same as characters or words.
  3. Numerical representation. Token IDs are mapped to vectors. Positional information helps the model represent token order.
  4. Forward pass. Transformer layers process the representation using attention and feed-forward operations. The model calculates scores for possible next tokens.
  5. Selection. Scores, often called logits, are converted into a probability distribution and a decoding strategy selects the next token.
  6. Repeated generation. The selected token is appended to the context and the process repeats until a stop condition or output limit is reached.
  7. Post-processing. The application may apply formatting, safety checks, tool orchestration or other product-specific logic before showing the result.

The model does not usually write an entire paragraph in one indivisible operation. In autoregressive generation, it produces a sequence one token at a time. Other model architectures and generation modes can behave differently.

##

  1. Generation settings
  • Temperature: changes how strongly the selection process favours high-probability tokens. Higher values generally increase variation; lower values generally make outputs more concentrated. It does not guarantee truth or creativity.
  • Top-p: nucleus sampling limits selection to a set of tokens whose cumulative probability reaches a configured threshold. Its interaction with temperature is provider- and implementation-dependent.
  • Maximum output tokens: caps generated output. It is not the same as the model's total context window.
  • Context window: the amount of input and output context the model can process in one request, subject to provider rules.
  • Stop conditions: stop strings, end-of-turn tokens, tool hand-offs or output limits can end generation.

Changing settings changes output behaviour, not the underlying facts known by the model. A low temperature does not make a model a verified database.

##

  1. Worked example: phishing triage

An analyst submits an email for classification. The application may assemble a policy instruction, the email body and a request for a structured classification. The model processes the tokens and generates a label and explanation. The application should validate the response schema, preserve the source email, record the model/version and route uncertain or high-impact cases to a human.

Do not let a generated label automatically block a payment or disable an account unless the surrounding system has independently approved that action and appropriate safeguards exist.

##

  1. AI GRC and security implications

Inference creates operational risks even when training was completed safely:

  • Sensitive prompts or retrieved records may be sent to a provider or retained in logs.
  • Malicious instructions inside user content or retrieved documents may influence model behaviour.
  • Outputs may be inaccurate, biased, incomplete or inconsistent.
  • Model or provider outages can affect business availability.
  • Long prompts, repeated generation and inefficient serving can create unexpected cost.
  • Logging may capture secrets, personal data or regulated information.

Assess data flows, retention, access, encryption, tenant isolation, output validation, abuse controls, provider terms, incident response and human oversight.

##

  1. Common misconceptions
  • Inference is not another word for training.
  • A model response is not automatically deterministic.
  • A fluent answer is not evidence of correctness.
  • A model API response is not necessarily the final user-visible output.
  • The context window is not a guarantee that every supplied item will be used accurately.

##

  1. Practical exercise

Map an AI-assisted vendor-risk workflow. Identify the prompt, user-supplied documents, retrieval sources, model endpoint, generated output, human reviewer and audit record. For each component, record the data it receives, the trust boundary, failure mode and control.

##

  1. Knowledge check
  2. What is the core difference between training and inference?
  3. Why does tokenisation matter?
  4. What does the context window limit?
  5. Does low temperature guarantee factual accuracy?
  6. Name three risks that arise during inference.

Answer key:

  1. Training adjusts model parameters; inference uses a model to generate or calculate an output.
  2. Models process token IDs rather than raw text characters.
  3. The amount of context handled in a request.
  4. No.
  5. Examples include prompt injection, data exposure, hallucination, availability and cost risks.

##

  1. Checklist
  • [ ] Identify every system component involved in inference.
  • [ ] Document input sources and data classifications.
  • [ ] Confirm provider retention and processing terms.
  • [ ] Validate output format and content before downstream use.
  • [ ] Set token, rate, timeout and cost limits.
  • [ ] Log model/version and relevant decision metadata safely.
  • [ ] Define human review for consequential decisions.

##

  1. Further reading
LEARNER FEEDBACK

Help improve this learning path.

Suggest a concept we should teach, or tell us what is unclear. No account is required. Email is optional and only for a reply. Do not include confidential or sensitive information.

COURSE PROGRESS0/29 complete
Not yet completed
CHECK YOUR UNDERSTANDING