Lunelle ← Back to home
Guides

What is a lorebook in AI roleplay? How to write one

Updated

A lorebook is a collection of short entries about a story’s world, such as its side characters, places, factions, and rules, and each entry has a few keywords. When one of those keywords comes up in the recent chat, the app adds that entry’s text to what it sends the AI before the next reply, so the AI knows who or what is being discussed. Lore that isn’t needed stays out of the prompt until it is, which saves room in the AI’s limited context. A lorebook works when each entry covers one subject in a few plain sentences, names that subject in its text, and uses keywords people actually type, such as names, nicknames, and plurals.

Most roleplay apps have one under some name. SillyTavern calls it World Info, AI Dungeon calls its version Story Cards, and Janitor AI keeps lorebooks under Scripts. Chub, NovelAI, and Character.AI call it a lorebook, and Character.AI added its own in July 2026. The settings differ from app to app, but the mechanism of keywords that pull in text is the same, so the advice in this guide works in any of them.

How a lorebook works

Before each reply, the app sends the model one block of text: the character’s definition, any notes or memory the app keeps, and as much of the recent chat as fits. That block has a size limit, called the context window, measured in tokens. Everything the AI knows about your story at that moment has to fit inside it. Our guide to why AI characters forget explains the limit in more detail.

A lorebook lets the app choose what goes into that block based on the scene. The app scans the last few messages for each entry’s keywords, inserts the entries it finds, and leaves the rest out. NovelAI’s documentation puts it in one sentence: “Each entry has its own activation key(s), and when an activation key is found in the recent context, the entry’s text gets inserted into the context.” When the keyword stops appearing in recent messages, the entry drops out again.

Suppose your lorebook has an entry for a smuggler named Hesper Rook. As long as nobody mentions her, her entry is left out. When you write that Rook is waiting on the pier, the app finds the keyword “Rook” and adds her entry, so the next reply knows who she is and what she owes your character.

The apps explain the purpose in terms of space. Character.AI’s help center says “Details written into the Character Definition take up space in every response, whether they’re relevant or not,” and that a lorebook “keeps those details on standby” until a keyword calls them up. Chub’s documentation says a lorebook can hold a character’s backstory and setting “without needing to have it be in character definitions taking up permanent token space.”

Leaving unused lore out may also help the AI focus. In a 2023 study, Freda Shi and colleagues added irrelevant sentences to math problems and found that models were “easily distracted by irrelevant information.” A 2025 study by Yufeng Du and colleagues found that models did worse as the input grew longer, even when they could find every fact they needed. Neither study tested stories, but both suggest that a prompt full of lore the scene doesn’t use can make replies worse.

Researchers call the general technique retrieval-augmented generation: a system looks up stored text and adds it to the model’s input. Patrick Lewis and colleagues named it in a 2020 paper about models that “combine pre-trained parametric and non-parametric memory,” meaning what a model learned in training plus a collection of text it can look things up in. A lorebook is a small, hand-written version of the same idea, where the lookup is a keyword match. SillyTavern can also match entries by meaning through its Vector Storage extension, and its documentation advises: “If you want deterministic and predictable results, stick to keyword matching.”

Where the term comes from

Two AI story games shaped the feature and its name. AI Dungeon, Latitude’s AI text adventure, had a feature called World Info, which it later renamed. Its help center notes that “Story cards also used to be called ‘World Info’.” NovelAI’s roadmap of June 2, 2021, published before its beta, announced a “Lore Book” as “a simple word-matching version of this world information feature,” and said NovelAI was working on imports of AI Dungeon stories that would include their world info.

The name lorebook spread from there. The Character Card V2 specification, a shared file format for AI character cards finalized in May 2023, defines a lorebook as entries “included in the prompt when specified keywords are found in the conversation history.” It says the term was coined by NovelAI and notes that SillyTavern calls the same thing World Info. The spec also added a way to embed a lorebook inside a character card, called a character book, so that “users don’t have to download and import two separate files.” That’s why a character you download from Chub or import into SillyTavern can arrive with its own lorebook.

What each app calls it

Each app builds the same idea into its own menus and settings. Here is where to find it and what is particular to each.

SillyTavern: World Info

SillyTavern’s documentation describes World Info as “also known as Lorebooks or Memory Books.” You can make a lorebook active in every chat, or bind it to a character, a persona, or a single chat. A lorebook bound to a character is embedded in the character card when you export it, so the lore travels with the character. Each entry has keys, content, an insertion order and position, and options for recursion, probability, and timed effects such as a cooldown.

Janitor AI: lorebook scripts

