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

推荐订阅源

AI
AI
G
Google Developers Blog
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
量子位
月光博客
月光博客
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Latest news
Latest news
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
TaoSecurity Blog
TaoSecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Cisco Blogs
Project Zero
Project Zero
Security Latest
Security Latest
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Scott Helme
Scott Helme
S
Securelist
有赞技术团队
有赞技术团队
T
Threat Research - Cisco Blogs
N
News | PayPal Newsroom
博客园 - 聂微东
小众软件
小众软件
S
SegmentFault 最新的问题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Privacy & Cybersecurity Law Blog
博客园 - Franky
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Spread Privacy
Spread Privacy
A
Arctic Wolf
S
Security @ Cisco Blogs
The Hacker News
The Hacker News
腾讯CDC
博客园 - 【当耐特】
T
Troy Hunt's Blog
NISL@THU
NISL@THU
爱范儿
爱范儿

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? E4B? 26B A4B? The Gemma 4 Model Names Finally Explained
Shivam Singh · 2026-05-21 · via DEV Community

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


Gemma 4 Explained: Which Model Should You Use and Why It Changes Everything for Local AI

I built an offline AI crop diagnostic tool for Indian farmers using Gemma 4. During that process I made every possible mistake - downloaded the wrong model variant, crashed my system, misunderstood what "E4B" meant, and spent hours confused about why multimodal wasn't working.

This article is what I wish I had read before starting.

By the end you'll know exactly which Gemma 4 model to use for your use case, what makes the architecture genuinely different from anything before it, and why this family of models is a bigger deal than most developers realize.


First: Why Gemma 4 Is Different

Most open-source models are powerful but come with a catch - they either need the cloud (OpenAI, Anthropic), require massive hardware (LLaMA 70B), or sacrifice too much quality for local use (older 2B/7B models).

Gemma 4 breaks that tradeoff.

The 31B model currently ranks #3 among all open models globally on the Arena AI leaderboard. The 26B MoE ranks #6. Both run on consumer hardware. Both are Apache 2.0 licensed - meaning you can use them commercially, modify them, and deploy them anywhere, for free.

But more importantly: Gemma 4 processes text, images, video, and audio natively. Not bolted-on, not a separate pipeline - natively, in a single model call. That changes what's possible to build locally.


Decoding the Model Names: E2B, E4B, 26B A4B, 31B

This is the part that confuses everyone. Let's decode it once and for all.

The "E" Models: Edge

E2B = Effective 2 Billion parameters

E4B = Effective 4 Billion parameters

The word "effective" is doing real work here. These aren't traditional dense models - they use architectural tricks (Per-Layer Embeddings) to punch above their weight class. The "E" signals they're built for edge deployment: phones, Raspberry Pi, laptops, embedded hardware.

Both E2B and E4B support:

  • Text + Image + Audio input natively
  • Up to 128K token context window
  • Fully offline via Ollama
  • No GPU required (CPU inference possible)

The Workstation Models: 26B and 31B

26B A4B = 26 Billion total parameters, 4 Billion Active per inference

31B = 31 Billion Dense parameters

The 26B A4B uses a Mixture of Experts (MoE) architecture — it has 26B parameters but only activates 4B of them for any given token. This means it runs at roughly the speed of a 4B model while producing quality closer to a full 26B model. That "A" stands for Active.

Both workstation models support:

  • Text + Image + Video (up to 60 seconds at 1fps) input
  • Up to 256K token context window
  • Hybrid attention (local sliding window + full global)

The Decision Table

Your Hardware Best Model Reason
Phone / Raspberry Pi E2B Lowest memory, fast responses
Any modern laptop (8GB RAM) E4B Sweet spot — good quality, runs anywhere
16GB RAM desktop / workstation 26B A4B Near-26B quality at 4B inference speed
80GB VRAM GPU (H100) 31B Maximum quality, #3 open model globally

When I built KhetAI I chose E4B — it needed to run on a mid-range Windows laptop with a consumer GPU, handle crop photos, and respond in 8 Indian languages. E2B was too limited, 26B/31B too heavy for the target hardware.


The Architecture That Makes It Work

Hybrid Attention: Fast AND Deep

