Skip to main content

Chapter 2: Local vs Cloud LLMs

Running AI on Your Own Machine​

You don't have to use cloud APIs to access LLMs. With open-source models and the right hardware, you can run AI locally—completely private and offline.


What Is Local LLM Running?​

Definition

Local LLM means running the AI model on your own computer or server, rather than sending requests to a cloud service.

The Key Difference​

Cloud LLMLocal LLM
Your data goes to OpenAI/AnthropicYour data stays on your machine
Pay per usePay for hardware once
Always latest modelUpdate manually
Requires internetWorks offline

Tools for Running Local LLMs​

Ollama​

The most user-friendly option for local LLMs.

Features:

  • One-command installation
  • Simple model management
  • Works on Mac, Windows, Linux
  • API compatible with OpenAI

Getting Started (example):

# Install Ollama, then:
ollama run llama3

LM Studio​

Desktop app with a graphical interface.

Features:

  • No command line needed
  • Model browsing and download
  • Chat interface built-in
  • Works on Mac and Windows

llama.cpp​

Technical but lightweight.

Features:

  • Very efficient
  • Works on minimal hardware
  • Powers many other tools
  • Full control over settings

Others​

  • Text Generation WebUI - Feature-rich interface
  • GPT4All - Simple desktop app
  • Jan - Modern, privacy-focused

Hardware Requirements​

What You Need​

Running LLMs locally requires decent hardware:

Model SizeMinimum RAMRecommended GPU
7B parameters8GBOptional (slower on CPU)
13B parameters16GB8GB VRAM
30B parameters32GB16GB VRAM
70B parameters64GB+24GB+ VRAM

Understanding Model Sizes​

ModelApproximate SizeQuality Level
7B~4-7 GBGood for many tasks
13B~7-13 GBBetter quality
30B~15-30 GBApproaching GPT-3.5
70B~35-70 GBNear frontier quality

Quantization: Making Models Smaller​

What Is Quantization?

Quantization reduces model precision to make it smaller and faster, with some quality trade-off.

Quantization Levels​

LevelSize ReductionQuality Impact
FP16BaselineFull quality
Q8~50% smallerMinimal loss
Q4~75% smallerNoticeable but usable
Q2~87% smallerSignificant loss

A 7B model can range from ~14GB (FP16) to ~3GB (Q4), making it runnable on laptops.


Privacy Benefits​

Your Data Stays Private​

When using cloud LLMs:

  • Prompts are sent over internet
  • Stored on provider servers
  • May be used for training (check ToS)
  • Subject to provider policies

When using local LLMs:

  • Nothing leaves your machine
  • No logging by third parties
  • Full compliance control
  • Works in air-gapped environments

Privacy-Critical Use Cases​

IndustryWhy Local Matters
HealthcareHIPAA compliance, patient data
LegalAttorney-client privilege
FinanceProprietary trading strategies
GovernmentClassified information
EnterpriseTrade secrets

Performance Considerations​

Latency​

DeploymentTypical Response Time
Cloud API (GPT-4)2-10 seconds
Local (M3 Max, 7B)1-3 seconds
Local (RTX 4090, 7B)Less than 1 second
Local (CPU only, 7B)10-30 seconds

Throughput​

Cloud APIs often handle more parallel requests, while local deployment is limited by your hardware.


Cloud Advantages​

Why Cloud Still Makes Sense​

  1. No upfront investment - Don't need expensive hardware
  2. Always up-to-date - Latest models automatically
  3. Scalability - Handle traffic spikes
  4. Multi-modal - Image, audio, video capabilities
  5. Global availability - Access from anywhere
  6. Expert maintenance - Providers handle operations

Cost Comparison​

Break-Even Analysis​

ScenarioCloud Cost (Monthly)Local Cost (Hardware)
Light use (1K queries)~$5-20$1,000+ GPU
Medium use (100K queries)~$500-2,000Same hardware
Heavy use (1M queries)~$5,000-20,000Same hardware

Rule of thumb: Heavy users save money with local; light users save money with cloud.


Hybrid Approaches​

Best of Both Worlds​

Common Hybrid Patterns​

PatternHow It Works
Sensitivity routingSensitive data → local; else → cloud
Complexity routingHard questions → better model
FallbackLocal first, cloud as backup
Local draft, cloud refineLocal generates, cloud polishes

Getting Started with Local LLMs​

Step 1: Check Your Hardware​

  • At least 8GB RAM for small models
  • GPU recommended but not required

Step 2: Choose a Tool​

  • Beginners: LM Studio or Ollama
  • Power users: llama.cpp or text-generation-webui

Step 3: Download a Model​

  • Start with Llama 3 8B or Mistral 7B
  • Use Q4 quantization if limited RAM

Step 4: Experiment​

  • Try different prompts
  • Compare to cloud models
  • Find what works for your use case

Key Takeaways​

✅ Local LLMs run on your own hardware, keeping data private

✅ Tools like Ollama and LM Studio make local running accessible

✅ Hardware requirements vary with model size (7B is most accessible)

✅ Quantization trades quality for smaller, faster models

✅ Privacy-critical applications often require local deployment

✅ Hybrid approaches combine local privacy with cloud capability


Think About It​

  1. What personal or work data would you never want to send to a cloud LLM?
  2. How might edge devices (phones, laptops) change if they could run capable LLMs locally?
  3. When would you choose cloud even if local were technically possible?

Next Steps​

Now let's look at where LLMs are heading in Chapter 3: Future Developments.