Class BM25Stream

java.lang.Object
com.tnsai.server.rag.retrieval.BM25Stream
All Implemented Interfaces:
RetrievalStream

public final class BM25Stream extends Object implements RetrievalStream
BM25-based keyword retrieval, bounded by a Caffeine LRU cache (issue #36). See the issue for rationale; the index is now a bounded LRU window rather than a complete in-memory index.
  • Field Details

    • DEFAULT_MAXIMUM_SIZE

      public static final int DEFAULT_MAXIMUM_SIZE
      See Also:
    • DEFAULT_EXPIRE_AFTER_ACCESS

      public static final Duration DEFAULT_EXPIRE_AFTER_ACCESS
  • Constructor Details

    • BM25Stream

      public BM25Stream()
    • BM25Stream

      public BM25Stream(int maximumSize, Duration expireAfterAccess)
  • Method Details

    • name

      public String name()
      Specified by:
      name in interface RetrievalStream
    • getMaximumSize

      public int getMaximumSize()
    • size

      public long size()
    • addDocument

      public void addDocument(com.tnsai.knowledge.Document doc)
    • removeDocument

      public void removeDocument(String docId)
    • replaceDocuments

      public void replaceDocuments(Collection<String> removeIds, List<com.tnsai.knowledge.Document> add)
      Removes then adds documents as one generation under the index lock.
      Parameters:
      removeIds - document identifiers to drop
      add - documents to index after the removals
    • clear

      public void clear()
    • retrieve

      public List<com.tnsai.knowledge.SearchResult> retrieve(String query, int topK)
      Specified by:
      retrieve in interface RetrievalStream