LearnNewsExamplesServices
Frontmatter
id7218
titleRefactor AI Query Scoring for Performance
stateClosed
labels
enhancement
assigneestobiu
createdAtSep 20, 2025, 11:36 AM
updatedAtSep 20, 2025, 11:51 AM
githubUrlhttps://github.com/neomjs/neo/issues/7218
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtSep 20, 2025, 11:51 AM

Refactor AI Query Scoring for Performance

Closed v10.7.0 enhancement
tobiu
tobiu commented on Sep 20, 2025, 11:36 AM

Problem

The queryKnowledgeBase.mjs script currently reloads and processes the entire knowledge base JSON file on every query. This is slow and memory-intensive, especially as the knowledge base grows.

Solution

  1. Pre-process Inheritance: In embedKnowledgeBase.mjs, load the full knowledge base, build an inheritance map, and then pre-calculate the full inheritanceChain for each chunk. Store this inheritanceChain array in the metadata for each chunk in ChromaDB.
  2. Simplify Query Script: Modify queryKnowledgeBase.mjs to be lightweight and fast.
    • Remove the code that reads the local JSON file entirely.
    • For scoring, use the inheritanceChain provided in the metadata from the query result. This avoids expensive file I/O and graph traversal on every query.
    • Keep the dynamic keyword-based scoring logic within the query script, as it depends on the user's input.

Benefits

  • Significantly faster and more memory-efficient queries.
  • Better separation of concerns (create -> score & embed -> query).
  • More scalable architecture.
tobiu assigned to @tobiu on Sep 20, 2025, 11:36 AM
tobiu added the enhancement label on Sep 20, 2025, 11:36 AM
tobiu referenced in commit 0a667b3 - "Refactor AI Query Scoring for Performance #7218" on Sep 20, 2025, 11:45 AM
tobiu closed this issue on Sep 20, 2025, 11:51 AM