Wild West API

Lorebooks and world info explained

A lorebook, called World Info in SillyTavern, is a set of entries that are added to the prompt only when their trigger keywords show up in the recent chat.

What a lorebook is

A story setting can have far more detail than you want to send on every turn: places, factions, side characters, magic rules, history. A lorebook stores that detail as separate entries, each with one or more keywords. When a keyword appears in the recent conversation, the frontend inserts that entry into the prompt. When it does not, the entry stays out and costs nothing. SillyTavern calls the feature World Info; a lorebook embedded in a character card is a character book.

How it works

On each generation the frontend scans recent text for keywords, then assembles the triggered entries. The main settings in SillyTavern:

  • Keys: primary keywords, optionally with secondary keys and logic (AND ANY, NOT ANY and so on) for selective entries. Regex keys are supported.
  • Scan depth: how many recent messages are searched. Depth 2 means only the last two messages can trigger entries.
  • Constant: the entry is always inserted, no keyword needed.
  • Insertion position and order: where the text goes (before or after the character definition, at a depth in the chat, or in the author's note) and which entries take priority.
  • Budget: a cap on how many tokens of lore can be inserted, as a percentage of context or a fixed number. Lower priority entries are dropped when it is full.
  • Recursion: inserted entries can themselves trigger other entries if they contain their keywords.
  • Probability, sticky and cooldown: options to make an entry fire only some of the time or stay active for a few messages.

The matching is plain text, not meaning. A key of "castle" does not fire on "fortress". That is the difference from vector memory, which matches by similarity.

Writing good entries

  • One topic per entry, written as short factual statements.
  • Include common variants as keys: full name, first name, nickname, plural.
  • Avoid very common words as keys, or the entry fires constantly.
  • Keep entries small, 50 to 200 tokens, so several fit in the budget.
  • Use constant entries sparingly, for facts the model must never lose.

Common mistakes

Scan depth too low, so a place mentioned three messages ago drops out mid-scene; a budget too small for the number of entries that fire; recursion loops that pull in half the book; and huge entries that read like wiki pages. Also note that entries change the prompt from turn to turn, which can reduce the benefit of prompt caching if they are inserted near the start.

Lorebooks with Wild West API

Lorebooks are handled entirely by the frontend, so they work with any model. With 512K to 1M token context windows you can afford a larger lore budget than on small local models, but each inserted token is billed as input on every request.

FAQ

Is a lorebook the same as world info?

Yes. World Info is SillyTavern's name for it. A lorebook bundled inside a character card is called a character book and works the same way.

Why is my lorebook entry not triggering?

The keyword may not be in the scanned messages (check scan depth), may be spelled differently, or the token budget may already be full of higher priority entries.

Related

Uncensored AI models on one key

OpenAI and Anthropic compatible, pay as you go. New to it? Start with uncensored AI, explained.