Janitor AI released lorebooks to all users on September 5, 2025, as one of two modes of a beta feature called Scripts. Its announcement described the lorebook mode as a “visual editor mode for world-building and lore management” that could also import SillyTavern lorebooks. To make one, Janitor AI’s help center says to open the menu from your profile picture, select Scripts, click Create New Script, and choose Lorebook. You then add entries, each with keys and content, and assign the script to one or more of your characters. Each standard entry “has just one text box,” and the help center suggests keeping it to one to three sentences.

Character.AI: Lorebook

Character.AI launched Lorebook in beta on July 24, 2026. Its help center describes the same mechanism as the other apps: “Each piece of information is stored as an entry with keywords. When you or your Character mentions one of those keywords, the relevant entry becomes available.” Each entry has a title the character never sees, content, and up to eight keywords. One lorebook can be linked to several characters so they share the same world, and it has to be published before it works in chat. During the beta, creating and editing lorebooks requires a c.ai+ subscription.

Chub: lorebooks and character books

Chub’s documentation defines a lorebook as “a series of defined keywords that, when activated, insert specific content into the prompt.” You build a standalone lorebook in the Lorebook Creator and add it to a chat from Chat Settings, or you build one into a character in the Character Creator, where it’s called a character book. Character books work only when “Use V2 Spec.” is enabled. By default Chub ignores capital letters and matches whole words, so the keyword “Apple” matches “apple” but not “Applebottom.”

NovelAI: Lorebook

NovelAI describes its Lorebook as “a repository for supplemental information that’s added to the AI’s context as each entry comes up in your story.” Keys can be plain words, regular expressions, or combinations such as NovelAI & Anlatan, which fires only when both words are in range. NovelAI searches a set number of characters of recent story text, up to 10,000, and it has a generator that drafts entries for you.

AI Dungeon: Story Cards

AI Dungeon’s help center calls Story Cards “notes for the AI about characters, locations, concepts, or any other elements of your story.” A card has a type, a name the AI can’t see, an entry, triggers, and notes. When a trigger appears in your input or the AI’s output, the entry goes into the context under the label “World Lore:”. AI Dungeon checks at least the last four actions for triggers, and more when there is room for more cards. Since August 2026, creators can also pin a card so it stays in the context every turn.

What a lorebook entry looks like

Every app’s entry has the same two working parts. The keywords decide when the entry fires, and the content is the text the AI reads. Most apps add a title for your own reference, and SillyTavern, NovelAI, AI Dungeon, Chub, and Character.AI all say the AI doesn’t see it. The two entries below are illustrations for an invented harbor city, written as plain text you could copy into any app’s fields.

Title: The Saltmarket
Keywords: Saltmarket, Salt Market, night market
Content: The Saltmarket is a night market on the docks of Varrow, open from dusk to dawn. Smugglers trade there openly because Captain Hesper Rook pays the Harbor Watch to stay away. Anyone caught stealing in the Saltmarket is thrown off the pier by Rook's crew.

The first entry fires when someone names the market. Its first sentence says what the place is, the second says why it matters in a story about smugglers, and the third gives a rule the AI can turn into a scene. It also names Hesper Rook, which can pull in her own entry in apps that support recursion.

Title: Tide magic
Keywords: tide magic, tidecaller, tidecallers, tidecalling
Content: Tide magic lets a tidecaller move water by speaking to it. Each use costs the tidecaller one memory, and they can't choose which. Tidecallers keep journals to track what they have lost. Using tide magic inside Varrow's walls is punished by exile.

The second entry describes a rule of the world. Its keywords include the plural and other forms of the word, because several apps match whole words only. It also says what the magic costs, which makes every use a decision for the characters.

Entry settings

Beyond keywords and content, apps add settings that control when and where an entry goes into the prompt. The names vary, and these are the main ones.

These settings sit alongside the model’s own settings, such as context size, which our guide to roleplay settings explains.

How to write lorebook entries that work

An entry is read out of its original context. The app drops it into the prompt on its own, sometimes next to other entries and far from the scene that made it relevant, and the AI has to understand it from its text alone. These habits come from the apps’ documentation and from what research shows about how models read long prompts.

Cover one subject per entry. A person, a place, a faction, an item, and a rule each get their own entry with their own keywords. Character.AI’s entry templates follow the same split, with separate templates for side characters, locations, items, events, factions, and world rules. If a city and its rulers share one long entry, every mention of the city pulls in the rulers too, and the AI gets more text than the scene needs.

Name the subject in the content. NovelAI’s documentation says to “always include the entry’s title somewhere inside the entry text itself or else the AI won’t know what the entry is about,” and AI Dungeon gives the same advice. Open with the name and what the thing is: “The Saltmarket is a night market on the docks of Varrow.”

