惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Register - Security
The Register - Security
T
Troy Hunt's Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
G
GRAHAM CLULEY
S
Schneier on Security
S
Secure Thoughts
Know Your Adversary
Know Your Adversary
Forbes - Security
Forbes - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Hacker News
The Hacker News
Y
Y Combinator Blog
L
LINUX DO - 最新话题
D
Docker
S
Security @ Cisco Blogs
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
博客园_首页
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V2EX - 技术
V2EX - 技术
NISL@THU
NISL@THU
MongoDB | Blog
MongoDB | Blog
阮一峰的网络日志
阮一峰的网络日志
P
Privacy & Cybersecurity Law Blog
C
Cisco Blogs
AWS News Blog
AWS News Blog
博客园 - 司徒正美
Martin Fowler
Martin Fowler
W
WeLiveSecurity
月光博客
月光博客
博客园 - 聂微东
N
News and Events Feed by Topic
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
T
Tenable Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
Vercel News
Vercel News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
E2B vs E4B vs 31B Dense: The Practical Guide to Choosing the Right Gemma 4 Model
pulkitgovran · 2026-05-23 · via DEV Community

This is a submission for the Gemma 4 Challenge: Write About Gemma 4


I want to tell you about the moment I stopped treating local AI as a compromise.

I was building a UX analysis tool. The idea was simple: give it a screenshot, get back a structured critique grounded in Nielsen's heuristics, cognitive load theory, WCAG — the real frameworks, not vibes. I'd used cloud models before. They work. But they also mean your users' screenshots leave their machine, hit an API, and cost money per call.

So I pulled Gemma 4 E4B locally via Ollama, pointed it at Stripe.com, and waited.

Fifty-six seconds later it handed me a structured JSON object with an overall UX score, three specific friction points each mapped to a Nielsen heuristic, accessibility flags, layout analysis, and prioritized recommendations with effort and impact ratings.

On CPU. No GPU. No API key. No data leaving the machine.

That's when the compromise framing broke for me. This isn't a fallback. It's a capability shift.


What Gemma 4 Actually Is

Gemma 4 is Google's latest open-weights model family, and the headline feature is multimodality — it can see images, not just read text. But the more interesting story is the range of what Google shipped:

Variant Parameters Context Window Best For
E2B ~2B 8K Edge, mobile, fast inference
E4B ~4B 8K Local development, CPU-viable
31B Dense ~31B 128K Complex reasoning, long documents

Three very different tools with the same name. Picking wrong costs you either quality or speed. Let me tell you what I've actually learned about each.


E2B: The One That Fits Anywhere

The 2-billion-parameter model is built for constraints. Think browser extensions, mobile apps, Raspberry Pi, anything where you cannot afford to wait or cannot carry a heavy runtime.

It handles basic instruction-following and short-form generation well. What it struggles with is structured output — complex JSON schemas, multi-step reasoning chains, tasks that require holding a lot of context simultaneously. If your task is "summarize this paragraph" or "classify this text into one of five categories," E2B is excellent and blazingly fast. If your task requires the model to reason across multiple frameworks while producing a nested JSON object, you'll feel the ceiling.

Use E2B when: speed > depth, you're running on constrained hardware, or the task is classifying/summarizing rather than reasoning.


E4B: The Sweet Spot for Developers

This is the one I use. The 4-billion-parameter model is the first point in the family where you stop noticing the limitations on most practical tasks.

What changed for me: E4B can follow a complex, multi-section JSON schema reliably. I give it a system prompt that defines eight nested fields — cognitiveLoad, trustScore, frictionPoints, recommendations, accessibilityFlags, layoutAnalysis — and it fills them correctly, with real observations, not hallucinated filler.

It also handles format: "json" mode in Ollama properly. This flag constrains the output to valid JSON, and E4B respects it while still producing coherent, specific content. E2B can struggle here — the output is valid JSON but the reasoning quality inside the strings drops noticeably.

On a modern CPU (M-series Mac or reasonably recent x86), E4B runs in under two minutes for most tasks. That's usable. It's not instant, but it's not "go make a coffee" either. On a GPU it's much faster.

Use E4B when: you need structured output, multimodal input, or reasoning quality that holds up in a real product — and you want it to run locally without a GPU.


31B Dense: When You Need to Think Hard

The 31B model is a different kind of tool. The 128K context window alone opens up use cases the smaller models simply cannot touch: full codebase analysis, long-document reasoning, multi-turn conversations that span thousands of tokens without losing thread.

