Package com.tnsai.intelligence.rag
Class GraphRAGStrategy
java.lang.Object
com.tnsai.intelligence.rag.GraphRAGStrategy
- All Implemented Interfaces:
RAGStrategy
Deterministic, bounded graph traversal retrieval strategy.
The framework ranks seed nodes, traverses outgoing edges, prevents cycles within each path, and emits each node once through its highest-scoring path. Scores decay by edge weight and depth. A non-empty source fence prevents both retrieval and traversal through nodes outside the selected sources.
- Since:
- 0.13.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault relevance decay applied for every traversed edge.static final intDefault maximum traversal depth.static final intDefault hard bound on expanded graph nodes per retrieval. -
Constructor Summary
ConstructorsConstructorDescriptionGraphRAGStrategy(String providerName, GraphStore store, Set<String> allowedSources, int maxDepth, double depthDecay, int maxVisitedNodes) Creates a graph strategy. -
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.
-
Field Details
-
DEFAULT_MAX_DEPTH
public static final int DEFAULT_MAX_DEPTHDefault maximum traversal depth.- See Also:
-
DEFAULT_DEPTH_DECAY
public static final double DEFAULT_DEPTH_DECAYDefault relevance decay applied for every traversed edge.- See Also:
-
DEFAULT_MAX_VISITED_NODES
public static final int DEFAULT_MAX_VISITED_NODESDefault hard bound on expanded graph nodes per retrieval.- See Also:
-
-
Constructor Details
-
GraphRAGStrategy
public GraphRAGStrategy(String providerName, GraphStore store, Set<String> allowedSources, int maxDepth, double depthDecay, int maxVisitedNodes) Creates a graph strategy.- Parameters:
providerName- provenance name of the graph providerstore- graph data access implementationallowedSources- exact source fence; empty allows every sourcemaxDepth- maximum number of edges traversed from a seeddepthDecay- relevance multiplier applied at each depthmaxVisitedNodes- hard expansion bound
-
-
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
-