Keep entries short and factual. Janitor AI’s help center says “1–2 sentences usually work better than paragraphs,” and AI Dungeon’s asks for “short, simple sentences and unambiguous language.” AI Dungeon also warns that when an entry is long, “the AI will pick and choose just some of the information provided.” Janitor AI’s advice for chat memory fits lorebooks too: “List facts, not scenes.” Write “Rook owes Riley a favor” instead of a paragraph about the night the debt began.

Write in the third person, with names. An entry can be inserted for any character in any scene, so “I” or “you” inside an entry can end up pointing at the wrong person. In apps that support placeholders, {{char}} stands for the character and {{user}} for your persona, and Character.AI’s help center says its lorebook entries support them the same way character definitions do.

Put the most important fact at the start or the end. AI Dungeon’s help center advises to “Place the most important information at the beginning and end of the Entry,” because “The AI has a bias towards information in these positions.” Research on long prompts found a similar pattern: in “Lost in the Middle” (Nelson Liu and colleagues, 2024), models did best when the information they needed was “at the beginning or end of the input context.”

Write what is particular to your world. Character.AI’s help center notes that characters “already know plenty about the real world, so focus on what’s unique to yours.” For a harbor, that means its name, who controls it, and what happens there that happens nowhere else, with no explanation of what a harbor is.

Go light on physical description. AI Dungeon’s help center warns that with too much of it, “the AI will either not use it at all, or may repeatedly mention it, over and over again.” One or two features the characters would notice are enough.

Choosing keywords

An entry with the wrong keywords either never reaches the AI or reaches it in every reply, so keywords need as much care as the content.

What goes in the definition and what goes in the lorebook

Character.AI’s help center gives a rule of thumb: “always relevant goes in the Definition, sometimes relevant goes in the Lorebook.” It puts a character’s core identity, such as motivation, voice, and behavior, in the definition, and world details such as side characters, locations, factions, events, and rules in lorebook entries.

In practice, the main character’s personality, voice, and relationship to you belong in the definition, because they matter in every reply. A side character who appears in one chapter, a city the story visits twice, or a rule that matters only when someone casts a spell belongs in the lorebook. A fact that shapes every scene without being about the character, such as a war or a curfew, can go in the scenario, an always-on entry, or the app’s memory field. Our guide to writing an AI character that stays in character covers the definition itself.

What to put in a lorebook for a world

A lorebook for a whole world usually covers four kinds of things: places, factions, rules of magic or technology, and history. An entry is most useful when it gives the AI something to use in a scene, such as a problem, a rule with a consequence, or a detail a character can react to. Long passages of scenery or history that never touch the plot use up room without giving the AI anything to act on.

Places

Give each place a one-line description, who controls it, and one concrete custom or rule. Jonathan Swift’s Gulliver’s Travels (1726) sums up the politics of Lilliput and Blefuscu in one absurd fact: the two nations are at war over which end of an egg should be broken first, and the holy text both sides argue over says only “that all true believers break their eggs at the convenient end.” A detail like that, or a custom such as “in the river towns, it’s bad luck to say a drowned person’s name,” gives the AI something to build a scene around.

Factions

For each faction, write what it wants, what it controls, and who stands in its way. Factions that want the same thing, such as two guilds that both claim the river trade, give the AI a reason for conflict in any scene where they meet. Name the faction’s leader in its entry, and give the leader an entry of their own, so a mention of either can bring in the other in apps with recursion.

Rules of magic or technology

A rule entry should say what the power does, what it costs, who can’t have it, and what happens to people who break the rule. In Ursula K. Le Guin’s A Wizard of Earthsea (1968), magic works through the true names of things, and wizards are taught that changing anything disturbs the Equilibrium, the balance of the world. Because magic has a price in that book, using it is always a decision. The tide magic entry above follows the same pattern.

Some rules affect every scene. In Frank Herbert’s Dune (1965), water is so scarce on the desert planet Arrakis that it shapes the whole culture of the Fremen, from the stillsuits that recycle the body’s moisture to the water they reclaim from their dead. A rule like that belongs in the scenario or an always-on entry, where the AI sees it without waiting for a keyword.

History

Keep the full history in your own notes, and give the lorebook only the events that still affect the story. J. R. R. Tolkien invented languages, family trees, and thousands of years of history for Middle-earth. The Lord of the Rings (1954–55) shows only parts of it, and much of the rest appeared in the book’s appendices or in books published after his death, such as The Silmarillion (1977). An entry for a past war should say who fought, who won, and what grudge or debt remains, and its keywords should be the war’s name and the places it touched.

A first lorebook for a world can be small:

Common problems and how to fix them

Most lorebook problems come down to an entry firing at the wrong time or the AI not using what it receives. Before you change anything, check what the AI actually got. AI Dungeon and NovelAI have a context viewer, and Janitor AI’s test chat has a debug panel that shows whether an entry fired.

The entry never triggers

