sphiratrioth666's picture
Update README.md
237df69 verified
metadata
license: cc-by-nc-4.0

I was experimenting with Silly Tavern lorebooks and I found a great way of implementing pre-defined random events or actions when particular circumstances occur. It allows steering the scenario automatically, simulating a TTRPG experience (rolling dice with random roleplaying results) or steering a {{char}} behavior very precisely the way we want.

image/png
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License (https://www.goodfon.com/fantasy/wallpaper-the-lord-of-the-rings-sauron-dark-lord-metal-helm.html)

How to do it:

1. Create a lorebook in Silly Tavern (I will not teach you that, you need to understand how it's done and how it's used on your own this time - super simple (read this: https://rentry.co/world-info-encyclopedia). In short, it is usually used for storing and triggering actual lore information when a particular trigger word appears in our message or LLM response, but we'll be using the lorebooks much more creatively! They can be used to give LLM orders/instructions in instruct mode in a very useful way. Lorebooks go into: (...)\SillyTavern\data\default-user\worlds).

2. Create the entries group in your lorebook - add multiple entries, each representing random events you want to happen in a given situation (like table of results of dice rolls in TTRPG).

Each entry must have: a) the same trigger words, b) position = at Depth (System), c) depth = 1, d) order = 100, e) trigger = 100, f) Prevent further recursion option on (entry will not activate other entries), g) group weight = 100 (or lower it if you want something to trigger less frequently, it's just a probability modifier, does not have to sum up to 100 in a group, as it seems), h) sticky = 10 or 20 (it makes the instruction for LLM remain active for a given number of the following messages - so it actually triggers logically within the scene, LLMs seem to understand it and do things under logical circumstances in the scene".

image/png

image/png

You can theoretically change the weights to trigger different events with different probabilities. For simplicity, you can also match all separate "dice results" with a given fiction result or a TTRPG system DC (something like: we roll 1d6, we fail at 1-3 so: 1 = {{user}} will fail in {{user}}'s' action, 2 = {{user}} will fail in {{user}}'s' action, 3 = {{user}} will fail in {{user}}'s action', 4 = {{user}} will succeed in {{user}}'s action etc.'). I rather prefer having equal weights and repeated entries rather than messing with the weights. We never know, which actual RNG simulator a given software will use so this way - we take control of that forcing the real, equal distribution. It's also why Excell RNG for dice rolling is more realistic than dice rolling apps, just if you're curious (I'm working in game dev).

3. Write instructions inside of the entries. They must be short, clear and include a specific word: "WILL". It seems to be very, very important. Otherwise, it might not work - at least with Mistral models and their fine-tunes.

Template: {{char}} will [ACTION YOU WANT] or [EVENT] will [HAPPEN}. Something like: "enemies will attack {{user}}" or "road ahead will be blocked".

Again, it seems that a word "will" is the best working trigger. Here, maybe "OOC" instructions would also be a good idea but since keys at depth = system are inserted already as instructions inside of a prompt itself (I checked, they're [INST] (...) [/INSTR] for Mistral), I'm not sure if it makes any sense.

image/png

image/png

TRICKS:

  1. it may be good using one, specific word to trigger the entry group so it does not trigger again and again with different results as you or LLM repeats the trigger word - such as - attack or defend or whatever. You can use something like... roll 1d20 even - if you're into TTRPG. However, in different situations, recursive triggering may prove beneficial - then you may want to lower a "sticky" value but 5 seems balanced (LLM counts both {{user}} and {{char}} messages, if you're interested to know).
  2. depending on the use-case, you will need a couple of such entry groups (like different "dice rolls" for social encounters, different for random events in the world and different for dungeons exploring). IT WORKS VERY WELL.
  3. you can also steer {{char}}'s behavior precisely using this method to stick to the personality better or make character consistently do given things in given situations (it seems to work better than pure card definitions).
  4. In NSFW, like actions during combat, reacting to monsters (your {{char}} should be really terrified when seeing a Sauron or a Nazgul, not jump at them with an axe happily) - you can add variety and logic to your roleplays - this way, {{char}}'s behavior is influenced better than while using normal, random lorebooks in a classical manner. BTW, you can combat a positive bias of LLMs like that (a bias of cooperating with {{user}} when {{user}} does something - for instance, your sword swing will fail to connect with the enemy if you set it up to trigger like that. It works VERY WELL.