---
url: https://lettuceai.app/docs/lorebooks
title: "Lorebooks — LettuceAI"
description: "Define persistent world lore, character backgrounds, and rules that activate by keyword across all chats."
---

Menu 

# Lorebooks

Lorebooks define persistent world canon, character background, and rules that apply across chats and sessions.

## In plain English

A lorebook is a set of permanent notes that the AI can look up when certain words or topics appear.

-   Use lorebooks for world facts, backstory, factions, locations, and rules
-   Use memory for evolving story events and relationship changes
-   Use lorebooks when something should stay stable across chats

Simple difference

**Lorebook** means "fixed reference information." **Memory** means "things the app learned or saved from the conversation."

Lorebook content is written by you and remains attached to a character permanently. It is not learned, changed, or forgotten by the AI. Entries are injected only when relevant keywords appear, allowing large shared lore to persist without being sent on every message.

## What Lorebooks Are (and Arent)

-   **Are**: On-demand reference material the AI can consult when needed.
-   **Are not**: Persistent memory or learned behavior.

Lorebooks do not evolve, decay, or learn over time. They act as conditional instructions that activate only in specific situations.

## Structure

### Lorebooks

You can create multiple lorebooks (for example: _World History_,_Magic System_, or _Locations_).

Each lorebook can be assigned to multiple characters, allowing reuse without duplicating content.

### Entries

Each lorebook contains entries with the following properties:

-   **Title**: short label, shown only in the editor.
-   **Content**: the text injected into the prompt when the entry is active.
-   **Keywords**: triggers that activate the entry.
-   **Case sensitive**: per-entry toggle for whether keyword matching is case sensitive.
-   **Always active**: skip keyword scanning and inject this entry on every turn.
-   **Enabled**: disable an entry without deleting it.
-   **Priority** and **display order**: determine reading order when multiple entries activate at once.

### Keyword detection mode

Each lorebook has a keyword detection mode that controls how much conversation history is scanned for triggers:

-   **Recent message window** (default): scans the most recent messages so keywords mentioned a few turns ago can still activate entries.
-   **Latest user message**: only the user's most recent message is scanned. Best for narrowly scoped, on-topic activation.

* * *

## Activation

When you send a message, the system scans according to the lorebook's detection mode for matching keywords.

-   **Keyword match**: if a keyword appears, the entry activates.
-   **Always active**: entries marked as always active bypass keyword checks entirely.
-   **Disabled entries**: never activate, even if their keywords appear.

If no keywords match, the entry is not injected at all.

* * *

## Injection & Priority

When one or more entries are activated, they are processed in this order:

1.  **Ordering**: Entries are sorted by their position in the lorebook.
2.  **Assembly**: All active entries are combined into a single_World Information_ block.
3.  **Insertion**: The block is injected into the AI's prompt before response generation.

Entries near the top of a lorebook take precedence when instructions conflict.

* * *

## Cost & Token Usage

Lorebooks only consume tokens when entries are activated.

-   Inactive entries cost nothing.
-   Activated entries are included verbatim in the prompt.
-   Broad or common keywords can cause frequent, unnecessary injection.

For cost efficiency, prefer small, focused entries with precise triggers.

* * *

## Setup

### Creating a Lorebook

1.  Navigate to the **Lorebook** tab.
2.  Click **New Lorebook**.
3.  Enter a descriptive name.

### Assigning to a Character or Persona

Lorebooks only apply when assigned. There are two ways to attach one:

-   **Per character**: open the character editor and pick the lorebooks you want active in their chats. Multiple characters can share the same lorebook.
-   **Per persona**: assign lorebooks to a persona to bring along user-side context (your faction, your gear, your home town) whenever you use that persona, regardless of which character you chat with.

Active lorebooks from the character and the active persona are merged for each turn.

### Adding Entries

1.  Open the lorebook and click **+**.
2.  Add keywords that should activate the entry.
    -   **Recommended**: Specific names and unique terms (_Neo-Tokyo_, _Excalibur_).
    -   **Avoid**: Generic words (_city_, _place_, _man_).
3.  Enter the content.
4.  Reorder entries to control priority.

On mobile, you can long-press an entry and drag it to reorder.

* * *

## AI Lorebook Generator

The Lorebook Generator builds a complete lorebook for you from a brief and optional source materials. It runs as a multi-stage pipeline so each entry is planned, drafted, and reviewed before you accept it.

The pipeline has four stages:

-   **Planner**: outlines the entries (titles, keywords, rough scope) from your brief and sources.
-   **Writer**: drafts the content for each entry from the approved outline.
-   **Refine**: revises any single entry from a feedback message you provide.
-   **Coherence**: proposes surgical edits across the full set so entries stay consistent with each other.

From Settings, you can configure:

-   **Generation model**: pick a text model for all four stages, or leave it unset to use the app default.
-   **Default entry count**: between 5 and 50. Pre-fills the slider when you start a generation.
-   **Max output tokens**: per-stage completion cap (256 to 32768). Raise it for longer entries or large outlines.
-   **Structured fallback**: JSON or XML. Used when the selected model does not reliably emit tool calls.
-   **Stage prompts**: each of the four stages can use the built-in default prompt or a custom prompt template you define.

To start a flow, open the Library, click **New Lorebook**, and choose **Generate with AI**. You can accept, edit, or discard each proposed entry before it is saved.

## AI entry generator

From a lorebook editor you can ask the app to draft new entries for you. You describe what the world or setting is about (or point it at an existing character), and the generator proposes titles, keywords, and content that you can accept, edit, or discard one by one.

## Trigger preview

The trigger preview tool lets you paste in sample text or load existing chat messages, then see exactly which entries would activate and why. It is the fastest way to debug keywords that fire too eagerly or never fire at all.

## Import and export

Lorebooks can be moved between LettuceAI installs and shared with other apps:

-   **Native JSON**: full LettuceAI lorebook with all fields preserved.
-   **SillyTavern World Info**: import and export the common world info format, so you can reuse community-made lorebooks.
-   **USC (Unified Setting Card)**: portable shared format.

When you import a character that ships with a lorebook (from a Chara Card v3, UEC, or Discovery card), the lorebook is created and attached for you automatically.

## Best Practices

-   **Use Lorebooks** for static, backstory, and reference-style information.
-   **Use Memory** for evolving facts, relationships, and story events.
-   Keep entries concise. long entries increase token usage when triggered.
-   Split large topics into multiple entries with targeted keywords.

[

PreviousMemory System

](/docs/memory)[

NextSync

](/docs/sync)
