Keyword Instruction Blocks

From Infinite Worlds
Jump to navigation Jump to search

Keyword instruction blocks are instruction blocks which are only given to the AI when their associated keywords are detected in playerAction and recent context. These keywords are not case-sensitive (i.e. "Keyword" is treated the same as "keyword").

Keyword instruction blocks are a mechanism for avoiding sending the AI unnecessary information - they're useful when you want to give a lot of information which is only occasionally relevant (for example, information on a specific city or faction).

If you're not sure whether you should use a keyword instruction block or not, it's probably best to simply put information in the Main instructions.

IW Description[edit]

Keyword instruction blocks allow you to write information about specific topics which is provided to the AI only when those topics are mentioned in the story. Because the information is sent to the AI only when it's needed, you can provide much more information than would be reasonable to give in the main instructions.

Note that unless one of the keywords has recently been mentioned, the AI has no awareness at all of the contents of a keyword block. For this reason it often makes sense to mention topics briefly in the main instructions, and then expand on them in a keyword block.

Overview[edit]

Keyword instruction blocks are designed for providing situational extra information about specific topics. However, it's important to understand how lore books work. The AI cannot "look things up" in lore books; rather, they are invisible to it unless specifically triggered.

Lore books are triggered by specific keywords which must show up in recent context i.e. either the player input or the AI output (including secretInfo), but not the main instructions (otherwise the lore book would always be added!). This test is a simple string comparison, so the keyword "hat" would match the word "whatever", and so on. When a keyword is matched, the lore book's contents are sent to the AI along with the main instructions for the next three turns. This means that anything which could be written in main instructions could also be put in lore books; they are not limited simply to lore descriptions of topics but can include other instructions for the AI too.

When a lore book keyword matches the player input, the lore book is sent to the AI for that turn meaning its response will already be aware of the lore book contents. If the AI's output matches a lore book keyword, the lore book will be added on the subsequent turn.

Essentially, keyword instruction blocks are extra instruction blocks which are only sometimes included, dependent upon recent events.

This also implies that one should write keyword instruction blocks as if you were writing in main instructions, albeit with the flexibility to be a little more verbose. Text that would add cost or risk confusing the AI in main instructions still will in a lore book, it just won't always be sent.

The advantage that keyword instruction blocks have over simply putting the info into main instructions is that it's not always added. If a world has a lot of text in keyword instruction blocks, perhaps referring to many niche topics, this could bloat the main instructions, increasing cost and potentially distracting the AI from more important instructions. Furthermore, keyword instruction blocks can be modified by triggers, making them quite flexible.

A good example use of keyword instruction blocks would be extra information about locations which could be visited, but may not be. Whenever the location is named in the player action or the output text, this additional information will start being sent to the AI. However, if the game takes place entirely somewhere else and the relevant location is never part of the story, that information is not needed and so we can avoid having to send it.

Note that until a keyword instruction block is triggered, the AI will have no awareness of its existence, let alone its content. Therefore it may be necessary to include brief mention of relevant items in main instructions anyway, or the topic might never get mentioned in the first place.

Importing[edit]

Keyword instruction blocks authored outside of Infinite Worlds can be imported into worlds. This is a convenient way to reuse instruction blocks or to adapt instruction blocks written by other people (e.g. from Chub AI Lorebooks) for your worlds.

To import keyword instruction blocks:

  1. Edit a world
  2. Check "Show optional features"
  3. Expand "Keyword instruction blocks (formerly lorebooks; advanced feature, optional)"
  4. Select "Import from lore book"

Keyword instruction blocks are formatted as the following example JSON:

{
  "entries": {
    "0": {
      "key": [
        "Mars",
        "Martian base"
      ],
      "content": "A frontier base was built on Mars ten years ago. It contains dome-like protective structures, closed-loop oxygen recycling, water reclamation and purification, hydroponics and controlled agriculture zones, and solar panel arrays. It was left abandoned after its residents evacuated when it was attacked by aliens."
    },
    "1": {
      "key": [
        "Horizon Nexus",
        "space station"
      ],
      "content": "Horizon Nexus is a space station in Mars's orbit. It contains a rotating central cylinder for artificial gravity, a fusion reactor core, a command and control center, personalized living quarters, communal recreation areas, and psychological wellness centers.\nHorizon Nexus is the residence of asteroid miners who commute to and from the asteroid belt between Mars and Jupiter, as well as doctors, engineers, and maintenance staff."
    }
  }
}

This will produce the following keyword instruction blocks. Note that the Infinite Worlds interprets the first key as the name of the instruction block.

  1. Mars
    Keywords
    Mars, Martian base
    Content
    A frontier base was built on Mars ten years ago. It contains dome-like protective structures, closed-loop oxygen recycling, water reclamation and purification, hydroponics and controlled agriculture zones, and solar panel arrays. It was left abandoned after its residents evacuated when it was attacked by aliens.
  2. Horizon Nexus
    Keywords
    Horizon Nexus, space station
    Content
    Horizon Nexus is a space station in Mars's orbit. It contains a rotating central cylinder for artificial gravity, a fusion reactor core, a command and control center, personalized living quarters, communal recreation areas, and psychological wellness centers.
    Horizon Nexus is the residence of asteroid miners who commute to and from the asteroid belt between Mars and Jupiter, as well as doctors, engineers, and maintenance staff.

Notes[edit]

  • Formerly called Lore Books.