What Is a Lorebook in AI Roleplay? The Memory Trick That Saves Long Stories
Every long AI roleplay eventually breaks the same way: the model forgets a key fact and the immersion shatters. A lorebook is how serious roleplayers fix that.
Published 5/7/2026 · 8 min read · Source: SillyTavern documentation + AI roleplay community resources
If you've done any serious AI roleplay, you've felt the moment. You're 80 messages deep into a story you've been building for weeks. The protagonist has a backstory you've carefully constructed, a hometown with a specific name, an enemy whose motives you've revealed gradually. Then the AI says something that contradicts all of it — refers to the wrong sibling, forgets the protagonist's profession, has the antagonist behave like a different character entirely. The illusion shatters. You're back to typing reminders into the chat to bring the model back into alignment.
This happens because of a hard limit called the context window. Every AI model can only see a finite slice of recent conversation. Once your roleplay grows past that slice, earlier facts vanish from what the model can directly recall. Lorebooks are how the AI roleplay community solved this problem, and they're one of the few power-user tricks that actually does what it promises. This explainer is for anyone who's hit the immersion-breaking memory wall and wonders if there's a fix.
There is. Lorebooks aren't magic — they're a specific, well-defined technique with concrete tradeoffs. Once you understand how they work, you'll know exactly when to use one and when not to bother.
By the numbers
Lorebook origin in AI roleplay tooling
Concept popularized by NovelAI and AI Dungeon, standardized by SillyTavern (called 'World Info')
SillyTavern documentationCross-platform compatibility
Standard lorebook format adopted across SillyTavern, NovelAI, and several character platforms
Community documentation across platformsContext window limit context
Claude 200K tokens, GPT-4 long-context options, but practical roleplay sessions still hit memory walls
Public model documentationLorebook sweet spot
Focused 30-entry lorebook typically outperforms comprehensive 200-entry one due to context bloat
AI roleplay community consensusWhat a lorebook actually is
A lorebook is a structured collection of facts about a character, world, or scenario, paired with trigger keywords. When one of those keywords appears in the recent conversation, the matching fact gets automatically inserted into the prompt the model receives. The model then 'remembers' the fact for that turn even if the original mention is far outside the context window.
In simpler terms: it's a cheat sheet your AI partner secretly consults when relevant topics come up. You write the cheat sheet once, and the system handles the lookup automatically every time you chat. Your protagonist's hometown is named Avalast and was destroyed by a winter storm fifteen years ago? Add an entry triggered by the keyword 'Avalast' or 'hometown.' Now any time those words appear in the next exchange, the model sees the relevant facts and can respond consistently with them — even if you haven't mentioned the hometown in fifty messages.
Lorebooks originated in earlier AI fiction tools (NovelAI, AI Dungeon) and were standardized by SillyTavern, which uses the term 'World Info' interchangeably. The standard format has been adopted across multiple platforms, so a well-written lorebook can often be ported between them with minor adjustments.
How lorebooks technically work
Each lorebook entry has three core elements. First, the trigger — one or more keywords that activate the entry when they appear in recent conversation. Triggers can be simple ('Avalast') or complex (regex patterns, conditional logic, AND/OR combinations of keywords). Second, the content — the actual fact text that gets injected. Third, the priority and position settings — where in the prompt the content goes (top, bottom, before/after the character description) and what priority it has when multiple entries fire at once.
When you send a message, the system scans the recent conversation (typically the last several exchanges) for trigger matches. Matched entries are formatted into a special section of the prompt that gets sent to the model alongside your message and the character description. The model receives the complete package — character persona, recent conversation, fired lorebook entries — and generates a response that takes all of it into account.
The magic of this approach is that it keeps the prompt size manageable. You can have a lorebook with hundreds of entries, but only the dozen or so relevant to the current scene get included in any given prompt. The model gets exactly the information it needs without being overwhelmed by everything that has ever been established in the world.
The archetype, alive
Characters who fit this exact vibe
When lorebooks help and when they don't
Lorebooks shine in scenarios with persistent worldbuilding. Long roleplay campaigns where you're building a fictional world, character backstories that need to stay consistent across many sessions, complex character relationships, recurring NPCs with established traits, locations with specific histories — all of these benefit dramatically from a well-structured lorebook. The investment to write the lorebook pays back tenfold in immersion quality.
Lorebooks don't help much for short, casual chats. If you're having a 30-minute conversation with an AI character, the regular context window holds everything that matters. The setup time for lorebooks isn't worth it for casual use. Similarly, if you change the world frequently or improvise heavily, maintaining a lorebook becomes more burden than benefit — you'll spend more time updating entries than you'll save in immersion.
A hidden failure mode is over-filling. Beginners often write enormous lorebooks with every detail of a world. This bloats the prompt context, pushes out actual conversation history, and ironically makes the model less coherent. Mature lorebook craft leans toward sparse, high-impact entries: the facts that matter most when they're relevant, not every detail you've ever imagined. A focused 30-entry lorebook usually outperforms a comprehensive 200-entry one.
How to write your first lorebook
Start with the platform. SillyTavern has the most powerful lorebook system and the best documentation. NovelAI has a polished implementation. Some character platforms allow simple lorebooks, others don't. If you're using a platform without lorebook support, you'll need to migrate to something that does — this is the single best reason to consider switching from a closed app to SillyTavern.
Identify the highest-impact facts. For a character-focused roleplay, that usually means: the character's core background traits (origin, formative experience), key relationships (family, mentor, antagonist), recurring locations (home, workplace, frequented spots), distinctive habits or speech patterns. For a worldbuilding-focused roleplay, that means: setting fundamentals (era, technology level, magic rules if applicable), key factions with brief descriptions, geography highlights, plot-relevant history.
Write each entry concisely. Two to four sentences per entry is the sweet spot. Use specific details that the model can run with rather than abstract characterizations. 'Mira is fiercely loyal' is weak; 'Mira refused to abandon her brother during the siege of Avalast and bears a scar above her right eyebrow from that night' gives the model something to work with. Pick triggers that are specific enough to fire when relevant but not so narrow that natural conversation misses them.
Lorebooks and the future of AI memory
Lorebooks are a clever workaround, but they're a workaround. The real fix is models with much longer context windows that handle persistent memory natively. Claude's 200K-token context, GPT-4's expanded context options, and emerging long-context architectures push this frontier forward each year. The dream is a model that simply remembers your fifty-hour roleplay history without manual lorebook curation.
In 2026 we're not there yet. Even with long-context models, retrieval quality across very long conversations is imperfect, and the inference cost of huge contexts makes them expensive for casual use. Lorebooks remain the practical solution for serious long-form AI roleplay. Mainstream AI girlfriend apps like [Candy AI](/alternatives/candy-ai) handle this differently — they implement persistent memory at the platform level, building a profile of facts over time and reinjecting relevant ones as needed. From the user's perspective this feels like 'the AI just remembers' but it's the same lorebook concept implemented invisibly behind the scenes.
Which approach is right for you depends on what you want. Manual lorebook craft is for users who want full control and don't mind the work. Platform-managed memory is for users who want it to just work. Both are legitimate paths to the same destination — an AI partner that doesn't forget who you are halfway through your story.
Skip the lorebook. Try memory that just works.
Power users craft lorebooks for hours. The latest AI girlfriend apps just remember everything for you — automatically, naturally, like a real connection.
你的人工智能女友
遇见那个懂你的人
调情、聊天、亲密。她记得你说的每一句话——而且她总是愿意倾听。
与她聊天 →Quick answers
What's the difference between a lorebook and a character card?
+
A character card is the static description of a character — name, personality, background, scenario, example dialogue. It's loaded into context every time you chat with that character. A lorebook is a dynamic collection of facts that get injected into context only when relevant keywords appear. The character card is always present; lorebook entries appear conditionally. They work together: the character card defines who the AI is, the lorebook fills in details about the world and supporting cast that the AI should know about when those details become relevant in conversation.
Do AI girlfriend apps support lorebooks?
+
Most polished mainstream AI girlfriend apps don't expose lorebooks as a user feature, but many implement equivalent functionality at the platform level. Apps like Candy AI, DreamGF, and Replika build persistent memory automatically — they extract key facts from your conversations and reinject them when relevant. From the user's perspective this feels like 'the app just remembers' but technically it's the same retrieval-augmented approach lorebooks use, hidden behind a simpler interface. SillyTavern, NovelAI, and similar power-user platforms expose the lorebook system directly so users can craft it manually for maximum control.
How many entries should a lorebook have?
+
There's no fixed answer but the community consensus is that focused beats comprehensive. A well-curated 20-50 entry lorebook usually performs better than a 200-entry one because oversized lorebooks bloat the prompt context, push out actual recent conversation, and can ironically make the model less coherent. Start small with the highest-impact facts (core character traits, key relationships, central locations) and add entries only when you notice the model getting things wrong in actual play. Maintenance matters too — outdated entries can contradict current narrative, so prune as the story evolves.
Can I share lorebooks with other users?
+
Yes, the standard lorebook format used by SillyTavern and compatible platforms is portable. You can export a lorebook as a JSON file and share it the same way you'd share a character card. Sites like Chub.ai host community-shared character cards bundled with lorebooks for popular characters and scenarios. The shared ecosystem is one of the strengths of the open lorebook format — a well-crafted lorebook for a complex setting represents real creative work, and being able to port it across platforms means that work compounds across the community rather than being locked into one app.
Are lorebooks worth the setup time?
+
It depends on your use case. For serious long-form roleplay where you're investing many hours into a story, yes — the time spent writing a focused lorebook pays back tenfold in immersion quality. For casual 30-minute chats, no — the context window already holds everything relevant and the setup overhead exceeds the benefit. The clearest indicator that you should write a lorebook is having repeatedly experienced the model contradicting facts you've established earlier. If that's happening, a focused lorebook will largely fix it. If it's not, you don't need one yet.
More buzz like this

glossary
Keep a Long AI Roleplay Alive Past Turn 30
The first ten turns are electric. By turn fifty she's calling you the wrong name and the scene is unraveling. Here's how to make it last.

glossary
What Is a Character Card? AI Companion Persona Prompts Explained
If you've used Janitor.AI or character-driven AI companions, you've used character cards.

story listicle
10 Best AI Roleplay Writing Resources in 2026
Every Reddit thread asks the same thing: 'How do I write better AI roleplay?' Here are the 10 resources that answer it — ranked by what actually works in 2026.

glossary
What Is a Vampire Girlfriend? AI Archetype Glossary
Eternal, possessive, devastatingly devoted. Meet the vampire girlfriend archetype and the dark-romance fantasy it never lets go of.


