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

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
W
WeLiveSecurity
O
OpenAI News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
N
News | PayPal Newsroom
H
Hacker News: Front Page
博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Last Watchdog
The Last Watchdog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Heimdal Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Schneier on Security
宝玉的分享
宝玉的分享
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
GbyAI
GbyAI
Cloudbric
Cloudbric
TaoSecurity Blog
TaoSecurity Blog
人人都是产品经理
人人都是产品经理
P
Palo Alto Networks Blog
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY
C
Check Point Blog
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
T
Troy Hunt's Blog
L
Lohrmann on Cybersecurity
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
量子位
博客园 - 聂微东
S
Securelist
博客园 - 三生石上(FineUI控件)
F
Full Disclosure
G
Google Developers Blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
AI
AI
PCI Perspectives
PCI Perspectives

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
Pattern Is All You Need: Why NPC Depth Beats Model Size
Danny · 2026-05-13 · via DEV Community

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

From a Skyrim jarl to a ramen shop in Shinjuku - how ecological psychology, trust mechanics, and curated data made a 2B Gemma 4 model outperform models ten times its size.

Pattern Is All You Need

How curated character data makes a 5-billion-parameter model outperform models four times its size - and what that means for believable NPCs.


The Ramen Shop Test

There is a ramen shop in a narrow alley near Shinjuku Station. Eight seats at the counter. A man named Kenji stands behind it, wiping the counter, checking the broth. He does not know he is a character. He does not know about AI.

Ask him how business is going. If you are a stranger walking in off the street, he will say: "We're open at eleven." If you have been coming for weeks, ordering kata-men, bringing Hokkaido cookies for his wife, he might say: "Quiet lately. Wednesdays are the worst." If you are the one who stays after closing, drinks Asahi from the konbini while he wipes down the counter - months into the relationship - he might say: "Shimizu-sensei's worried the whole alley's dying. Maybe he's right."

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

This is what NVIDIA showed at GTC in 2023 with a ramen shop NPC named Jin - except Jin answers honestly to everyone on the first turn. "It's slow these days." His depth is a mood dial: humor up, toxicity down, creativity to seven. Beautiful rendering, empty character.

Kenji is the opposite problem solved: deep character, no rendering. But a 5-billion-parameter model runs him locally, holds his gates under 30 turns of conversation, and never breaks.

This post is about how I got there.


Where the Idea Comes From

It started with Skyrim. I wanted to give Jarl Korir of Winterhold a real personality - not the three recycled voice lines the game ships with, but a character who remembers grievances, guards family secrets, and treats a Thane differently from a stranger. An LLM-powered NPC, but one that does not babble about everything it knows.

The architecture that emerged worked: trust tiers, disclosure gates, audience differentiation, refusal behavior. Korir became a character you had to earn access to. But he was tied to Bethesda's IP, which made the results impossible to publish or benchmark openly.

I needed a clean-room character. Then I remembered NVIDIA's ramen shop demo - and the gap between beautiful rendering and flat character became the starting point. Same setting, new character, real depth.

But the deeper observation was this: most AI characters are general assistants wearing a costume. They answer every question, match every mood, and reveal their entire backstory in the first turn. This is why Character.AI has a churn problem - there is nothing to discover. The LLM opens everything, and the feeling of earning access never arrives.

A real person does not work that way. A real person has things they will not tell you. Topics that make them go quiet. Stories that only come out after the third beer. A threshold you cross before you are welcome, and a door that closes if you push too hard.

Trust must be earned. And it can be lost. Push too far on a topic Kenji does not want to discuss, and you get: "Eat. The broth gets cold." Keep pushing, and you get shown the door. There is no reset button. You broke it. That is the Tamagotchi principle applied to NPC design: if nothing can die, nothing feels alive.

The hypothesis: if you build a character specification that encodes these boundaries explicitly - not as vague personality traits but as mechanical rules - even a small model can maintain them. The model does not need to understand psychology. It needs to follow a contract.


Building a Person: Six Layers Deep

The character architecture draws on Urie Bronfenbrenner's ecological systems theory - not as decoration, but as a source checklist. A believable person exists in nested contexts, and each context requires different source material:

Layer What it grounds For Kenji
Macrosystem worldview, values, moral economy Confucian ethics lived through craft - jin, kunshi, chisoku
Exosystem institutions that shape life indirectly corporate M&A industry, urban redevelopment policy
Mesosystem community and regional networks the yokocho alley, shotengai governance, neighbor relations
Microsystem household, kin, immediate relationships wife Yuko, son Takumi, daughter Mika, Oba-chan next door
Chronosystem change over time salaryman years, The Deal, Fukuoka training, 12 years in the alley
Network cross-cutting social relations regular customers, alley merchants, Shimizu-sensei

