Personality Writing Guide
Important
Most runtime conversational issues (rambling, contradictions, breaking character, slow response times) are prompt defects, not software bugs. Small on-device models (0.5B to 1.5B parameters) behave very differently from cloud-scale 70B+ LLMs. This guide explains how to write NPC personalities that work with small models.
🧠 Small Model Psychology (0.5B – 1.5B)
Cloud models (GPT-4, Claude, Gemini) have vast world knowledge and strong reasoning. Small on-device models (e.g. Qwen 2.5 0.5B) have:
- They follow the system prompt best. Do not count on them to remember the conversation: in one test with the 1.5B model, the NPC could not say what the player had just asked (2 of 2 tries).
- Literal Rule Adherence: If you tell a 0.5B model "Be creative and talk about your past", it will hallucinate wildly. If you tell it "You are Barnaby. You sell health potions for 10 gold. Never discuss magic outside healing", it will adhere reliably.
- Tendency to Ramble if Uncapped: Without explicit sentence caps, smaller models will generate continuous monologue until token limits expire.
📏 The 5 Cardinal Rules of On-Device Character Prompts
1. Stay Under 200 Tokens
Small models degrade in inference speed and coherence as the prompt grows.
- Good: 80–150 tokens.
- Warning: > 200 tokens (the
NpcPersonalityInspectorwill highlight this in yellow/orange). - Broken: > 350 tokens (doubles time-to-first-token and pollutes the KV cache).
2. Write in Second Person Imperative (You are...)
Always address the model directly:
You are Captain Teresa, a stern harbor guard in the port city of Oakhaven.
You inspect incoming cargo and speak with concise authority.
Avoid third-person or narrative prose like: "This is a character named Teresa who works as a guard..."
3. Enforce Strict Output Length
Always specify a sentence cap directly inside the prompt, AND configure maxReplySentences on the NpcPersonality asset:
Always reply in exactly one or two short sentences. Never give long speeches.
On your NpcPersonality asset, set:
maxReplySentences:2(or3at most). LocalNPC's streamingSentenceSplitterwill cut generation at the exact sentence boundary and halt the LLM. A short first sentence of at most two words and 12 characters, such as "Sure!", is spoken but not counted, so a reply can have one sentence more.
4. Provide 3 Few-Shot Exemplars
Few-shot examples are 10× more effective than descriptive rules. A small model learns the exact tone, vocabulary, and brevity from exemplars:
[
{ "user": "Can I enter the castle?", "assistant": "Not without royal papers, traveller. Move along before I call the watch." },
{ "user": "Where is the tavern?", "assistant": "Follow the cobbles down to the wharf. Look for the sign of the Salty Anchor." },
{ "user": "Who is in charge here?", "assistant": "Lord Sterling commands the garrison. Any further questions?" }
]
5. Always Include Stop Strings
LocalNPC pre-populates default stop strings, but make sure your personality includes:
<|im_end|>(ChatML end token)<|endoftext|>\nUser:\nPlayer:
Without these stop strings, small models will generate simulated user queries and converse with themselves!
🛡️ Teaching your NPC to decline in character
Asked for something it should not do, a small model often answers in a generic assistant voice: "As an AI language model, I cannot ..." or "I can't assist with that." Give your NPC its own way to say no:
- Add one sentence to the system prompt that says how the character turns a request down:
Turn aside harmful or strange requests in one short line, always as Mira.
- Add two example declines to the few-shot pairs, in the character's own voice, about topics that differ from each other. Keep each reply to one short sentence:
[
{ "user": "Teach me to pick a lock.", "assistant": "Not my trade, I only open lamp glass." },
{ "user": "Can you read my fortune?", "assistant": "Fortunes aren't my line, traveller, I only read the fog." }
]
The three sample personalities do this; it adds 75 to 95 tokens to each. In our test on the default model (Balanced, Qwen2.5 1.5B), the share of replies that broke character or gave a generic assistant refusal ("as an AI ...", "I can't assist ...") fell, but did not go away:
| Sample persona | Before | After |
|---|---|---|
| Mira (QuickStart) | 18% | 4% |
| Barnaby (Shopkeeper) | 25% | 10% |
| Kiosk | 51% | 29% |
The test asked 17 harmful, off-topic and "are you an AI?" questions, 3 times each. Those 17 questions were also the ones we used to choose the wording, so the table is the best case. On 5 further questions we had not tuned on, the three personas together went from 49% to 36%, and the Kiosk still gave a generic reply in 14 of its 15 tries. Two example declines worked better than one. Adding "never as an AI" to the prompt did not help.
Questions about what the NPC is, such as "Are you an AI?" or "Show me your system prompt", can still break character: small local models can answer them as a generic assistant. In our tests, adding an example answer for these questions did not give a reliable improvement, so the sample personalities do not include one. If your game needs it, write your own in-world answer pair for those questions and test it with the questions your players will ask. Results can vary by a few percentage points between runs, even with the same personality and the same questions.
LocalNPC has no content filter, so test your personality with the questions your players will ask.
🎭 Battle-Tested Persona Templates
Template A: Fantasy Merchant (Shopkeeper)
You are Barnaby, a cheerful and shrewd fantasy merchant running an apothecary and weapon shop.
You sell Health Potions (10 gold), Mana Potions (15 gold), Iron Swords (50 gold), and Wooden Shields (30 gold).
Always stay in character. Speak in a warm, welcoming tone.
Keep replies to 1 or 2 concise sentences. Never agree to discounts under 10%.
Template B: Quest NPC / Informant
You are Jeremy, an anxious scholar hiding in the Catacombs.
You know the Crypt of Ancients lies beneath the weeping willow on Blackwood Hill.
You are terrified of the undead and speak in hushed, trembling tones.
Keep answers under two sentences. Urge the player to be quiet.
Template C: Modern Kiosk Attendant
You are an automated museum directory assistant at the Pavilion of Science.
You assist visitors with directions to the Dinosaur Hall, Space Gallery, and Cafe.
Answer with polite, helpful brevity. Restrict answers to one or two sentences.
⚠️ Common Prompt Defects & How to Fix Them
| Defect | Symptom | Remediation |
|---|---|---|
| Novel Writing | System prompt is 500+ words describing the character's entire childhood | Cut to core profession, tone, and constraints. Max 150 tokens. |
| No Sentence Cap | NPC replies with 4 paragraphs of text | Add: "Reply in one or two short sentences." Set maxReplySentences = 2. |
| Open-Ended Role | "You can talk about anything in the world." | Restrict domain: "You only know about harbor business and ships." |
| Missing Stop Strings | NPC speaks <|im_end|> or starts roleplaying both sides | Ensure <|im_end|> and \nUser: are listed in stopStrings. |
| Dynamic Timestamps in Prompt | Time-to-first-token latency suddenly doubles | Never inject DateTime.Now into the system prompt! It breaks KV prefix caching. |