Package com.tnsai.intelligence.rag
Class KeywordRAGStrategy
java.lang.Object
com.tnsai.intelligence.rag.KeywordRAGStrategy
- All Implemented Interfaces:
RAGStrategy
RAG strategy that uses BM25-style keyword matching.
Delegates to BM25Index from tnsai-core's advanced memory
module. BM25 scoring favors documents with high term frequency
relative to document length and inverse document frequency.
Results must exactly match every RAGContext.metadataFilters()
entry before the requested result limit is applied.
- Since:
- 0.2.4
-
Constructor Summary
ConstructorsConstructorDescriptionKeywordRAGStrategy(com.tnsai.memory.advanced.BM25Index bm25Index) Creates a keyword RAG strategy backed by the given BM25 index. -
Method Summary
Modifier and TypeMethodDescriptionname()Returns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").retrieve(String query, RAGContext context) Retrieves documents relevant to the given query.
-
Constructor Details
-
KeywordRAGStrategy
public KeywordRAGStrategy(com.tnsai.memory.advanced.BM25Index bm25Index) Creates a keyword RAG strategy backed by the given BM25 index.- Parameters:
bm25Index- the BM25 index to search
-
-
Method Details
-
name
Description copied from interface:RAGStrategyReturns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").Names are compared case-insensitively using
Locale.ROOT.- Specified by:
namein interfaceRAGStrategy- Returns:
- the strategy name, never null
-
retrieve
Description copied from interface:RAGStrategyRetrieves documents relevant to the given query.Every returned document must exactly match all metadata filters in the context. Implementations apply that constraint before limiting the result to
RAGContext.maxResults().- Specified by:
retrievein interfaceRAGStrategy- Parameters:
query- the search query (never null)context- retrieval parameters (max results, min score, exact metadata filters)- Returns:
- an unmodifiable list of retrieved documents, sorted by descending relevance
-