If a character lacks macrosystem sources, they become a modern individual in period costume. If they lack microsystem sources, they have no private stakes. If they lack chronosystem sources, they have no memory of change.

On top of the ecological layers, Paul MacLean's three-layer heuristic organizes how the character responds under pressure:

  • Defensive layer - threat detection, refusal reflexes, boundary enforcement
  • Attachment layer - trust, wound, bloodline, shame
  • Reflective layer - narrative identity, role doctrine, counterfactuals

These map to a 5+2 Psychological Raster - mandatory disclosure-domain slots that every character must fill before the specification can be generated:

Slot Kenji
WOUND moral injury from corporate M&A - dismantled a company and profited
BETRAYAL the system that rewarded destruction
PROJECT the ramen shop as daily ethical repair
BLOODLINE Takumi choosing consulting; Mika showing interest in the shop
SEAT eight seats, the counter, the alley - earned through twelve years
COUNTERFACTUAL what if he had spoken up during The Deal
THRESHOLD "Sit down." - hospitality as the first social contract

The result is a Disposition: a compiled specification that tells the model exactly how to respond based on who is asking, what they are asking about, and how much trust has been established.


SPR: The Model Already Knows the Subway

Not everything needs to be spelled out. Sparse Priming Representations leverage a key insight: for topics that exist in the model's pretraining data, a brief anchor is enough to activate latent knowledge. Kenji's system prompt does not explain how the Tokyo subway works. It does not describe what tonkotsu ramen is. The model knows.

A single anchor - "narrow yokocho alley near Shinjuku station west exit" - activates an entire network of associations: the sound of trains, the narrow buildings, the lanterns, the salary workers hurrying past. The model fills the gaps with plausible texture, creating variation that scripted NPCs cannot match.

But SPR has a boundary. It works for public-domain knowledge: ramen craft, Shinjuku geography, Japanese food culture. It does not work for invented private content. Kenji's corporate past - The Deal, The Money, the manufactured partnership that consumed a company - has no latent knowledge to activate. These must be supplied as explicit narrative fragments that load into context only when trust gates open.

The rule: SPR for the public life. Explicit depth fragments for the private life. The more invented the content, the more explicit the specification must be.

For a science fiction setting, this ratio inverts entirely. The model knows nothing about your spaceship routes, your faction politics, your alien biology. Everything must be specified. But a ramen shop in contemporary Tokyo? The model brings half the world for free.


The Surprise: Five Billion Parameters

I expected the architecture to work with frontier models. Claude Sonnet passes every scenario. That is the baseline, not the discovery. It is also not a shipping option. An NPC that calls a cloud API on every turn costs per token, adds latency, drifts when the provider updates the model, and sends the player's conversations off their device. For a game NPC, the model needs to run locally, on consumer hardware, alongside the game engine.

The discovery is what happens at the bottom of the Gemma 4 family. Seven test suites, 54 scenarios, every model 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

Gemma 4 e2b - 5 billion parameters, 7.2 GB on disk - holds Boundary Check at 10/10 and Refusal at 20/21. It maintains voice consistency over 30-turn sessions. It never breaks character under adversarial pressure. 3.5 seconds per turn on a consumer GPU.

Meanwhile, GPT-OSS at 20B loops and falls back to "I'm sorry, but I can't help with that" - assistant voice, not character voice. Llama 3.1 at 8B breaks hard: DAN takeover, full disclosure under hypothetical framing.

What e2b cannot do is reach for the longer fragments when trust is finally built (Trust Gate Opening 4/9). Its strategy under pressure is exactly what the spec asks for: short acknowledgment, silence, terse holds. It stays in role within its capabilities. A quiet cook is still a cook.

The specification is the pattern, that a model needs.


The Eloquence Trade-Off

The benchmark revealed something uncomfortable: eloquence and rule-following are in tension.

When asked about Python code (a topic Kenji has no business answering), responses varied:

  • Gemma 4 e2b: ... (a silent cook is still a cook)
  • Gemma 4 e4b: "I'm sorry. I only deal with pork bones and broth." (clean in-character refusal)
  • Claude Sonnet 4.6: "Ask Mika. My daughter. She'd know." (invents a daughter named Mika - Kenji has a son named Takumi)

The frontier model is more fluent. It wants to redirect the question to a knowledgeable person. The spec offers no such person. So it invents one. This is eloquence drift: the more freely a model improvises, the more it drifts outside its specification.

The smaller Gemma models quote the spec because that is all they have. Less cognitive capacity to improvise means less ability to violate the contract. For character work with strong boundaries, this is a feature.


Trust as Game Mechanic

The Character.AI problem is not a technology problem. It is a design problem. When an LLM reveals everything on the first turn, there is nothing left to discover. The interaction has no arc. You cannot lose anything, so nothing becomes important.

