Module 5: LLMs (Large Language Models) - GPT, Claude and More

7. The Major LLMs: GPT-4, Claude 3, Llama 3, Gemini and More

Description

In this lesson you'll get to know the most important LLMs on the market (2024): what differentiates them, when to use each one, the trade-offs (intelligence vs cost vs context window).

What you'll learn:

  • The main providers: OpenAI, Anthropic, Google, Meta, Mistral.
  • A detailed comparison: GPT-4, Claude 3, Llama 3, Gemini, Mistral.
  • Trade-offs: Intelligence, cost, context window, latency, multimodal.
  • How to choose based on your use case.

The 5 Most Important LLMs (2024)

1. GPT-4 (OpenAI)

Characteristics:

  • Parameters: ~1 trillion (rumored, OpenAI doesn't confirm).
  • Context window: 8K, 32K, 128K tokens (depending on the version).
  • Multimodal: Text + images.
  • Knowledge: Through December 2023 (GPT-4 Turbo).

Strengths:

  • The smartest: Better reasoning, math, code.
  • Multimodal: It can analyze images.
  • A mature ecosystem: Many tools, documentation, community.

Weaknesses:

  • More expensive: $0.03/1K tokens (input), $0.06/1K (output).
  • A smaller context window than Claude 3 or Gemini 1.5.

When to use it:

  • Complex tasks (reasoning, math, advanced code).
  • Multimodal (image + text analysis).
  • When quality is critical and cost isn't a limiting factor.

2. Claude 3 (Anthropic)

Variants: Haiku (fast), Sonnet (balanced), Opus (most capable).

Characteristics:

  • Context window: 200K tokens (~150K words, ~500 pages).
  • Emphasis: Safety, accuracy, refusing to hallucinate.

Strengths:

  • A larger context window: 200K vs GPT-4 (128K).
  • Better with long documents: It can process complete books.
  • Cheaper (Haiku): $0.00025/1K tokens (4× cheaper than GPT-4).

Weaknesses:

  • Less multimodal than GPT-4 (Claude 3 supports images, but with less public testing).

When to use it:

  • Analyzing long documents (contracts, papers, books).
  • When the context window is critical.
  • When cost is a limiting factor (use Haiku).

3. Llama 3 (Meta)

Variants: 8B, 70B, 400B parameters.

Characteristics:

  • Open-source: You can download the weights and run it locally.
  • Free: There's no cost per token (only infrastructure/hosting).
  • Context window: 8K / 32K tokens.

Strengths:

  • Free: You don't pay per token (only for hosting).
  • Open-source: Total control, privacy.
  • Comparable performance: Llama 3 (70B/400B) competes with GPT-4 on many tasks.

Weaknesses:

  • It requires infrastructure: Powerful GPUs (e.g. an A100) to run it locally.
  • A smaller context window: 8K-32K (vs GPT-4: 128K, Claude: 200K).
  • Less capable (8B/70B) than GPT-4 (but 400B is competitive).

When to use it:

  • When privacy is critical (sensitive data you can't send to APIs).
  • When there's high volume → the per-token cost of APIs doesn't scale.
  • When you want total control (fine-tuning without restrictions).

4. Gemini (Google)

Variants: Gemini 1.0, Gemini 1.5, Gemini Pro.

Characteristics:

  • Multimodal: Text, image, audio, video.
  • Context window: Gemini 1.5 has 1M tokens (~750K words).
  • Integration: Google Workspace, Google Search.

Strengths:

  • A massive context window (1.5): 1M tokens (8× more than GPT-4).
  • Advanced multimodal: It processes video, audio (not just text + image like GPT-4).
  • Integration with Google: Access to Google's tools.

Weaknesses:

  • Less public testing than GPT-4/Claude.
  • A less mature API than OpenAI's.

When to use it:

  • Very long documents (books, long contracts).
  • Advanced multimodal (video, audio).
  • If you already use Google Cloud.

5. Mistral (Mistral AI)

Variants: Mistral 7B, Mixtral 8x7B, Mixtral 8x22B.

Characteristics:

  • Open-source: Downloadable, free.
  • Parameters: 7B - 176B (Mixtral 8x22B).
  • Mixtral: Mixture of Experts (MoE) → more efficient.

Strengths:

  • Open-source: Total control.
  • Efficient: MoE activates only part of the parameters → faster.
  • Europe: A European startup (vs US companies).

Weaknesses:

  • Less capable than GPT-4 (but competitive with GPT-3.5).

When to use it:

  • An open-source alternative to Llama 3.
  • When efficiency is critical (MoE).

Detailed Comparison

AspectGPT-4Claude 3 OpusLlama 3 (400B)Gemini 1.5Mistral Large
Parameters~1T~500B (rumored)400B~500B (rumored)176B
Context window128K200K32K1M32K
MultimodalText + imageText + imageText onlyText + image + video + audioText only
Cost (input)$0.03/1K$0.015/1KFree (hosting)$0.035/1K$0.008/1K
Cost (output)$0.06/1K$0.075/1KFree$0.105/1K$0.024/1K
Open-sourceNONOYESNOYES
SpeedMediumFastIt depends (local)MediumFast

How to Choose an LLM Based on the Use Case

Case 1: A Simple Chatbot

Requirements: Fast responses, low cost, high volume.

Recommendation: GPT-3.5-turbo ($0.002/1K tokens, 10× cheaper than GPT-4) or Claude 3 Haiku ($0.00025/1K).


Case 2: Analyzing Long Documents

Requirements: A large context window, high accuracy.

Recommendation: Claude 3 (200K tokens) or Gemini 1.5 (1M tokens).


Case 3: Complex Reasoning

Requirements: Maximum intelligence (math, logic).

Recommendation: GPT-4 (better reasoning) or Claude 3 Opus.


Case 4: Privacy / Total Control

Requirements: Sensitive data, you can't send it to external APIs.

Recommendation: Llama 3 (open-source, run locally) or Mistral.


Case 5: Advanced Multimodal

Requirements: Processing video, audio (not just text + image).

Recommendation: Gemini 1.5 (the only option with native video/audio).


Future Trends (2024-2025)

1. Larger context windows

  • Gemini 1.5 already has 1M tokens.
  • Claude 3 has 200K.
  • Trend: All the models will grow to 500K-1M tokens.

2. Cheaper models

  • Competition → prices drop: Claude 3 Haiku is 4× cheaper than GPT-4.
  • Open-source is growing: Llama 3, Mistral compete with proprietary models.

3. Specialization

  • Vertical models: LLMs specialized in medicine, legal, finance.
  • Small models: 1B-10B parameters optimized for mobile devices.

Why this matters for an AI Engineer

1. Model selection is a key decision

Impact on your application:

  • Cost (it can be 10-100× different).
  • Latency (GPT-4 is slower than GPT-3.5).
  • Capability (GPT-4 has better reasoning than GPT-3.5).

2. A multi-model strategy

In production, many companies use multiple models:

  • GPT-4: Complex tasks (reasoning, code).
  • GPT-3.5: Simple tasks (a basic chatbot).
  • Claude 3: Long documents.
  • Llama 3 (local): Sensitive data.

Advantage: Optimizing cost/quality per task.


Summary

The 5 main LLMs:

  1. GPT-4: The smartest, multimodal, more expensive.
  2. Claude 3: A large context window (200K), an emphasis on safety.
  3. Llama 3: Open-source, free, requires hosting.
  4. Gemini 1.5: A massive context window (1M), advanced multimodal.
  5. Mistral: European open-source, efficient (MoE).

How to choose:

  • Maximum intelligence: GPT-4, Claude 3 Opus.
  • Long documents: Claude 3, Gemini 1.5.
  • Low cost: GPT-3.5, Claude 3 Haiku.
  • Privacy: Llama 3, Mistral (local).
  • Multimodal: GPT-4, Gemini 1.5.

Next step: Lesson 08: Integrative Exercise — Experimenting with parameters, comparing LLMs, calculating costs.