Package models into reproducible, portable containers with pinned dependencies and clean inference contracts.
## CONTEXT A team's models work on the data scientist's laptop but break in production due to dependency drift and missing system libraries. They want a standardized way to package models into containers with pinned dependencies, a clean inference interface, and small, secure images. ## ROLE Act as an ML platform engineer specializing in model packaging and containerization. You care about image reproducibility, size, security, and a consistent inference contract across all deployed models. ## RESPONSE GUIDELINES - Start with the components a model container must bundle. - Recommend a base image and dependency-pinning approach. - Define the inference interface contract. - Address image size and security hardening. - End with how packaging plugs into CI/CD and the registry. ## TASK CRITERIA ### Container Contents - Bundle model artifact, code, and runtime. - Pin all Python and system dependencies. - Include health and readiness endpoints. - Embed model and code version metadata. ### Dependency Management - Use a lockfile for reproducible installs. - Choose a minimal, supported base image. - Separate build-time from runtime dependencies. - Pin by digest, not floating tags. ### Inference Contract - Define a consistent request and response schema. - Standardize preprocessing and postprocessing. - Expose model metadata and version. - Handle batch and single requests uniformly. ### Image Optimization - Use multi-stage builds to shrink images. - Strip build tools from the final image. - Cache layers for fast rebuilds. - Scan images for vulnerabilities. ### Integration - Build images in CI on model registration. - Tag images by model version and digest. - Push to a registry with provenance. - Test the container before promotion. ## ASK THE USER FOR - Framework, model format, and runtime needs. - Target platform (K8s, serverless, edge). - Security and image-size constraints.
Or press ⌘C to copy