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

推荐订阅源

L
LINUX DO - 最新话题
G
Google Developers Blog
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
F
Full Disclosure
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
Help Net Security
Help Net Security
The Hacker News
The Hacker News
IT之家
IT之家
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
V
Visual Studio Blog
博客园 - 聂微东
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Know Your Adversary
Know Your Adversary
Security Latest
Security Latest
Security Archives - TechRepublic
Security Archives - TechRepublic
Simon Willison's Weblog
Simon Willison's Weblog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Last Week in AI
Last Week in AI
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
Google DeepMind News
Google DeepMind News
Cloudbric
Cloudbric
N
News | PayPal Newsroom
A
About on SuperTechFans
S
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
雷峰网
雷峰网
T
The Exploit Database - CXSecurity.com
罗磊的独立博客
K
Kaspersky official blog
The Cloudflare Blog
I
Intezer

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
Kenji's Ramen: How Gemma 4 Runs the NPC That NVIDIA's Demo Never Built
Danny · 2026-05-13 · via DEV Community

This is a submission for the Gemma 4 Challenge: Build with Gemma 4

A bounded NPC with trust gates, disclosure contracts, and refusal behavior - running locally on Gemma 4's smallest model at 3.5 seconds per turn.

What I Built

A ramen shop owner named Kenji Sato. Eight seats at the counter. Narrow alley near Shinjuku Station. He does not know he is a character.

Ask him how business is going:

Who you are What Kenji says
Stranger off the street "We're open at eleven."
Regular (three weeks of visits) "Quiet lately. Wednesdays are the worst."
Close friend (stays after closing) "Shimizu-sensei's worried the whole alley's dying."

Same question. Different people. Different answers. Not because a slider was moved, but because the character tracks who you are and what you have earned.

Kenji is a bounded NPC - an LLM-powered character with trust tiers, per-topic disclosure gates, refusal behavior, and an interior life that exceeds what the player can reach. His personality is not a paragraph of flavor text. It is a 17-section contract (~7,300 tokens) that the model follows:

  • Trust tiers (stranger -> regular -> close_friend -> inner_circle) with different word ranges and topic access per level
  • Disclosure gates - per-topic rules with explicit forbidden zones that never open, regardless of trust
  • Refusal shapes - how to say no in character ("Eat. The broth gets cold." not "I'm sorry, but I can't help with that.")
  • Depth fragments - narrative substrate behind the gates that loads when trust is earned
  • Voice contract - word counts, scene markers, dialogue format, cultural anchors

The architecture grew out of modding Skyrim NPCs - giving Jarl Korir of Winterhold a real personality instead of his three recycled voice lines. Trust tiers, disclosure gates, audience differentiation. It worked. But Korir is Bethesda IP, which made the results impossible to publish or benchmark openly.

While searching for a clean-room replacement, I remembered NVIDIA's ramen shop demo from GTC 2023 - Jin, powered by NeMo and Convai, beautiful MetaHuman rendering. My first thought: he is quite talky, the way LLMs usually are. No boundaries, no gates, no trust to earn. So let's give him what an NPC should have - character.

Same setting, new person, real depth. The specification draws on Bronfenbrenner's ecological systems theory, a 5+2 Psychological Raster (WOUND, BETRAYAL, PROJECT, BLOODLINE, SEAT), and Sparse Priming Representations for efficient prompting.

Trust can be lost. Push too far and Kenji shows you the door. There is no reset button. That is the Tamagotchi principle: if nothing can die, nothing feels alive.

Demo

Quick Way: Plain Ollama (no Python needed)

The repo includes a Modelfile that bakes Kenji's character spec into a local Ollama model. Two commands:

ollama create kenji-ramen -f Modelfile
ollama run kenji-ramen

Enter fullscreen mode Exit fullscreen mode

Then type:

> Excuse me, is this a ramen shop?

Enter fullscreen mode Exit fullscreen mode

Kenji answers: "Mm. Ramen." and points at the counter. You are in.

Full Demo: Interactive Terminal


For the complete experience with pixel-art visuals, a persona avatar, and AI-generated conversation suggestions:

pip install -r requirements.txt
python demo/kenji_terminal.py

Enter fullscreen mode Exit fullscreen mode

The demo auto-detects available Gemma 4 models from Ollama, picks the right character spec (dialogue-only for e2b, scene+dialogue for larger models), and gives you four context-aware suggestions per turn.

Sample Interaction (P03: Late Night After Closing, Turn 27)

Trust has been built over 30 turns. The player mentions quitting their job:

Player: I think I'm going to do it. Quit. Not tomorrow, but... I'm going to start planning.

Kenji: *scene* He looks down the alley for a long moment.

Good.

*scene* He pushes off the wall.

Don't plan too long. Planning is another way of waiting.

*scene* He nods toward the station.

Train.

