pub struct GraphRAGConfig {
pub max_entities_per_doc: usize,
pub max_relations_per_doc: usize,
pub leiden_resolution: f64,
pub leiden_seed: u64,
pub max_community_levels: usize,
pub max_context_tokens: Option<usize>,
pub entity_matcher: Option<Box<dyn EntityMatcher>>,
}Expand description
Configuration for GraphRAG.
Fields§
§max_entities_per_doc: usizeMaximum number of entities to extract per document.
max_relations_per_doc: usizeMaximum number of relations to extract per document.
leiden_resolution: f64Leiden modularity resolution γ for community detection
(see community::DEFAULT_RESOLUTION). Higher values produce more,
smaller communities; lower values merge more aggressively.
leiden_seed: u64Deterministic RNG seed for the Leiden algorithm. Fixed by default so rebuilding communities over the same graph yields the same partition.
max_community_levels: usizeMaximum number of hierarchy levels, including level 0. Each higher
level aggregates communities of the level below (see Community).
max_context_tokens: Option<usize>Maximum number of tokens for context in query prompts. When set, community summaries or subgraph context is truncated to fit.
entity_matcher: Option<Box<dyn EntityMatcher>>Custom entity matcher for local/hybrid queries. When None, uses the default KeywordMatcher.
Implementations§
Source§impl GraphRAGConfig
impl GraphRAGConfig
Sourcepub fn with_max_entities_per_doc(self, n: usize) -> Self
pub fn with_max_entities_per_doc(self, n: usize) -> Self
Sets the maximum number of entities to extract per document.
Sourcepub fn with_max_relations_per_doc(self, n: usize) -> Self
pub fn with_max_relations_per_doc(self, n: usize) -> Self
Sets the maximum number of relations to extract per document.
Sourcepub fn with_leiden_resolution(self, resolution: f64) -> Self
pub fn with_leiden_resolution(self, resolution: f64) -> Self
Sets the Leiden modularity resolution γ.
Sourcepub fn with_leiden_seed(self, seed: u64) -> Self
pub fn with_leiden_seed(self, seed: u64) -> Self
Sets the deterministic RNG seed used by Leiden community detection.
Sourcepub fn with_max_community_levels(self, levels: usize) -> Self
pub fn with_max_community_levels(self, levels: usize) -> Self
Sets the maximum hierarchy depth (level 0 is the base partition).
Sourcepub fn with_max_context_tokens(self, tokens: usize) -> Self
pub fn with_max_context_tokens(self, tokens: usize) -> Self
Sets the maximum number of tokens for context in query prompts.
When set, community summaries (Global/Hybrid) or subgraph context (Local/Hybrid) are truncated from lowest-priority items to fit within this budget.
Sourcepub fn with_entity_matcher(self, matcher: Box<dyn EntityMatcher>) -> Self
pub fn with_entity_matcher(self, matcher: Box<dyn EntityMatcher>) -> Self
Sets a custom entity matcher for local/hybrid queries.
When set, the matcher is used instead of the default keyword-based matching to find relevant entities.