ML SYSTEM DESIGN & MLOPS · INTERVIEW QUESTION
When should you train/fine-tune your own LLM vs use a 3rd-party API?
🟡 intermediate · System Design Patterns
Hint: Consider cost, control, privacy, latency, and customization needs.
Answer
Use 3rd-party API (OpenAI, Anthropic, Google) when:
-
Getting started / prototyping.
-
Low or uncertain volume, based on measured input/output token demand and current provider quotes.
-
General tasks without proprietary data needs.
-
Want state-of-the-art without infrastructure.
-
Fast time-to-market. Fine-tune your own when:
-
Specific domain with unique terminology/patterns.
-
Data privacy requirements (can't send data externally).
-
Sustained volume with a measured total-cost advantage; there is no universal token-volume crossover.
-
Latency requirements (self-hosted can be faster).
-
Need reproducibility and version control.
-
Regulatory compliance.
Cost comparison: API cost = input tokens × input rate + output tokens × output rate + applicable cache/tool charges. Self-hosted cost includes utilized and idle GPU capacity, redundancy, engineering, monitoring and training. Use dated quotes and matched quality, latency and context requirements; fine-tuning and self-hosting are separate decisions.
Middle ground: fine-tune smaller models (Mistral/LLaMA) for most tasks, use API for complex reasoning as fallback. Consider model routing: cheap model for simple queries, expensive model for complex ones.
Related questions
- Design a real-time ML serving system for a recommendation engine handling 10k QPS.
- What are ML design patterns? Explain the Feature Store pattern.
- Design a fraud detection system. What ML and engineering challenges arise?
- What is LLMOps and how does it differ from traditional MLOps?
- What is data drift and concept drift? How do you detect and handle them?