The reasoning depth is also qualitatively different. Tasks that require synthesizing across many pieces of information — legal document review, detailed technical explanations, nuanced comparative analysis — land differently at 31B than at 4B. The model doesn't just answer; it considers.

The tradeoff is infrastructure. You need a GPU (or significant RAM for CPU inference), and the latency is real. This isn't a laptop model. But if you're building something that needs serious reasoning and you can provision the compute, 31B Dense is competitive with much larger proprietary models on a lot of benchmarks.

Use 31B Dense when: you have the compute, your task requires deep reasoning or long context, and quality is the primary constraint.


The Feature That Changed How I Build: Multimodal + JSON Mode

Here's the combination that makes Gemma 4 genuinely special for application developers.

Most LLM applications are text in, text out. You send a prompt, you parse the response, you deal with whatever format the model decided to use that day. Gemma 4 changes two things at once:

1. You can send images. Not OCR'd text from images. Not bounding boxes. The actual image. The model reasons about what it sees — colors, layout, spatial relationships, visual hierarchy.

2. You can enforce JSON output. With format: "json" in the Ollama request, the model outputs valid JSON. Combined with a well-defined system prompt that describes the exact schema you want, you get structured, machine-readable output you can render directly in a UI.

Here's what that looks like in practice:

const response = await fetch("http://localhost:11434/api/generate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "gemma4:e4b",
    prompt: systemPrompt + "\n\n" + userPrompt,
    images: [base64Image],  // raw base64, no data URI prefix
    format: "json",         // constrain output to valid JSON
    stream: true,
    options: {
      temperature: 0.3,     // lower = more deterministic structure
      num_ctx: 8192,
    },
  }),
});

Enter fullscreen mode Exit fullscreen mode

The model receives the image, reasons about it, and returns a structured JSON object. No parsing heuristics. No regex. No "hope the model uses the format I asked for." Validate it with Zod or any schema library and you're done.

One practical note: sometimes the first pass at temperature: 0.3 produces a malformed response, especially on complex schemas. A simple retry at temperature: 0.1 with streaming disabled almost always fixes it:

// Retry pattern for malformed JSON
const retryResponse = await fetch("http://localhost:11434/api/generate", {
  method: "POST",
  body: JSON.stringify({
    model: "gemma4:e4b",
    prompt: systemPrompt + "\n\n" + userPrompt,
    images: [base64Image],
    format: "json",
    stream: false,          // non-streaming for retry
    options: { temperature: 0.1, num_ctx: 8192 },
  }),
});

Enter fullscreen mode Exit fullscreen mode

This two-pass pattern makes structured multimodal output production-reliable.


Getting Started in Five Minutes

If you want to run Gemma 4 locally right now:

# Install Ollama (macOS/Linux)
curl -fsSL https://ollama.com/install.sh | sh

# Pull the E4B model (~3GB download)
ollama pull gemma4:e4b

# Test it immediately
ollama run gemma4:e4b "Explain the difference between cognitive load and visual noise in UX design"

Enter fullscreen mode Exit fullscreen mode

For multimodal input via API:

# Send an image (base64 encoded)
curl http://localhost:11434/api/generate -d '{
  "model": "gemma4:e4b",
  "prompt": "Describe the visual hierarchy in this UI screenshot",
  "images": ["'$(base64 -i your-screenshot.png)'"],
  "format": "json",
  "stream": false
}'

Enter fullscreen mode Exit fullscreen mode

That's it. No API key, no rate limits, no billing dashboard.


What This Actually Means

I think we're underreacting to what's happening here.

A 4-billion-parameter multimodal model that runs on a consumer laptop, follows complex structured output schemas, reasons about images, and produces output good enough to use in a real product — that's not a prototype capability. That's a production capability.

For developers, this changes the build calculus for a whole category of applications. Anything that involves user data you'd rather not send to a cloud API. Any tool that needs to work offline. Any product targeting users who are rightfully skeptical about where their data goes. Any hobby project where you don't want to watch a usage bill grow.

For the broader ecosystem, a capable open-weights multimodal model means researchers, educators, and developers in places with expensive or unreliable internet access can run serious AI locally. The capability is no longer gated behind an API key and a credit card.

The question I keep coming back to: if a 4B model running on CPU can do this now, what does the roadmap look like in two years? We're probably not near the ceiling.

I'm not sure what that means yet. But I'm fairly sure the "local AI as compromise" framing is already wrong, and most people haven't noticed.


Running Gemma 4 E4B locally via Ollama. Models are open-weights and available at ollama.com/library/gemma4.