Uploaded image for project: 'LLM AI Integration'
  1. LLM AI Integration
  2. LLMAI-239

Semantic search misses some of the best matching chunks when few results are requested

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.0.1
    • 0.3
    • None
    • Unknown

    Description

      Problem

      When a search asks for only a few semantic results, the results are often not the best matching chunks of the collection: asking for more results returns better matches in the first positions than asking for few. The chat is the most affected, since its context uses 2 or 3 semantic results by default.

      Steps to reproduce

      1. Index a collection with a few thousand chunks.
      2. Send POST /rest/wikis/xwiki/aiLLM/search?query=<text>&collection=<name>&limitSemanticResults=3&limitKeywordResults=0.
      3. Send the same request with limitSemanticResults=100.

      Result

      For some queries, the 3 results of the first request are not the first 3 results of the second one, and the best match of the second request can be missing from the first.

      Expected

      The first request returns the first 3 results of the second one.

      Cause

      The search of the vector index is approximate, and it explores less of the index when it is asked for fewer nearest neighbors. The semantic query asks for exactly as many neighbors as results requested.

      Fix

      Ask the index for at least 100 nearest neighbors and return the requested number of results.

      Attachments

        Activity

          People

            ppantiru Paul Pantiru
            ppantiru Paul Pantiru
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: