Detecting Patterns
Experimental API
Pattern detection is an experimental feature. The API may change in future releases.
Introduction
Zep’s pattern detection analyzes the structure of your knowledge graph to discover recurring patterns: frequent relationship types, multi-hop paths, co-occurring entities, highly connected hubs, and tightly interconnected clusters. Unlike graph search, which retrieves content matching a query, pattern detection reveals the shape of your data — surfacing structural insights that aren’t visible from individual nodes or edges.
What It Finds
Use Cases
- Knowledge graph auditing: Understand what types of information your graph captures most frequently
- Schema discovery: Identify dominant relationship patterns to inform ontology design
- Anomaly context: Establish baselines of normal graph structure to help detect anomalies
- Data quality: Find unexpected patterns that may indicate ingestion issues
Basic Usage
With no configuration, pattern detection analyzes the entire graph and returns all pattern types using default settings:
Configurable Parameters
*Either user_id or graph_id is required
Selecting Pattern Types
Use the detect parameter to choose which pattern types to find. Each key enables that type; its value provides type-specific configuration. Omit detect entirely to run all types with defaults.
Type-Specific Configuration
Seed Nodes
By default, pattern detection analyzes the entire graph. Use seeds to focus analysis around specific nodes, node labels, or edge types. When multiple seed fields are provided, seeds are combined (union).
Seed Options
Recency Weighting
Apply temporal decay to favor recently created edges. The recency_weight value sets the exponential decay half-life applied to each edge’s created_at timestamp.
When recency weighting is enabled, the weighted_score in each result reflects the decayed sum, while occurrences always reports the raw unweighted count.
Search Filters
Use search_filters to restrict which nodes and edges participate in pattern detection. This uses the same filter format as graph search.
Including Examples
Set include_examples to true to receive concrete node and edge UUIDs for each detected pattern. This is useful for drilling into specific instances of a pattern.
Response Structure
Each pattern in the response contains:
The response also includes a metadata object:
Patterns are sorted by weighted_score in descending order.