β¨ Summary
Large Language Models (LLMs) have powered the AI wave of the last 3β4 years. While most are closed-source, a vibrant ecosystem of open-weight and open-source models has emerged.
As a long-time AI user, I wanted to peek under the hood: how do GenAI models work, and what happens when you actually run them locally on your laptop?
In this blog, Iβll cover:
- How GenAI models are built βοΈ
- Why local inference matters π
- My experiments with Qwen, Llama, and GPT-OSS on my Mac π»
π Hybrid Model Inference
Computing has gone through cycles: centralized β decentralized β hybrid. I believe AI inference is following the same path:
- Early computing β Mainframes (centralized)
- PCs/laptops β Decentralized
- Today β Cloud + Edge (hybrid)
π Most model inference currently happens in the cloud (huge infra needed).
π But smaller, specialized models now run on edge devices (laptops, even mobiles).
β οΈ Training wonβt realistically move to the edge β itβs too compute-heavy and usually a one-time process.
β
Inference is moving local β itβs repeated, latency-sensitive, and can benefit from privacy/cost savings.
π‘ Use Cases of Running Models Locally
- β‘ Reduce latency: Voice assistants, live translation, autonomous vehicles
- π° Reduce cost: Developer workflows, consumer electronics
- π Offline use: Remote fieldwork, disaster response
- π Privacy: Healthcare, enterprise security
- π οΈ Customization: LoRA adapters, RAG integration
ποΈ How GenAI Models Are Created
LLMs typically follow the Transformer architecture and are built in two stages:
- Pre-training: Learn general language patterns from massive datasets
- Post-training (fine-tuning): Teach task-specific skills (chat, reasoning, coding, etc.)
Result β A model ready for inference.
π§© What an AI Model Contains
- Weights: Learned numerical parameters (quantized models = smaller + faster)
- Tokenizer & Vocabulary: Convert text β tokens
- Config: Architecture, layer counts, hidden sizes, etc.
ποΈ Common formats: Hugging Face / Transformers, GGUF, ONNX, Apple MLX.
π How Generation Works (Simplified)
- Tokenization β Text β tokens
- Forward pass β Model processes tokens β probability distribution
- Decoding β Pick next token (greedy, sampling, top-k/top-p, etc.)
- Loop β Append token β repeat until done
- Detokenize β Tokens β final response
π Comparing Models
Common Evaluation Axes
- Technical specs: Parameters, memory, speed, context length
- Quantitative benchmarks: MMLU (knowledge), ARC (science), HumanEval (coding)
- Qualitative: Creativity, domain knowledge, licensing
π Open-Weights Model Comparison
I installed these 3 models in my mac, more details on it further down…
| Feature | Qwen2.5:7B-Instruct | Llama3:latest | GPT-OSS:20B |
|---|---|---|---|
| Model Size | 7B | 8B | 20B |
| File Size | 4.7 GB | 4.7 GB | 13 GB |
| Key Advantage | Multilingual (29+), strong structured output | Reasoning + code gen optimized | Large, strong reasoning |
| Hardware Need | 8GB+ GPU | 8GB+ GPU | 16GB+ GPU |
| Typical Use | Multilingual chat, summarization | General-purpose, coding, creative writing | Advanced reasoning, tool use |
| License | Apache 2.0 | Meta custom (check site) | Apache 2.0 |
π Open Weights vs Open Source models
Often confused! Hereβs the difference π
| Action | Open Source | Open Weights |
|---|---|---|
| Run inference | β | β |
| Fine-tune (adapters) | β | β |
| Full retraining | β | β |
| Audit code/data | β | β |
| Commercial use | Usually allowed | Often restricted |
| Redistribution | Usually | Restricted |
| Modify & republish | β | β |
π Takeaway: Open weights let you use and adapt, but open source lets you rebuild.
π» Using Open Weight Models Locally
On my MacBook Pro (32 GB RAM) I installed models using Ollama:
- Qwen2.5:7B-Instruct
- Llama3:latest
- GPT-OSS:20B
ollama list
NAME ID SIZE MODIFIED
qwen2.5:7b-instruct 845dbda0ea48 4.7 GB 3 weeks ago
llama3:latest 365c0bd3c000 4.7 GB 3 weeks ago
gpt-oss:20b aa4295ac10c3 13 GB 3 weeks ago
Install Ollama:
brew install ollama
Download a model:
ollama pull gpt-oss:20b
Run it:
ollama run llama3
β¦and you can start chatting!
π§ͺ My Experiments
βοΈ Use Case 1: Local LM Arena
Inspired by lmarena, I built a local version:
- User query β Sent to multiple models
- A βjudgeβ model scores responses
- Models get ranked
Following is a screenshot of the application:
The 2 models compared here are qwen and llama and gpt-oss is grading the response.

π‘ Example: Qwen scored 9/10, Llama scored 7/10, as judged by GPT-OSS.
ποΈ Use Case 2: Tuning Model Parameters
I tested how model parameters affect their responses:
| Parameter | Role | Best Use |
|---|---|---|
| Temperature | Controls randomness | 0.1β0.3 β factual, 0.7+ β creative |
| Top-P | Restrict to top probability mass | Lower β focused, Higher β diverse |
| Top-K | Consider top K tokens | Low (10β40) β predictable, High (100+) β diverse |
| Repeat Penalty | Discourage repetition | 1.05β1.1 β natural |
| Stop Sequences | Cut off response | Prevent drift/hallucination |
| Seed | Fix randomness | Debugging / reproducibility |
π Lowering temperature/top-p/top-k + good prompts = fewer hallucinations.
I created an application where we can specify these model input parameters and check how the responses vary. I used another model to evaluate if the responses provided are inline with the model parameters.
I was able to experiment and get the parameter combinations for providing consistent response or for reducing hallucinations.
Following is a screenshot of the application:

Following is the response evaluation output:

π οΈ Use Case 3: Modifying Base Models
Tried LoRA adapters β freeze base model + insert tiny trainable matrices.
β οΈ Didnβt fully succeed due to library issues, but worth exploring for cheap fine-tuning.
π Glossary (Quick Reference)
- Parameters: Learned weights/biases
- Tokens: Atomic input/output units
- Context length: Max tokens a model can process at once
- Embedding: Numeric vector for tokens/context
- Transformer: Model architecture with self-attention
- Pre-training: Large-scale language learning
- Fine-tuning: Specialization for tasks
- Quantization: Lower precision β smaller, faster models
π Closing Thoughts
Local LLMs are moving from curiosity to practical tools. With tools like Ollama and LM Studio, you can:
- Experiment with models directly on your laptop π»
- Balance privacy, latency, and cost π
- Customize outputs for your own use cases π οΈ
And with ongoing advances in quantization and small yet powerful models, local inference is only going to get better.