Traditional transformers use full attention - every token attends to every other token. This is expensive. Gemma 4 uses a hybrid attention mechanism that interleaves:

  • Local sliding window attention for nearby tokens (fast, memory-efficient)
  • Full global attention for the final layer (captures long-range dependencies)

This gives you the processing speed of a lightweight model without losing the deep contextual understanding you need for complex tasks. The final layer is always global — ensuring nothing important gets missed.

Proportional RoPE (p-RoPE)

For long contexts (up to 256K tokens), Gemma 4 uses Proportional RoPE — a smarter positional encoding that scales proportionally with sequence length. Combined with unified Keys and Values in global attention layers, this dramatically reduces memory usage at long contexts compared to standard transformers.

Variable-Resolution Vision

When you send an image to Gemma 4, it doesn't resize everything to a fixed resolution. It uses a dynamic number of soft tokens fitted exactly to the image's content and resolution. A high-detail photo gets more tokens than a simple diagram. This matters enormously for real-world tasks like document analysis, medical imaging, or - in my case - crop disease detection where fine texture details are diagnostic signals.

Per-Layer Embeddings (PLE) in Edge Models

The E2B and E4B models use Per-Layer Embeddings instead of shared embeddings across all layers. This lets them carry more representational richness per parameter - which is why they're called "Effective" rather than just "2B" and "4B". They genuinely outperform models of equivalent raw parameter count.


The Thinking Mode: Built-in Reasoning

Every Gemma 4 model has a configurable thinking mode - the model can reason step-by-step before producing its final answer.

In Ollama, you enable it like this:

response = ollama.chat(
    model="gemma4:e4b",
    messages=[{"role": "user", "content": "your prompt"}],
    options={"thinking": True}  # enables step-by-step reasoning
)

Enter fullscreen mode Exit fullscreen mode

This is particularly powerful for:

  • Diagnosis tasks - reasoning through symptoms before concluding
  • Code debugging - thinking through the logic before suggesting a fix
  • Multi-step math - working through the problem before giving an answer
  • Agentic workflows - planning before acting

The thinking tokens are separate from the response — you get clean output plus the reasoning chain if you want to inspect it.


Running Gemma 4 Locally: Complete Setup

1. Install Ollama

Download from ollama.com - available for Mac, Windows, Linux.

2. Pull Your Model

# Edge models (recommended for most developers)
ollama pull gemma4:e2b   # ~7GB - phones, Pi, very low-end hardware
ollama pull gemma4:e4b   # ~10GB - any modern laptop ✅ recommended start

# Workstation models (need a good GPU)
ollama pull gemma4:26b   # ~16GB - MoE, great quality/speed balance
ollama pull gemma4:31b   # ~20GB - maximum quality

Enter fullscreen mode Exit fullscreen mode

3. Basic Text Usage

import ollama

response = ollama.chat(
    model="gemma4:e4b",
    messages=[
        {"role": "user", "content": "Explain the difference between MoE and Dense transformers"}
    ],
    options={"temperature": 0.7}
)

print(response["message"]["content"])

Enter fullscreen mode Exit fullscreen mode

4. Multimodal Usage (Image + Text)

import ollama
import base64

