Inference
Inference is the process of using a trained model to produce outputs. It can be offline batch inference, interactive serving, retrieval scoring, generation, or agent action selection.
The generic form is:
For autoregressive generation:
Inference cost depends on input length, output length, batch size, model size, precision, cache behavior, and hardware.
Modes
- Batch inference for large offline datasets.
- Online inference for request-response services.
- Streaming inference for token, audio, or video outputs.
- Retrieval inference for embedding and nearest-neighbor search.
- Tool-using inference for agents.
Inference Pipeline
Inference is usually a pipeline, not only a model call:
Each stage has its own validity rules and failure modes. Evaluation should use the same preprocessing and postprocessing as deployment unless the difference is explicitly tested.
Decoding and Constraints
For generative models, inference includes decoding:
where contains constraints such as temperature, max tokens, schemas, stop conditions, beam size, or validity functions. These settings are part of the method.
Failure Modes
- Input is accepted but interpreted under the wrong schema.
- Preprocessing differs from training or evaluation.
- Postprocessing repairs invalid outputs without counting failures.
- Batch order, random seed, cache state, or timeout changes outputs.
- Model returns fluent but unsupported text for missing evidence.
Checks
- Is there an inference contract for accepted inputs, outputs, and errors?
- Is the workload latency-bound or throughput-bound?
- Is preprocessing identical to evaluation?
- Are outputs constrained to valid task objects?
- Does batching change output order, randomness, or timeout behavior?
- Are failures explicit rather than silently returning malformed outputs?
- Are decoding parameters and validity checks recorded?
- Are invalid outputs included in quality and efficiency metrics?
- Is fallback behavior explicit when retrieval, tools, or preprocessing fail?