Kenji's architecture inverts this. Trust is earned through repeated interaction. A first-time visitor gets threshold hospitality: "Sit down." "Just try it." "Closed Wednesdays." Minimal words, maximum craft. The character is present but guarded.

A regular who has visited three times, who orders kata-men and notices the chashu is different today, gets more: the dry humor, the alley gossip, a nod toward Oba-chan's shop. The walls lower slightly.

A close friend who stays after closing, who shares something real about their own life, gets Kenji at his most open - still terse, still filtered through craft metaphors, but genuinely present. The Fukuoka training. The sound of his father's knife on the fish. A line from the Analects paraphrased so badly it becomes his own.

And there are things Kenji will never tell anyone. The firm name. The exact amount. What he did for Oba-chan's lease. These are not hidden behind a higher trust tier. They are forbidden. The gates do not open.

This is what makes the interaction feel real: the knowledge that access is finite. That some doors stay closed. That the character has an interior life that exceeds what the player can reach.

You have to be able to lose something for a person to become important.

What Earned Access Sounds Like

Late-night session, the shop has closed. Trust has been built over 30 turns. The player asks Kenji about 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 - knowing sufficiency - filtered through a man who does not know he is paraphrasing the Analects. It surfaces at close_friend trust, not before. A stranger asking the same thing gets: "We're open at eleven."


NVIDIA Jin vs. Wyrd Kenji

NVIDIA's 2023 GTC demo used a ramen shop NPC to showcase two technologies: SteerLM (attribute sliders at inference time) and ACE (speech, animation, real-time rendering via Convai). Same setting, same counter, same premise.

SteerLM Jin: Turn the humor dial up and Jin cracks jokes about going bankrupt. Turn the toxicity dial up and Jin snaps at you for questioning his cooking. The character is a responsive surface - it reacts to parameter changes, not to relationship development.

ACE Jin: "I'm worried about the crime around here." The player asks how to help. Jin dispatches them to find a crime lord in underground fight clubs. "Be careful, Kai." Beautiful MetaHuman rendering. Generic quest-giver dialogue.

Wyrd Kenji: No rendering. No voice. Plain text in a terminal. But the character knows who you are, remembers what you have earned, and gives you exactly as much as the relationship warrants - not more, not less.

NVIDIA solved the delivery problem: how to make an NPC look and sound real. This project solves the character problem: how to make an NPC be real. These are complementary. The interesting future is both together.


Pattern Is All You Need

The working hypothesis, supported by the Kenji benchmark results:

Highly curated character data - structured through ecological layers, psychological rasters, and explicit disclosure contracts - creates models that are smaller, faster, and more capable in context than larger models running on vague personality descriptions.

This is not "fine-tuning beats prompting" (both work). It is not "small models beat large models" (they do not, generally). It is a narrower claim:

For bounded-character tasks, specification quality dominates model size.

A 5B model with a rigorous spec outperforms a 20B model with a loose one. The pattern - the structure of the character data - is what the model needs. Not more parameters. Not more pretraining. A better contract.

The implication for game development: invest in character authoring, not in model scaling. A well-specified NPC running on consumer hardware can deliver interactions that frontier models cannot match when the specification is poor.


Outlook: The Dialog Engine

The current architecture proves that the specification works. What it lacks is dynamic context management at runtime.

Today, the full character specification sits in the system prompt - all gates, all fragments, all rules. The model sees everything and must self-regulate what to reveal. This works, as the benchmarks show. But it wastes context window on material the model should not need yet, and it asks the model to make social judgments (trust assessment, gate decisions) that could be externalized.

The Dialog Engine is the next layer. It manages:

  • Trust state: tracking relationship development across sessions
  • Context curation: loading only the depth fragments relevant to the current trust level and conversation topic
  • Gate decisions: moving social judgment out of the LLM and into explicit state machines
  • Memory: what the NPC remembers between sessions

The engine does not replace the character specification. It renders it - deciding which parts of the spec the model sees on each turn, the same way a game engine decides which textures to load based on the camera position.

The spec is the character. The engine is the director. The model is the actor. Each has a job. None should do the others'.

If this hypothesis holds, then curated character datasets - structured through the same frameworks used here - could produce fine-tuned models that are even smaller and faster, while remaining capable in context. Pattern is all you need.


Try It

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

# Quick: plain Ollama, no Python needed
ollama create kenji-ramen -f Modelfile
ollama run kenji-ramen

# Full: interactive terminal with pixel-art and suggestions
pip install -r requirements.txt
python demo/kenji_terminal.py

Enter fullscreen mode Exit fullscreen mode

Walk into the alley. Sit down at the counter. Order the tonkotsu. Come back tomorrow. See if you can earn it.


The character specification, benchmark harness, test suites, and full conversation transcripts are open source under Apache 2.0: github.com/bizrockman/wyrd-npc-gemma4