Stemmer Lorebook cover
181
1

Stemmer Lorebook

Advanced Script

Sorta fulltext search using Porter stemmer alg. Check https://optimalhorror.github.io/ how to populate

About this script

What is this?

This is an advanced memory script that gives your bot a "Brain" for lore. Unlike standard lorebooks that require you to say specific keywords (like Help or History), this script relies on context and words used in the entry and user's prompt.

It uses Vector Math (Cosine Similarity) to figure out what you are talking about and automatically retrieves the relevant information from the lorebook.

✨ Key Features:

  • 🔎 "Google" for Roleplay: It effectively searches the database every time you send a message to find the most relevant entry.

  • 📚 Infinite Knowledge: You can pack huge amounts of lore into the database, and the AI will only "read" the specific paragraph that matters for the current conversation, saving tokens.

🛠️ How to Use:

1. Write your text: Regular text, no need to get fancy, but splitting it into paragraphs will definitely help.

2. Use the Generator: Go to https://optimalhorror.github.io. Pick Stemmer tab

  • Paste your lore text into the editor.

  • Click "Parse Text".

  • Click "Export Entries", your JSON will be downloaded.

  • Click "Export Vocabulary", your JSON will be downloaded.

3. Install:

  • Open this script file.

Look for the section marked LOREBOOK ENTRIES.

  • Delete the example data (The Ainur stuff) and paste your generated JSON there.

  • Do the same for const vocab = ... (The generator provides this too).

⚙️ Configuration (For Advanced Users):

score = 0.1: This is the Sensitivity.

Higher (e.g., 0.5) = The bot only remembers lore if it is extremely relevant to what you said, might miss some nuance.

Lower (e.g., 0.1) = The bot brings up lore even if it's only vaguely related.

topN = 5: This is the Limit. It determines the maximum number of lore entries the bot is allowed to read at once.


Script source

Public codeContext depth 3

Used by

1 character using this script


Please log in to see comments