# Load and encode the image
with open("crop_photo.jpg", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode("utf-8")

response = ollama.chat(
    model="gemma4:e4b",
    messages=[
        {
            "role": "user",
            "content": "What disease does this crop have? Suggest treatment.",
            "images": [image_b64],  # pass base64 encoded image
        }
    ],
    options={"temperature": 0.2}  # low temp for factual tasks
)

print(response["message"]["content"])

Enter fullscreen mode Exit fullscreen mode

That's it. No separate vision model. No preprocessing pipeline. One call.

5. Structured JSON Output

For applications, you want reliable structured output. Use a system prompt with low temperature:

import ollama
import json

SYSTEM = """Always respond ONLY with valid JSON. No preamble, no markdown.
Format: {"answer": "...", "confidence": "High/Medium/Low", "reasoning": "..."}"""

response = ollama.chat(
    model="gemma4:e4b",
    messages=[{"role": "user", "content": "Is this tomato leaf diseased?", "images": [image_b64]}],
    system=SYSTEM,
    options={"temperature": 0.1}
)

result = json.loads(response["message"]["content"])

Enter fullscreen mode Exit fullscreen mode

6. Using the 128K Context Window

The E4B's 128K context window means you can pass entire codebases, long documents, or full conversation histories in a single call:

# Pass an entire document for analysis
with open("research_paper.txt", "r") as f:
    document = f.read()

response = ollama.chat(
    model="gemma4:e4b",
    messages=[
        {
            "role": "user",
            "content": f"Summarize the key findings and methodology:\n\n{document}"
        }
    ]
)

Enter fullscreen mode Exit fullscreen mode


Choosing Temperature: A Practical Guide

Temperature is the most impactful parameter after model selection:

Task Temperature Why
Structured JSON output 0.1 - 0.2 Consistency over creativity
Factual Q&A / diagnosis 0.2 - 0.4 Reliable, grounded answers
General conversation 0.7 Natural, balanced responses
Creative writing 0.9 - 1.0 Varied, imaginative output
Brainstorming 1.0+ Maximum diversity of ideas

What This Means for Developers

Here's the shift Gemma 4 represents, stated plainly:

Before Gemma 4, building a multimodal, multilingual, locally-running AI application required:

  • A separate vision model (CLIP, LLaVA, etc.)
  • A separate language model
  • A translation/multilingual layer
  • A cloud API for inference at any serious quality level
  • Significant engineering to glue it all together

With Gemma 4 E4B, you get all of that in a single 10GB model that runs on a laptop, costs nothing to operate, and sends zero data to any server.

That's not an incremental improvement. That's a different category.

For developers building for markets with unreliable internet — rural areas, developing countries, privacy-sensitive domains (medical, legal, financial), air-gapped enterprise environments - Gemma 4 is the first model that makes a fully capable local AI genuinely feasible.


What I Learned Building With It

I built KhetAI - an offline crop diagnostic tool for Indian farmers — using gemma4:e4b. A farmer uploads a crop photo, asks a question in Hindi or Kannada, and gets a structured diagnosis with treatment steps and local remedies. Zero internet. Zero cloud. Zero cost to operate.

The things that surprised me:

Multilingual works without any configuration. I just tell the model the language in the system prompt. It responds in that language natively — Hindi, Kannada, Tamil, Telugu. No translation layer, no separate multilingual model.

Image quality really matters. The dynamic soft-token system means a blurry photo gives fewer tokens to work with. For diagnostic tasks, tell your users to take clear, well-lit photos.

Low temperature is your friend for structured output. Setting temperature to 0.2 and adding "respond ONLY with JSON" to the system prompt gives remarkably consistent structured responses.

First inference is slow, subsequent ones are fast. The model loads into GPU memory on the first call. After that, it stays loaded and responses come quickly. Tell your users to expect a 30-90 second wait on the first analysis.


The Bigger Picture

There are 400 million Gemma model downloads. Over 100,000 community fine-tuned variants. Google calls this the "Gemmaverse."

The Apache 2.0 license means none of that growth has a ceiling. No usage fees, no terms that restrict commercial use, no platform lock-in. A developer in Bengaluru building for Indian farmers and a startup in São Paulo building for Brazilian doctors and a researcher at a university in Nairobi are all working with the same foundation model, improving it, specializing it, and sharing their work.

That's what open-weight AI at this capability level actually means. Not just "a free model" — a foundation that any developer anywhere can build on without asking permission.

Gemma 4 is the clearest example yet of that becoming real.


Quick Reference

# Install Ollama: https://ollama.com

# Pull recommended model for most developers
ollama pull gemma4:e4b

# Test immediately
ollama run gemma4:e4b "What is the Mixture of Experts architecture?"

# Python
pip install ollama

Enter fullscreen mode Exit fullscreen mode

import ollama

# Text
r = ollama.chat(model="gemma4:e4b", messages=[{"role":"user","content":"Hello"}])

# Image
r = ollama.chat(model="gemma4:e4b", messages=[{"role":"user","content":"Describe this","images":["base64string"]}])

# Structured output
r = ollama.chat(model="gemma4:e4b", messages=[...], system="Return only JSON", options={"temperature":0.1})

Enter fullscreen mode Exit fullscreen mode


Built KhetAI with Gemma 4 E4B for the Gemma 4 Good Hackathon 2026. GitHub: https://github.com/Tech-Psycho95/KhetAI

gemma, ai, python, ollama