Go through these checks in order:

  1. The keyword appears within the scan depth. If you named the place five messages ago and the depth is three messages, the entry stays out.
  2. The keyword matches the text exactly, including plurals in apps that match whole words, and capital letters if case sensitivity is on.
  3. The entry is enabled, its probability is 100 percent, and no minimum message count is holding it back. Janitor AI calls that setting Min Messages.
  4. The lorebook is attached where it should be. In Janitor AI, the script has to be assigned to the character. In Character.AI, the lorebook has to be linked and published. In Chub, a character book needs “Use V2 Spec.” turned on.
  5. The budget has room. SillyTavern and Chub skip entries once the token budget is full, even when their keywords match.

In AI Dungeon, a trigger isn’t instant: if the AI names something partway through a reply, the card reaches the AI from the next output on.

The entry triggers too often

An entry that fires in nearly every reply usually has a keyword that is too common, or one the character keeps saying. Replace common words with names, add a secondary keyword so the entry fires only in the right context, or lower the scan depth. In AI Dungeon, check that a short trigger isn’t matching inside longer words. In SillyTavern, a cooldown keeps an entry from firing again for a set number of messages.

The AI ignores the entry

A triggered entry is information the AI may or may not use. SillyTavern’s documentation says World Info “does not guarantee its appearance in the generated output messages,” and that this “depends on how good your model is at making use of additional information.” If the entry is in the prompt and the reply still ignores it, shorten the entry so the key fact isn’t buried, and put that fact in the first sentence. In apps that allow it, move the entry closer to the end of the prompt: after the character definition or at a chat depth in SillyTavern, or with a higher insertion order in Chub.

If something has to happen in the next reply, say so in a short note in your own message. Our guides to steering an AI story and writing OOC notes cover when and how.

Two entries contradict each other

Contradictions appear when the same fact lives in two places, such as a character’s age in both the definition and an entry, or when the story changes and an entry stays the same. Research on conflicting information gives no simple rule for which version a model will follow. Jian Xie and colleagues (ICLR 2024) found that models “can be highly receptive to external evidence” when it is coherent and convincing, but also show “a strong confirmation bias” when some of the evidence they get agrees with what they learned in training and some contradicts it.

The practical fix is to keep each fact in one entry and update entries as the story moves. AI Dungeon’s help center says you “can (and should) update them to reflect changes in your story,” and Character.AI lets lorebook owners edit an entry from the viewer inside the chat.

The lorebook takes up too much space

Many active entries can crowd out the recent chat. In AI Dungeon, Story Cards “are among the first elements to be removed from the context when it is full,” and Janitor AI’s help center puts its own model’s context at “Around 8k-9k tokens.” Trim entries to their facts, split long entries into narrower ones, turn always-on entries back into keyword entries when they aren’t needed every turn, and set a token budget so the lorebook can’t take over the prompt. In SillyTavern, an inclusion group lets only one of several matching entries in, and “Alert on overflow” warns you when activated entries exceed the budget.

Common questions

What does a lorebook do?

It gives the AI background on people, places, and rules at the moment they come up in the chat. The app checks recent messages for each entry’s keywords and adds the matching entries to the prompt, so the AI can use details that would otherwise be missing or would take space in every reply.

How do I make a lorebook in Janitor AI?

Open the menu from your profile picture, select Scripts, click Create New Script, and choose Lorebook. Add entries with keys and content, then assign the script to your characters. Janitor AI’s help center suggests short entries and testing them with the debug panel in a test chat.

Does Character.AI have lorebooks?

Yes. Character.AI launched Lorebook in beta on July 24, 2026, and creating and editing lorebooks requires c.ai+ during the beta. Each entry can have up to eight keywords, and one lorebook can be linked to several characters.

Is World Info the same as a lorebook?

Yes. SillyTavern calls its lorebooks World Info, and AI Dungeon used the name World Info before it switched to Story Cards. A character book, or characterbook, is a lorebook embedded in a character card.

Can I use a SillyTavern lorebook in another app?

Often. Janitor AI’s help center explains how to paste the entries from a SillyTavern World Info file into a lorebook script. A lorebook bound to a SillyTavern character is embedded in the exported card, and Chub uses character books from cards when “Use V2 Spec.” is on.

What’s the difference between a lorebook and memory?

A lorebook holds entries you write ahead of time, and each one is sent only when its keywords come up. Memory features keep facts from the chat itself, either as notes you write, such as Character.AI’s Story Memory, or as memories the app saves and retrieves by relevance, such as AI Dungeon’s Memory Bank. Our guide to writing a chat memory summary covers what to put in a memory note.

Long-term memory is one of Lunelle AI’s three focus areas: characters remember events, choices, and how their relationship with you has changed, across sessions. See long-term memory in Lunelle AI.

Sources