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.
Pattern detection supports two modes:
- Seed mode: Provide explicit seed nodes, labels, or edge types to analyze patterns around specific parts of the graph
- Query mode: Provide a natural-language query to automatically discover relevant nodes and return relationship patterns with relevance-scored edges
What It Finds
Query mode only detects relationship patterns. Use seed mode for path, co-occurrence, hub, and cluster detection.
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
- Agent-driven Q&A: Use query mode to find relevant graph context for answering questions (e.g., “clothing purchases” returns scored edge facts about purchase patterns)
Basic Usage
Seed mode
Provide seeds to focus analysis around specific nodes, node labels, or edge types. At least one seed field (node_uuids, node_labels, or edge_types) is required.
Query mode
Provide a query string to let Zep automatically discover relevant nodes and detect relationship patterns. The response includes relevance-scored edges per pattern and a deduplicated nodes array.
Configurable Parameters
*Either user_id or graph_id is required
Either query or seeds is required, but not both
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
Use seeds to specify the starting points for pattern detection in seed mode. At least one seed field is required. When multiple seed fields are provided, seeds are combined (union). Seeds cannot be used together with query.
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.
Response Structure
Each pattern in the response contains:
The top-level response also includes:
The metadata object contains:
Patterns are sorted by weighted_score in descending order.