Table of Contents
GPT-4 can obviously generate great game dialogue. But GPT-4 costs money per second, latency runs hundreds of milliseconds to seconds, and routing all NPC dialogue to a cloud API raises privacy concerns — player behavior data leaves the device. Small language models (SLMs) exist precisely to address these problems. Let’s look at what models around 10B parameters can actually do in a gaming context.
TL;DR
10B-parameter models (Mistral 7B, Gemma 9B, Llama 3.2 11B) can run locally on consumer GPUs (RTX 4090) or Apple Silicon Macs at 20–50 tokens/second — fast enough for real-time NPC dialogue. They excel at clear, well-constrained tasks; they fall short on complex reasoning and long-range consistency. Game design needs to work within these constraints.
What We’re Talking About
“Small models” here means 7–13B active parameter language models, such as:
- Mistral 7B / Mistral Nemo 12B: High inference efficiency, suited for real-time inference
- Gemma 9B (Google): Strong instruction-following capability
- Llama 3.2 11B (Meta): Multilingual support, multimodal version available
- Phi-3.5 Mini 3.8B (Microsoft): Smaller still, sacrifices some quality for speed
With 4-bit quantization, these models need approximately 4–8GB of memory, runnable on consumer GPUs from RTX 4060 Ti up, or on M2/M3 Mac unified memory (16–32GB configurations).
What They Can Do in Games
Dynamic NPC Dialogue
This is the most mature application area right now. Traditional RPG NPC dialogue is pre-written as a tree structure — player picks options. SLMs allow genuinely free conversation:
Player: "I heard you know something about the missing children?"
NPC (SLM-generated): "Keep your voice down. The guards rotate at midnight — that's when I can talk.
Ask me now and I know nothing."
The key is NPC system prompt design: it needs to include character background (personality, secrets, speech patterns), current scene state (player trust level, time, location), and world constraints (what this NPC knows and doesn’t know).
Procedural Narrative Generation
Small models can dynamically generate short story fragments based on player behavior. In a roguelike, for example, generating a description each time the player enters a new area (the history of this abandoned dungeon, clues left by the last explorer).
A 2025 arXiv paper (“High-quality generation of dynamic game content via small language models: A proof of concept”) shows that SLMs can approach large model quality on short, clearly-contexted creative content, with more variety than purely rule-based generation.
Adaptive Game Content
Adjusting difficulty descriptions based on player behavior (same mission, different hint language for players of different skill levels), generating personalized mission briefings, or generating different branching narration based on player choices.
Interactive Fiction and Text Adventures
This is where SLMs shine most. Text adventure games with a clear worldbuilding setup, where the SLM drives the story forward based on player input. Godoka’s Painter Game is an experimental interactive painting narrative using a small model.
How It Works
Typical architecture for integrating SLMs in a game:
graph TB
subgraph "Game Engine"
GS["Game State\n(Player position, items, relationship values)"]
Event["Event Trigger\n(Player input / approaching NPC)"]
end
subgraph "SLM Inference"
SP["System Prompt Builder\n(Character + State + Constraints)"]
Model["Local SLM\n(llama.cpp / ollama)"]
Filter["Output Filter\n(Content safety + format validation)"]
end
Event --> SP
GS --> SP
SP --> Model
Model --> Filter
Filter --> GS
Filter --> UI["Game UI Display"]
Inference frameworks: llama.cpp is the most commonly used local inference engine, can be integrated directly into game engines via C++; Ollama provides an HTTP API suited for quick prototyping; Unity and Unreal both have community-developed llama.cpp integration packages.
The Real Gap Versus Large Models
| 10B SLM (local) | GPT-4o (API) | |
|---|---|---|
| Speed | 20–50 tok/s (RTX 4090) | 50–100 tok/s (but with network latency) |
| Latency | <100ms (direct local call) | 300ms–2s (including network round trip) |
| Cost | One-time hardware investment | ~$5–15 per 1M tokens |
| Privacy | Data never leaves the device | Sent to OpenAI servers |
| Long-range consistency | Weaker (smaller context window) | Strong |
| Complex reasoning | Noticeable gap | Strong |
| Short creative generation | Approaches large model quality | Strong |
The biggest practical gap is long-range consistency: if a conversation exceeds a few thousand tokens, SLMs tend to “forget” character setup or plot details established earlier. The solution is to explicitly maintain important state outside the model (game database), re-injecting it into context on each call, rather than relying on the model’s memory.
Wrap Up
10B models in 2025 are sufficient for real-time NPC dialogue, short procedural text generation, and interactive narrative. They’re not a replacement for GPT-4 — they’re an entry ticket to the category of “real-time, free, on-device language generation.” Game design needs to accommodate their limitations: short context, clear constraints, explicit state management. Games designed within these constraints may actually end up with uniquely interesting mechanics because of them.
References
- High-quality generation of dynamic game content via small language models: A proof of concept (arXiv)
- Narrative-to-Scene Generation: An LLM-Driven Pipeline for 2D Game Environments (arXiv)
- awesome-LLM-game-agent-papers (GitHub)
- Painter Game (Godoka)
- What Games Can We Build with a Small Model (10B active parameters)? (YouTube)
Answers come from this article only. Click any prompt below or open the chat at the bottom right.
🇺🇸 English
Here's the thing everyone assumes: if you want good game dialogue, you reach for GPT-4. And sure, GPT-4 writes great dialogue. But it costs money every single second it runs, the latency stretches from a few hundred milliseconds all the way up to whole seconds, and every time an NPC opens its mouth, you're shipping player behavior data off to a cloud server. That's a privacy problem. Small language models exist precisely to solve all three of those headaches. So let's talk about what a model in the ten-billion-parameter range can actually pull off inside a game.
Quick version up front: models like Mistral 7B, Gemma 9B, or Llama 3.2 11B can run locally — on a consumer graphics card like an RTX 4090, or on an Apple Silicon Mac — at somewhere between twenty and fifty tokens per second. That's fast enough for real-time NPC conversation. Where they shine is clear, tightly-constrained tasks. Where they stumble is complex reasoning and staying consistent over a long stretch. And the whole trick of designing a game around them is working *with* those limits instead of against them.
So what do we actually mean by "small model" here? We're talking seven to thirteen billion active parameters. Mistral 7B and its bigger sibling Nemo at twelve billion are prized for raw inference efficiency. Gemma 9B from Google is really strong at following instructions. Llama 3.2 11B from Meta brings multilingual support and even a multimodal version. And if you want to go even smaller, Microsoft's Phi-3.5 Mini sits at under four billion — it trades some quality for speed. The nice part: once you apply four-bit quantization, these models only need roughly four to eight gigabytes of memory. That runs on a mid-range consumer GPU, or on the unified memory of an M2 or M3 Mac.
Now, what can they do in a game? Let's go through it.
First, and this is the most mature use right now — dynamic NPC dialogue. Traditionally, RPG conversations are pre-written as a branching tree. The player just picks from a menu of options. A small model lets you have a genuinely free-form conversation instead. Picture this: the player says, "I heard you know something about the missing children." And the NPC, generated live, leans in and says, "Keep your voice down. The guards rotate at midnight — that's when I can talk. Ask me now, and I know nothing." That texture, that in-character evasiveness, comes out of the system prompt. And designing that prompt is the real craft. It has to carry the character's background — their personality, their secrets, how they speak. It has to know the current scene state — how much the player trusts them, the time of day, the location. And it has to encode world constraints — what this character actually knows and, just as importantly, what they don't.
Second use: procedural narrative generation. A small model can spin up short story fragments on the fly, reacting to what the player's been doing. Think of a roguelike where, every time you step into a new area, the game writes you a fresh description — the history of this abandoned dungeon, a clue scratched into the wall by the last explorer who came through. There's actually a 2025 arXiv paper on exactly this, showing that small models can approach large-model quality on short, well-contextualized creative content — and with far more variety than you'd ever get from rigid, rule-based generation.
Third: adaptive content. Same mission, but the hint language shifts depending on the player's skill level. Personalized mission briefings. Different narration branching off the choices you made earlier.
And fourth — this is where small models genuinely shine — interactive fiction and text adventures. Give the model a clear world setup, and let it drive the story forward based on what the player types. There's an experimental project called the Painter Game from Godoka that does exactly this — an interactive painting narrative running on a small model.
Let me walk you through how this actually fits together in a game. On one side you've got the game engine, holding two things: the game state — player position, inventory, relationship values — and the event trigger, which fires when the player types something or walks up to an NPC. That event, plus the current state, flows into a system prompt builder. That builder assembles the character, the state, and the constraints into one prompt. That goes to the local model — running on something like llama.cpp or Ollama. The model's output then passes through a filter that checks content safety and validates the format. And only then does it flow back to update the game state and show up on screen. So it's a loop: trigger and state in, prompt built, model generates, output filtered, screen and state updated.
On the tooling — llama.cpp is the workhorse local inference engine, and because it's C++, you can drop it right into a game engine. Ollama gives you a simple HTTP API, which is lovely for quick prototyping. And both Unity and Unreal have community-built packages that wire llama.cpp in for you.
Okay, but let's be honest about the gap versus the big models, because it's real. On speed, a local 10B model does twenty to fifty tokens a second; GPT-4o does fifty to a hundred — but remember, that number doesn't include the network round trip. And that's where local wins big: latency under a hundred milliseconds for a direct local call, versus anywhere from three hundred milliseconds to two full seconds once you account for the network. On cost, the small model is a one-time hardware purchase; the API charges you roughly five to fifteen dollars per million tokens, forever. On privacy, local data never leaves the device; the API sends everything to OpenAI's servers. Where the big model pulls ahead is long-range consistency and complex reasoning — both noticeably stronger. And on short creative generation, the small model very nearly matches it.
That long-range consistency point is the single biggest practical limitation, so sit with it for a second. Once a conversation runs past a few thousand tokens, a small model starts to *forget* — it loses the character setup or the plot details you established earlier. The fix is not to hope the model remembers. The fix is to hold all your important state *outside* the model, in a game database, and re-inject it into the context on every single call. Don't rely on the model's memory. Manage the memory yourself.
So let me leave you with three things to hold onto.
One: as of 2025, a 10B model is genuinely good enough for real-time NPC dialogue, short procedural text, and interactive narrative. This isn't theoretical anymore.
Two: it is *not* a GPT-4 replacement, and you shouldn't frame it as one. Think of it as your entry ticket into a whole new category — real-time, free, on-device language generation.
And three: design around the constraints, not in spite of them. Short context, clear constraints, explicit state management. The games that lean into those limits might end up with mechanics that feel genuinely fresh — interesting precisely *because* they were built inside the box, not outside it.
🇹🇼 中文
過年閒著沒事,我做了一個「你畫我猜」的網頁遊戲,不用註冊、不用安裝,開網址就能玩。這是我畢業之後第一次做遊戲,所以我刻意挑了架構相對直觀的社交遊戲,而「你畫我猜」又是裡面互動最簡單的一種:一邊只管畫、一邊只管猜,全程不用交流,堪稱最適合社恐的遊戲。考慮到看我的觀眾基本上都是工程師,而工程師又是社恐重災區,這選擇算是相當寵粉了。
不過這集真正想聊的不是遊戲本身,而是這次我換用了 MiniMax 最新的 M2.5,一顆激活參數只有 10B 的小模型,主打「小快靈」。一開始我幾乎沒為它調整流程,結果就是一直抽卡、一直碰壁,花了差不多兩天才摸出幾個駕馭小模型的訣竅。下面講三個最有感的教訓。
先講教訓一:架構別搞太複雜。
我一開始的後端是很中規中矩的經典起手式:一個 HTTP API 傳基本資料、一個 WebSocket 做遊戲即時同步,HTTP 前面掛 Redis 做快取,後面再放一個 PostgreSQL 當主資料庫。這套設計的問題在哪?一個狀態會被四個組件經手。比如新玩家加入房間,HTTP 和 WebSocket 都要更新,Redis 和 PostgreSQL 也都要留紀錄,只要任何一步出錯就會不同步。
倒不是說 AI 寫不出正確邏輯,而是你沒必要讓它去扛這份額外的複雜度。這除了撐大上下文、給 debug 製造難度、多吃 token 之外,沒什麼好處。所以最後我砍掉一半的技術棧:前端只用 WebSocket 做所有通訊,後端只用 Redis 當主資料庫,只保留一個通訊管道、一個儲存終點。效果立竿見影,第一版生成的程式碼只有兩個小 bug,從生成、測試到修復只花了十分鐘。
教訓二:小模型要避開冷門技術棧。
最初的 prompt 我想趕時髦,前端選了 SvelteKit 加 GraphQL,這兩個在中文圈都算冷門。結果就是語法層級的 bug 怎麼修都修不完,折騰半天連業務邏輯都沒機會看到。後來我把它們換成主流的 Vue 3 加 Express.js,語法 bug 瞬間全部消失。原因很直接:激活參數少的小模型,對冷門技術的熟悉度就是不高。
但這也是一種取捨。參數少換來的價值不少:夠輕量化、對私有化部署的錢包友善,而最重要的是,參數少意味著思考鏈路更精簡、推理速度更快。畢竟「更大、更快、更便宜」本來就是個不可能三角。
教訓三:速度夠快,就讓它自己測自己修。
之前開發那個視訊通話平台 o2o 的時候,我幾乎全程手動測試,再把問題回報給 AI。倒不是我愛當 QA,而是參數多的大模型行動偏慢,會把整個開發時間拖得很長。這次 M2.5 速度夠快,我就能讓它自己跑測試、自己找 bug、自己修。我唯一要做的,是提前把本機測試環境搭好。這裡我選擇全套 Docker 打包,AI 每次改完程式碼就直接呼叫我電腦上的 Docker 做本機部署,把業務流程從頭到尾模擬一次,自己看日誌,發現 error log 就琢磨、自己修,修完重啟再來,直到看不到 error log 為止。
這個「修 bug、啟 Docker、跑測試、看日誌、分析錯誤、再修」的迴圈會跑非常多次,這時候小模型的速度優勢就累積出可觀的時間。
省下來的時間當然是拿去加功能。整個開發裡我加的最複雜的功能,是繪圖工具「油漆桶」,難點有兩個。第一,它是二維平面填色,運作原理跟畫筆、橡皮擦這種一維線條工具完全不同,為了相容得對專案做不少重構。第二,效果只能在 canvas 上看到,而 canvas 很難自動化測試,從成本上講,最划算的做法只能靠人眼觀察、人來判斷填色對不對。後來甚至有不少觀眾勸我,乾脆找個成熟的繪圖外掛裝上去算了。還好在耐心調教下,AI 最後還是把它做出來了。
最後幫大家收攏三個重點。
第一,這次最核心的體會是:用小模型寫程式,不是把駕馭大模型那一套照搬、再期待它跟得上,而是要為它的特性重新設計工作流。
第二,具體來說就是三件事——架構極簡,少一個組件就少一份它要扛的複雜度;走主流技術棧,冷門框架會把它卡在語法 bug 上,連業務邏輯都摸不到;還有用速度換自動化,推理快,就把人從手動 QA 解放出來,交給 Docker 加 AI 的自測迴圈。
第三,在這些約束底下,一顆 10B 激活參數的小模型,已經足以快速產出一個能玩的網頁遊戲。所以與其糾結參數大小,不如先想清楚:你有沒有為它重新設計流程。
Tags
Related Articles
RAG's Five Stages: From Pipeline to Reasoning Retrieval, and the Naive RAG on My Own Site
Over the past two years RAG evolved from a 'linear pipeline' to 'loop-based reasoning'. It maps cleanly to five stages: Naive, Advanced, Modular, Graph, Agentic. The real inflection point is control moving from pipeline to agent — a System 1 → System 2 shift. Looking back at engineer-news's own RAG stack, it's stuck at the Naive edge — so this post also lays out what to fix next.
Building a Real RAG: 5 Infra Lessons from InfiniFlow's 2024 Year-in-Review
The previous post zoomed out for a five-stage panorama of RAG. This one zooms in on the five infra lessons any real RAG has to face: document ingestion, contextualized chunking, three-lane hybrid search, tensor reranker, and GraphRAG's semantic gap. Each lesson is checked against engineer-news's current stack, ending with a priority list for a personal site.
J-lens: Anthropic's New Interpretability Tool for Reading Claude's Inner Thoughts via a 'Global Workspace'
Anthropic proposes J-lens, an interpretability tool that captures the 'verbalizable' representations inside a Transformer, and uses it to show that Claude contains a privileged subspace analogous to the neuroscientific 'global workspace' — a small set of vectors that broadcast, drive reasoning, respond to external steering, and even leak signals during deception and evaluation awareness.