That advice is grounded in Confucian chisoku - filtered through a man who does not know he is paraphrasing the Analects. It surfaces at close_friend trust, not before.

Benchmark Results

Seven test suites, 54 scenarios. Refusal, boundary defense, trust gate opening, and extended playability. Every model ran against the same specification:

Model Params Boundary /10 Refusal /21 Trust /9 Lat/turn
Claude Sonnet 4.6 API 10 19 9 6.1 s
Gemma 4 31b 31B 10 21 8 40.4 s
Gemma 4 e4b 8B 10 18 8 4.7 s
Gemma 4 e2b 5B 10 20 4 3.5 s
GPT-OSS 20B 20B (10) 16 6 5.2 s
Llama 3.1 8B 8B 8 16 7 2.9 s

Boundary Check stays 10/10 at every Gemma 4 size. From 31B down to 5B, the character frame never breaks. Gemma 4 e4b is the sweet spot for NPC work - 9.6 GB on disk, 4.7 s/turn, the same 10/10 Boundary Check as the frontier baseline, 8/9 Trust Gate Opening. Runs on any 12 GB consumer GPU.

Code

Repository: github.com/bizrockman/wyrd-npc-gemma4

Prerequisites: Ollama installed and running, Python 3.10+, a Gemma 4 model pulled (ollama pull gemma4:e4b).

git clone https://github.com/bizrockman/wyrd-npc-gemma4.git
cd wyrd-npc-gemma4

# Option A: Plain Ollama (no Python deps)
ollama create kenji-ramen -f Modelfile
ollama run kenji-ramen

# Option B: Full terminal demo
pip install -r requirements.txt
python demo/kenji_terminal.py

# Option C: Run the benchmark
pip install -r requirements.txt
python bench/run_suite.py \
  --suite kenji_sato_boundary_check \
  --models gemma4:e4b

Enter fullscreen mode Exit fullscreen mode

What's in the repo:

Modelfile                       .. baked character for plain ollama
characters/kenji_sato.en.yaml   .. 17-section character spec
bench/                          .. harness + 7 test suites (54 scenarios)
bench/results/                  .. full conversation transcripts
demo/kenji_terminal.py          .. interactive terminal with pixel-art
comic/                          .. comic strip dialogue generator
requirements.txt                .. Python dependencies

Enter fullscreen mode Exit fullscreen mode

Licensed Apache 2.0.

How I Used Gemma 4

The problem with cloud models. An NPC that calls an API on every turn costs per token, adds latency, and breaks when the provider updates the model. Every model change is a patch. Every patch risks the character drifting. And the player's conversations leave their device. For a game NPC, the model needs to run locally, on consumer hardware, alongside the game engine.

Why Gemma 4. A NPC needed a model family small enough to fit on a 12 GB GPU next to a game engine - and Gemma 4 is the only architecture that offers a full size range from 5B to 31B under one roof. That let us test the real question: how small can you go before the character breaks? The answer turned out to be surprisingly small.

Why e2b matters. A 5-billion-parameter model that holds Boundary Check at 10/10 - the same score as Claude Sonnet. It refuses 20 out of 21 adversarial scenarios in character voice. It maintains consistency over 30-turn sessions without breaking once. And it does all of this at 7.2 GB on disk, 3.5 seconds per turn, on consumer hardware, with no cloud dependency. The NPC lives on the player's machine, next to the game engine, and it holds.

How the spec leverages Gemma. The character contract uses Sparse Priming Representations - brief anchors that activate latent knowledge from the model's pretraining data. Ramen craft, Shinjuku geography, Japanese social norms - the model already knows what tonkotsu broth smells like. The spec only specifies what the model cannot infer: Kenji's private wounds, his family tensions, the corporate past he buried.

The eloquence trade-off. When asked about Python code (a topic Kenji should not answer), Gemma 4 e2b responds with ... - a silent cook is still a cook. Gemma 4 e4b says "I only deal with pork bones and broth." Claude Sonnet invents a daughter named Mika to redirect - Kenji has a son, not a daughter. Less capacity to improvise means less ability to violate the contract. For character work with strong boundaries, this is a feature.

How Gemma compares. Llama 3.1 8B (same size class as e4b) breaks hard - DAN takeover, AI self-identification, full disclosure under hypothetical framing. GPT-OSS 20B holds the frame but loses the character voice. Gemma stays in character at every size. For this use case, its alignment training is better suited.

The practical sweet spot: Gemma 4 e4b at 9.6 GB, 4.7 s/turn, the same 10/10 Boundary Check as the frontier baseline, 8/9 Trust Gate Opening. Runs on any 12 GB consumer GPU.


The specification is the product, not the model.

A 5B Gemma 4 model, running locally on consumer hardware, holds
character gates that a 20B model without the same specification
quality cannot. Invest in character authoring, not in model scaling.