Model
A model is a mathematical system that is trained to obtain parameters and can calculate outputs based on inputs.
Layer 1: What Is a Model?
Understand the basic building blocks of an AI model from an engineering perspective, and how core concepts such as model, architecture, parameters, weights, configuration, and Tokenizer relate to each other.
- A model is a mathematical system that can compute outputs from inputs. Its architecture defines how the computation works, while the specific parameter values are obtained through training.
- Architecture is like a pre-designed computation framework; weights are the large set of numeric values filled in during training. Together they form a model with concrete capabilities.
Layer 2: How Is a Model Trained?
Understand from an end-to-end process how an AI model acquires capabilities through data and training, and how core concepts such as Dataset, Training, Pretraining, Fine-tuning, Loss, and Checkpoint relate to each other.
- Model training is the process of repeatedly feeding the model training data, measuring the error between its outputs and the targets, and continuously adjusting parameters so the model gradually learns to perform a class of tasks.
- A model starts with a fixed architecture and a large set of initial parameters. The training program repeatedly feeds it data, computes error, and adjusts parameters, eventually producing a set of weights that can generate useful outputs.
Layer 3: How Does a Model Turn Input into Output?
Understand from the inference pipeline how an AI model processes inputs and generates outputs, and how core concepts such as Tokenizer, Token, Embedding, Forward Pass, Logits, Sampling, and Context Window relate to each other.
- Input processing: convert human input into numbers the model can compute on;
- Autoregressive generation: predict one Token at a time, gradually forming the final output.
Layer 4: How Are Models Saved and Published?
Understand from an engineering perspective how an AI model is saved from in-memory parameters and training state into files, and how weights, configuration, Tokenizer, Chat Template, Model Card, and other resources are organized and published as a model repository.
- Training produces parameters and training state in memory; to pause training, distribute models, and run inference, these must be serialized into files and published together with configuration, Tokenizer, documentation, and other resources.
- During training, model parameters exist as Tensors in memory or VRAM.
Layer 5: How Is a Model Loaded and Run?
Understand from a runtime perspective how an AI model is loaded from files into memory and VRAM and executes inference, and how core concepts such as Inference Engine, CPU, RAM, GPU, VRAM, precision, quantization, Offload, and KV Cache relate to each other.
- Load the model: read files, create structure, allocate memory, place weights;
- Run inference: process input, run model computation, generate Tokens one by one.