What is a lorebook?
A lorebook is a set of background entries attached to a character, each one guarded by keywords. An entry is inserted into the conversation only when its keywords appear. It lets a character carry a whole world without paying for that world in context on every single message.
Why not just write it in the description?
Every word of the description is sent with every message. A 3,000-word setting bible crowds out the conversation itself, and models attend poorly to detail buried in a wall of text. A lorebook keeps the card short and supplies the right paragraph at the moment it matters — when someone finally mentions the northern garrison, the northern garrison entry arrives.
How an entry works
Each entry has keywords and content. Before a reply is generated, recent messages are scanned for the keywords; matching entries are added to the context. Nothing is inserted otherwise.
Writing entries that actually fire
- Use the words people type. Include nicknames, abbreviations, and plurals, not just the formal name. An entry keyed only to “The Sundered Concordat” will rarely trigger if everyone says “the treaty”.
- Keep entries short. 50–150 words. A lorebook entry is a fact sheet, not a chapter.
- One subject per entry. Split people, places, factions, and events apart, so a mention of one does not drag in three unrelated pages.
- Avoid ultra-common keywords. Words like “he”, “city”, or “war” fire on almost every message and quietly refill the context you were trying to save.
- State facts, not prose. “Ruled by a council of five; the seat for the eastern district has been vacant since the fire” is more usable than an atmospheric paragraph.
What belongs in a lorebook
Recurring side characters, locations, factions, historical events, in-world rules — anything true of the world that only sometimes comes up. What belongs on the card instead is anything true of every message: the character’s own voice, their relationship to the user, the format of replies.
Lorebooks and memories
A lorebook is authored in advance and shared by everyone who chats with the character. Memories are specific to your own conversation and accumulate as you play. Use a lorebook for the setting; use memories for what happened in your version of it.
Getting started
Create one in the library, attach it to a character, then chat and watch which entries fire. The usual first fix is broader keywords; the usual second is shorter entries.
See also: how to write a character card and what makes an AI character compelling.