Library

Volume 2 · GenAI Foundations & LLM Architecture

Notebook
Sign in

Section 2

Model Families & Selection

867 words · about 4 min

2.1 Major Model Families Comparison Table

Model Provider Context Window Approx. Pricing (in/out per 1M tokens) Strengths Best For
GPT-4o OpenAI 128K $2.50 / $10.00 Multimodal, broad reasoning, ecosystem General enterprise, complex reasoning
GPT-4o-mini OpenAI 128K $0.15 / $0.60 Cost-effective, fast High-volume, simpler tasks
Claude Sonnet (3.5/4) Anthropic 200K $3.00 / $15.00 Long context, safety, coding Document analysis, regulated industries, code generation
Claude Haiku (3.5/4) Anthropic 200K $0.25 / $1.25 Fast, cheap Classification, routing
Gemini 2.0 Pro Google 1M+ $1.25 / $5.00 Massive context, multimodal Long document processing, video
Gemini 2.0 Flash Google 1M+ $0.075 / $0.30 Very fast, cheap High-volume multimodal
Llama 3.1 405B Meta (open) 128K Compute cost only Open-source, fine-tunable On-prem, data-sensitive, customization
Llama 3.1 70B Meta (open) 128K Compute cost only Open-source, strong balance Self-hosted production
Mistral Large / Mixtral 8x22B Mistral AI 64K-128K Compute or low API cost Efficient MoE, EU-based EU data residency, cost efficiency
Command R+ Cohere 128K Mid-tier RAG-optimized, strong grounding Enterprise RAG applications
DeepSeek V3 DeepSeek (open) 128K Very low (self-host) Open-source, strong reasoning, MoE Research, cost-conscious deployment

2.2 Enterprise Model Selection Framework — The 7 C’s

  1. Capability: Can the model handle the task’s reasoning complexity?
  2. Context: Does the context window fit the input data (documents, history)?
  3. Cost: What’s the per-query and monthly cost at expected volume?
  4. Compliance: Does it meet data residency, PHI/PII, and privacy requirements?
  5. Customizability: Can it be fine-tuned for domain-specific needs?
  6. Consistency: How deterministic/reliable are outputs across repeated calls?
  7. Cadence: How frequently does the provider update/deprecate models (migration burden)?

2.3 Selection Decision Tree

flowchart TD
    Start{"Data Sensitivity &\nRegulatory Constraints?"}

    Start -->|High: PHI / PII / Strict Gov| Private["Self-Hosted / VPC Isolated\n(Llama 3.1, Mistral, DeepSeek)"]
    Start -->|Low / Medium: General SaaS| Public["Managed Enterprise API\n(Claude 3.5, GPT-4o, Gemini 2.0)"]

    Private --> CompPriv{"Task Complexity?"}
    Public --> CompPub{"Task Complexity?"}

    CompPriv -->|High: Deep Reasoning / Code| BigSelf["Large Open Model\n(Llama 3.1 70B / 405B)"]
    CompPriv -->|Low: Classification / Extraction| SmallSelf["Small SLM\n(Llama 3.1 8B, Mistral 7B)"]

    CompPub -->|High: Complex Synthesis / Logic| BigAPI["Flagship Frontier API\n(GPT-4o, Claude 3.5 Sonnet)"]
    CompPub -->|Low: Summaries / High Volume| SmallAPI["Cost-Optimized Fast API\n(GPT-4o-mini, Claude 3.5 Haiku)"]

2.4 Mixture of Experts (MoE)

Instead of activating the full parameter count for every token, MoE conditionally routes tokens to a small subset of specialized feed-forward “expert” sub-networks via a learned gating router.

flowchart LR
    Token["Input Token Embedding"] --> Router["Learned Gating Router\n(Top-k Softmax)"]

    subgraph Experts["Parameter Space (N Experts Loaded in VRAM)"]
        E1["Expert 1 (Active)"]
        E2["Expert 2 (Idle)"]
        E3["Expert 3 (Active)"]
        E4["Expert 4 (Idle)"]
        EN["Expert N (Idle)"]
    end

    Router -->|Weight: 0.65| E1
    Router -.->|Zero Weight| E2
    Router -->|Weight: 0.35| E3
    Router -.->|Zero Weight| E4
    Router -.->|Zero Weight| EN

    Sum["Weighted Combination (Out)"]
    E1 --> Sum
    E3 --> Sum

Key Architectural Trade-Offs of MoE:

  • Mixtral 8×22B: Contains ~176B total parameters loaded in VRAM, but activates only ~44B parameters per forward token pass.
  • DeepSeek V3: 671B total weights, activating only ~37B weights per token.
  • Inference Reality: Delivers the quality of frontier mega-models at the latency and token compute cost of small models. However, GPU memory footprint is dominated by total parameter size, meaning MoE deployments are strictly VRAM-bound rather than compute-bound.

Section 2 — Interview Q&A

Q: A client wants to deploy a GenAI solution for internal document Q&A across 50,000 employees. How do you approach model selection? A: Start with requirements: query volume (50K × 3-5/day ≈ 150-250K queries/day), data sensitivity, latency target (<3s), and budget. Design a tiered routing architecture: ~60% simple/FAQ queries → cheapest model (e.g., GPT-4o-mini, ~$0.003/query); ~30% medium complexity → mid-tier model (~$0.012/query); ~10% complex reasoning → best model with extended context (~$0.025/query). This yields roughly $2K/day before optimization. Layer in semantic caching (30% reduction) and fine-tuning of the cheap tier on domain data to shift more traffic downward — net target ~$35K/month. For data privacy: if regulated industry, use a managed offering with a data-processing agreement (data doesn’t leave tenant) or self-host Llama on private infrastructure for maximum control.

Q: What are the key differences between OpenAI, Anthropic, Google, and open-source models for enterprise use? A: OpenAI (GPT-4o) offers the broadest capability and ecosystem maturity. Anthropic (Claude) leads on long-context handling, safety alignment, and code generation — strong for document-heavy, safety-critical use cases. Google (Gemini) offers the largest context windows and native multimodal (video/audio) support. Open-source (Llama/Mistral) gives full control, zero vendor lock-in, and the best option for regulated/on-prem deployments, at the cost of operational burden. In practice, most enterprises adopt a hybrid multi-model strategy: a managed API as the default, an open-source self-hosted model for high-volume/sensitive workloads, and specialized models for niche tasks (vision, code).

Q: What is MoE and why does it matter for enterprise deployment decisions? A: MoE routes each token to a small subset of expert sub-networks rather than activating the full parameter count, giving large-model quality at a fraction of the per-token compute cost. This matters because self-hosting an MoE model requires provisioning enough VRAM to hold all experts in memory even though only a fraction execute per token — so MoE models can be memory-bound rather than compute-bound. When evaluating open-source deployment options (e.g., DeepSeek V3, Mixtral), architects must size infrastructure around total parameter memory footprint, not just active-parameter compute.