Package com.tnsai.intelligence.rag
Interface RAGStrategy
- All Known Implementing Classes:
GraphRAGStrategy,HierarchicalRAGStrategy,HybridRAGStrategy,KeywordRAGStrategy,MultiQueryRAGStrategy,ReasoningRAGStrategy,TemporalRAGStrategy,VectorRAGStrategy
public interface RAGStrategy
Service provider interface for pluggable RAG retrieval strategies.
Implementations are discovered via ServiceLoader.
Each strategy defines a unique name() and implements the
retrieve(String, RAGContext) method to return ranked documents.
Built-in strategies:
"vector"— embedding-based semantic similarity search"keyword"— BM25-style lexical keyword matching"hybrid"— combines vector + keyword via Reciprocal Rank Fusion"graph"— bounded traversal over a provider-backed graph store"hierarchical"— child-hit selection with bounded parent expansion"temporal"— content relevance with bounded time decay
- Since:
- 0.2.4
- See Also:
-
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.
-
Method Details
-
name
String name()Returns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").Names are compared case-insensitively using
Locale.ROOT.- Returns:
- the strategy name, never null
-
retrieve
Retrieves 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().- 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
- Throws:
NullPointerException- if query or context is null
-