[GH-ISSUE #3627] [Issue]: Semantic search threshold causes unconditional or no lorebook injection #1964

Closed
opened 2026-10-21 05:44:13 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @SpicyMarinara on GitHub (Jul 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3627

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Vectorized lorebook entries are injected without a relevant mention when the semantic search score threshold is 0.97 or lower. At thresholds from 0.98 to 1.0, entries are not injected even when words from their definitions are used.

Expected behavior

Semantic search should scan the conversation history and inject only lorebook entries relevant to the current context.

Actual behavior

At a score threshold of 0.97 or lower, vectorized entries are injected regardless of context, including in the first message. At thresholds from 0.98 to 1.0, entries are never injected, even when testing words from the entry definition.

Steps to reproduce

  1. Use Marinara Engine v2.2.1 in RP with the default settings and a vectorized lorebook entry.
  2. Start a conversation without mentioning anything relevant to the entry.
  3. Set the lorebook semantic search score threshold to 0.97 or lower.
  4. Observe that the entry is injected despite having no relevant contextual match.
  5. Set the threshold between 0.98 and 1.0 and test words from the entry definition.
  6. Observe that the entry is not injected.

Environment

  • Marinara Engine version: v2.2.1
  • Install type: Not provided
  • OS + version: Not provided
  • Browser or app shell: Not provided

Logs, screenshots, or video

Screenshots: https://cdn.discordapp.com/attachments/1526770145895252029/1526770146436186262/kO875MHOavE3.png?ex=6a583b00&is=6a56e980&hm=042f3f3aede67dd7cd058a2f76dc7c4a75751f90d74c1358398f85bb62fa41e6&; https://cdn.discordapp.com/attachments/1526770145895252029/1526770147522646056/s.png?ex=6a583b01&is=6a56e981&hm=472b4e669dd67f902437df7969f4b97cffa8e7f4c59fa44c5ecabed18e8ca817&; https://cdn.discordapp.com/attachments/1526770145895252029/1526799367183274026/image.png?ex=6a585637&is=6a5704b7&hm=530137258c34e86f91b28d0d4c0c9675519d4e4dfb6366f02e3dd7f61d920a39&

Additional context

Reported as an addition to https://github.com/Pasta-Devs/Marinara-Engine/issues/3511. The embedding model was not changed. Unrelated injection can spoil RP content and force the user to swipe; in the minimal example, the person did not have a bottle and was not drinking.

Discord thread: Semantic search - useless?
Discord thread link: https://discord.com/channels/1417099416812392641/1526770145895252029
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (4 messages)
[2026-07-15T01:59:28.799Z] Nanami: Am I missing something? Default settings. Vectorized lorebook entries are always injected.
I thought search should scan history and insert entries only when a relevant mention occurs. But now this is ignored, since entries are always in the lore, and the main LLM itself decides whether to add them to the response text.
This can happen in the very first message, which spoils the entire RP, forcing you to swipe.
In the minimal example, the person doesn't have a bottle and isn't drinking anything.

This is an addition to https://github.com/Pasta-Devs/Marinara-Engine/issues/3511 
Tested on v2.2.1 in RP.
[Issue]: Semantic searching is skipped or not reachable · Issue #3...
Summary Semantic search is not functioning properly. Expected behavior It should work as before. Actual behavior Enabling vectorization in a lorebook's settings make all entries without keyword...

[attached image 1: https://cdn.discordapp.com/attachments/1526770145895252029/1526770146436186262/kO875MHOavE3.png?ex=6a583b00&is=6a56e980&hm=042f3f3aede67dd7cd058a2f76dc7c4a75751f90d74c1358398f85bb62fa41e6&]
[attached image 2: https://cdn.discordapp.com/attachments/1526770145895252029/1526770147522646056/s.png?ex=6a583b01&is=6a56e981&hm=472b4e669dd67f902437df7969f4b97cffa8e7f4c59fa44c5ecabed18e8ca817&]
[Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526770145895252029]

[2026-07-15T03:16:31.121Z] Wozza: I haven't used vectors in a while but when I did this wasn't a problem.  Are you sure it isn't injecting based on keys?  One test you could try is raise the semantic search score threshold on the lorebook up to like 0.99 and see if it still injects.
[Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526789533319036999]

[2026-07-15T03:36:31.415Z] Nanami: With Score Threshold of 0,99 it doesn't inject the entry.
[Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526794567716700211]

[2026-07-15T03:55:35.768Z] Nanami: 0,98-1.0: no injection at all, I tried every word in the definition
0,97 and lower: it will inject no matter of what.

So, it is broken. I haven't changed the embedding model, and it worked when the engine didn't have these settings (now I am not sure 😅 )

[attached image 1: https://cdn.discordapp.com/attachments/1526770145895252029/1526799367183274026/image.png?ex=6a585637&is=6a5704b7&hm=530137258c34e86f91b28d0d4c0c9675519d4e4dfb6366f02e3dd7f61d920a39&]
[Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526799367481331784]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Jul 15, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3627 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Vectorized lorebook entries are injected without a relevant mention when the semantic search score threshold is 0.97 or lower. At thresholds from 0.98 to 1.0, entries are not injected even when words from their definitions are used. ## Expected behavior Semantic search should scan the conversation history and inject only lorebook entries relevant to the current context. ## Actual behavior At a score threshold of 0.97 or lower, vectorized entries are injected regardless of context, including in the first message. At thresholds from 0.98 to 1.0, entries are never injected, even when testing words from the entry definition. ## Steps to reproduce 1. Use Marinara Engine v2.2.1 in RP with the default settings and a vectorized lorebook entry. 2. Start a conversation without mentioning anything relevant to the entry. 3. Set the lorebook semantic search score threshold to 0.97 or lower. 4. Observe that the entry is injected despite having no relevant contextual match. 5. Set the threshold between 0.98 and 1.0 and test words from the entry definition. 6. Observe that the entry is not injected. ## Environment - Marinara Engine version: v2.2.1 - Install type: Not provided - OS + version: Not provided - Browser or app shell: Not provided ## Logs, screenshots, or video Screenshots: https://cdn.discordapp.com/attachments/1526770145895252029/1526770146436186262/kO875MHOavE3.png?ex=6a583b00&is=6a56e980&hm=042f3f3aede67dd7cd058a2f76dc7c4a75751f90d74c1358398f85bb62fa41e6&; https://cdn.discordapp.com/attachments/1526770145895252029/1526770147522646056/s.png?ex=6a583b01&is=6a56e981&hm=472b4e669dd67f902437df7969f4b97cffa8e7f4c59fa44c5ecabed18e8ca817&; https://cdn.discordapp.com/attachments/1526770145895252029/1526799367183274026/image.png?ex=6a585637&is=6a5704b7&hm=530137258c34e86f91b28d0d4c0c9675519d4e4dfb6366f02e3dd7f61d920a39& ## Additional context Reported as an addition to https://github.com/Pasta-Devs/Marinara-Engine/issues/3511. The embedding model was not changed. Unrelated injection can spoil RP content and force the user to swipe; in the minimal example, the person did not have a bottle and was not drinking. Discord thread: Semantic search - useless? Discord thread link: https://discord.com/channels/1417099416812392641/1526770145895252029 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (4 messages)</summary> ```text [2026-07-15T01:59:28.799Z] Nanami: Am I missing something? Default settings. Vectorized lorebook entries are always injected. I thought search should scan history and insert entries only when a relevant mention occurs. But now this is ignored, since entries are always in the lore, and the main LLM itself decides whether to add them to the response text. This can happen in the very first message, which spoils the entire RP, forcing you to swipe. In the minimal example, the person doesn't have a bottle and isn't drinking anything. This is an addition to https://github.com/Pasta-Devs/Marinara-Engine/issues/3511 Tested on v2.2.1 in RP. [Issue]: Semantic searching is skipped or not reachable · Issue #3... Summary Semantic search is not functioning properly. Expected behavior It should work as before. Actual behavior Enabling vectorization in a lorebook's settings make all entries without keyword... [attached image 1: https://cdn.discordapp.com/attachments/1526770145895252029/1526770146436186262/kO875MHOavE3.png?ex=6a583b00&is=6a56e980&hm=042f3f3aede67dd7cd058a2f76dc7c4a75751f90d74c1358398f85bb62fa41e6&] [attached image 2: https://cdn.discordapp.com/attachments/1526770145895252029/1526770147522646056/s.png?ex=6a583b01&is=6a56e981&hm=472b4e669dd67f902437df7969f4b97cffa8e7f4c59fa44c5ecabed18e8ca817&] [Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526770145895252029] [2026-07-15T03:16:31.121Z] Wozza: I haven't used vectors in a while but when I did this wasn't a problem. Are you sure it isn't injecting based on keys? One test you could try is raise the semantic search score threshold on the lorebook up to like 0.99 and see if it still injects. [Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526789533319036999] [2026-07-15T03:36:31.415Z] Nanami: With Score Threshold of 0,99 it doesn't inject the entry. [Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526794567716700211] [2026-07-15T03:55:35.768Z] Nanami: 0,98-1.0: no injection at all, I tried every word in the definition 0,97 and lower: it will inject no matter of what. So, it is broken. I haven't changed the embedding model, and it worked when the engine didn't have these settings (now I am not sure 😅 ) [attached image 1: https://cdn.discordapp.com/attachments/1526770145895252029/1526799367183274026/image.png?ex=6a585637&is=6a5704b7&hm=530137258c34e86f91b28d0d4c0c9675519d4e4dfb6366f02e3dd7f61d920a39&] [Discord message: https://discord.com/channels/1417099416812392641/1526770145895252029/1526799367481331784] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:13 +07:00
  • closed this issue
  • added the
    in-pr
    bug
    labels
Author
Owner

@SpicyMarinara commented on GitHub (Jul 15, 2026):

Claiming this for implementation on agent/fix-3627-3631-open-issues. I will preserve the current staging prompt and lorebook behavior while adding focused semantic-match regression coverage.

<!-- gh-comment-id:4978499941 --> @SpicyMarinara commented on GitHub (Jul 15, 2026): Claiming this for implementation on `agent/fix-3627-3631-open-issues`. I will preserve the current staging prompt and lorebook behavior while adding focused semantic-match regression coverage.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 15, 2026):

Addressed in #3632. Semantic similarity is now calibrated against a neutral embedding baseline, with prompt regression coverage for clustered raw scores.

<!-- gh-comment-id:4978713740 --> @SpicyMarinara commented on GitHub (Jul 15, 2026): Addressed in #3632. Semantic similarity is now calibrated against a neutral embedding baseline, with prompt regression coverage for clustered raw scores.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1964
No description provided.