Why distribution shift is the main enemy of production ML
A client comes with a dataset of 200k rows and asks: "Why does the baseline model give 87% accuracy, but in production it drops to 71%?" The answer is almost always the same — distribution shift between training and inference data that no one measured. This is where real AI solution development begins: not with architecture selection, but with understanding the data.
We are a team with 7 years of experience in production ML and 50+ completed projects. We build systems that work under load: reproducible pipelines, model versioning, data drift monitoring, and inference SLAs guaranteed at P99. No notebooks with "promising results."
What AI development solutions include
By AI/ML we mean the full cycle: data collection and labeling, training, validation, deployment, monitoring, and retraining. Each stage can be a standalone task or part of an end-to-end project.
Directions we work with:
- LLM and Generative AI — fine-tuning, RAG pipelines, multi-agent systems, deployment via vLLM with PagedAttention
- Computer Vision — object detection, segmentation, OCR, face recognition, video analytics
- NLP — NER, text classification, sentiment analysis, information extraction, embeddings
- MLOps — training and deployment infrastructure, model registry, CI/CD for models, monitoring
- Recommendation Systems — collaborative filtering, content-based, hybrid approaches, real-time serving
- Data Engineering for ML — feature store, ETL pipelines, labeling, data quality
- Speech — ASR (speech recognition), TTS, speaker diarization
What tech stack we use and why
Tool selection depends on the task, not habit.
Model training. PyTorch is the primary framework. We keep TensorFlow for legacy projects and TensorFlow Serving. We use JAX when high performance on TPUs or custom gradients is needed. Hugging Face Transformers + PEFT + trl is the standard for working with language models: LoRA, QLoRA, DPO, RLHF. DeepSpeed and FSDP for distributed training on multiple GPUs.
Inference. vLLM with PagedAttention for LLMs — handles 200+ req/s with P99 latency < 800ms on A100, delivering 4x lower latency than naive deployment without continuous batching. ONNX Runtime + TensorRT for CV models — provides 3-8x acceleration over native PyTorch inference. bitsandbytes for INT4/INT8 quantization without significant quality loss.
Vector databases. pgvector for projects on PostgreSQL (zero infrastructure dependency). Qdrant and Weaviate when production-grade vector search with filtering and scaling is needed. FAISS for offline indices and experiments. ChromaDB for development and prototyping.
LLM orchestration. LangChain for complex agentic pipelines. LlamaIndex when the task is RAG on documents. Direct calls to OpenAI API, Claude API, Mistral API when an orchestrator is overkill.
MLOps. MLflow for experiment tracking and model registry. Weights & Biases for projects with intensive experimentation requiring visualization and collaboration. Kubeflow for ML pipelines on Kubernetes. DVC for data and model versioning.
Why GPU OOM kills timelines more than bad architecture
This is one of the most common stoppers in real projects. A team spent a week selecting an architecture, launched training of a 7B model on an A100 40GB — and 10 minutes later OOM. The reasons are typical.
First: gradient_accumulation_steps not configured. With batch_size=32 and sequence length 2048 tokens, activations take ~18GB just for forward pass. Solution: reduce batch to 4 and set gradient_accumulation_steps=8, effective batch same, memory footprint radically smaller.
Second: training in fp32 instead of bf16. Switching torch_dtype=torch.bfloat16 in Hugging Face Trainer halves memory consumption. On Ampere architecture (A100, A6000), bf16 works faster than fp16 and without loss scaling.
Third: gradient checkpointing not used. model.gradient_checkpointing_enable() sacrifices 20-30% training speed but cuts activation memory by 5-8x. On long sequences this is critical.
With QLoRA the situation is even better: 4-bit quantization of the base model via bitsandbytes + LoRA adapters allows fine-tuning Llama-3 70B on two A100 40GB. Trainable parameters ~0.5% of total, but the fine-tuning result is comparable to full training on narrow tasks. This approach reduces memory footprint by 4x compared to full fine-tuning.
Distribution by typical tasks
Understanding which part of a project takes the most time helps with proper planning.
| Task | Data | Model | MLOps | Total |
|---|---|---|---|---|
| Fine-tuning LLM on corporate data | 30% | 40% | 30% | 100% |
| CV detection in production | 40% | 35% | 25% | 100% |
| RAG on documents | 25% | 30% | 45% | 100% |
| Recommendation system | 50% | 25% | 25% | 100% |
| NER on specialized vocabulary | 45% | 35% | 20% | 100% |
Data is always more expensive than it seems. This is not pessimism — it's experience from dozens of projects.
How to validate the system, not just the model
A model with F1 0.91 on a holdout set is no guarantee of F1 0.91 in production. The gap between offline and online metrics occurs for several reasons.
Temporal leakage. Train contains future data relative to validation. With random split on temporal data, this happens automatically. The correct approach is temporal split with a gap between train and val to eliminate feature leakage.
Feature drift. The distribution of input data changes over time. The model is trained on data from previous periods, but today user behavior has changed. Monitoring distribution shift via PSI (Population Stability Index) or KL-divergence is mandatory for production ML systems.
Label shift. The class ratio in production differs from training. This is especially critical in fraud detection and medical diagnosis, where imbalance can reach 1:5000.
To neutralize these effects, we use: stratified k-fold with temporal awareness, calibration via Platt scaling or isotonic regression, threshold tuning to real business metrics (not accuracy, but precision@recall).
Generative AI in production: real limitations
LLM projects have specifics not described in tutorials. The three most frequent problems.
Hallucinations in RAG. The model confidently answers a question that is not in the context. The cause is often not the model but poor retrieval: chunk_size=512 without overlap leads to the relevant answer being split between two chunks. Solution: overlap 20-30%, hybrid search (dense + sparse BM25), re-ranking via cross-encoder (e.g., ms-marco-MiniLM-L-6-v2 from sentence-transformers).
Latency. Naive deployment of a 13B model on a single A10G gives P50 latency ~4s — unacceptable for interactive applications. vLLM with PagedAttention and continuous batching reduces this to 600-900ms P50 under the same load. For even more aggressive optimization: AWQ quantization to 4 bits with minimal quality degradation.
Context management. With a context window of 128k tokens, models degrade in the middle of the context (lost in the middle). For long documents, hierarchical RAG works better: first coarse retrieval via summary embeddings, then fine retrieval via original chunks.
Speech technologies
ASR tasks often come with a requirement to "recognize industry-specific vocabulary" — medical terms, legal constructs, product names. OpenAI Whisper large-v3 gives a good baseline WER, but on specialized vocabulary errors increase sharply.
Fine-tuning Whisper via LoRA on a corpus of 50-200 hours of labeled speech reduces WER on specialized vocabulary by 2-3 times. Moreover, adapters weigh 30-50MB — unlike the full model (3GB for large-v3), they are easy to version and deploy.
For speaker diarization we use pyannote.audio 3.x with pretrained pipelines and custom adaptation to the specific acoustic domain.
Project phases and estimated budget
Data audit and problem definition. We look at class distribution, labeling quality, volume, and presence of temporal patterns. Often the task is reformulated: from "predict churn" to "rank customers by probability of churn in the next 30 days." This changes metrics and architecture.
Baseline in 1-2 weeks. A simple model with a reproducible pipeline. The goal is to lock metrics, ensure data adequacy, and get a reference point. XGBoost or logistic regression as baseline is better than a neural network without understanding the problem.
Iterative improvement. Feature engineering, architecture selection, hyperparameter tuning via Optuna or Ray Tune. Each experiment is logged in MLflow or W&B — otherwise it's impossible to understand what really helped.
Validation and stress testing. Check on edge cases, adversarial inputs, load testing. For LLMs: red teaming and hallucination evaluation.
Deployment and monitoring. Canary release, A/B testing, setting alerts on quality metrics and data drift. A model without monitoring degrades unnoticed.
Estimated timelines and cost
| Project Type | Timeline | Estimated Cost |
|---|---|---|
| Prototype on existing data | 2-4 weeks | Contact for pricing |
| Production-grade system with MLOps | 3-6 months | Contact for pricing |
| Integration of a ready-made model | 1-3 weeks | Contact for pricing |
Cost depends on data volume, computational requirements, and infrastructure complexity — estimated individually after task audit. Savings on inference via optimization (vLLM, quantization) can reach 40% of operational costs.
What deliverables do you get after an AI project
Every engagement includes a standardized set of artifacts to ensure reproducibility and handover:
- Data audit report (distribution, quality, temporal patterns, labeling errors)
- Model card with training configuration, hyperparameters, and final metrics
- Reproducible pipeline: DVC for data, MLflow for experiments, Docker for environments
- Deployed endpoint with monitoring dashboard (latency P50/P95/P99, drift alerts)
- Knowledge transfer session (2 hours) and complete documentation
- 2-week post-launch support with hotfix response within 4 hours
Optionally, we provide custom dashboards for business stakeholders and integration with your existing CI/CD.
Why data drift monitoring is a non-negotiable requirement
According to MLflow documentation, systems without monitoring degrade on average within 2 months. This is not theory — we have seen projects where accuracy dropped from 91% to 73% in six weeks because user behavior changed seasonally. Monitoring data drift with PSI and performance alerts is the only way to catch degradation before it impacts business metrics. We guarantee that your model goes into production with at least three drift metrics and automatic retraining triggers.
Common mistakes when starting an AI project
- Lack of data drift metrics before deployment
- Using only accuracy for imbalanced classes
- Lack of P99 latency monitoring
- Fine-tuning the entire model when LoRA suffices
- Ignoring temporal split during validation
- Skipping cost estimation for inference at scale
How to begin your first AI project without wasting six months
Check how ready your task is for an ML solution. Get a consultation on your project — order a preliminary audit of data and requirements. Contact us to assess your task and receive a detailed roadmap with time and cost estimates. We work with certified AWS/GCP infrastructure and guarantee data privacy.







