build_dag_taxonomy
build_dag_taxonomy(
embeddings,
k_neighbors=30,
similarity_threshold=0.55,
diversity_gap_threshold=0.02,
verbose=False,
)Build a navigable DAG taxonomy from embedding space.
Creates a lattice structure where: - Nodes with high neighbor diversity are “general” (parents) - Nodes with low neighbor diversity are “specific” (children) - Multiple parents are allowed (non-tree structure)
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| embeddings | np.ndarray | Embeddings to analyze (n, d). Will be L2-normalized. | required |
| k_neighbors | int | Number of neighbors for k-NN graph. | 30 |
| similarity_threshold | float | Minimum similarity for parent-child edges. | 0.55 |
| diversity_gap_threshold | float | Minimum diversity difference for directed edge. | 0.02 |
| verbose | bool | Print progress information. | False |
Returns
| Name | Type | Description |
|---|---|---|
| DAGTaxonomy | DAGTaxonomy with navigation methods. |
Example
from dyf import build_dag_taxonomy
taxonomy = build_dag_taxonomy(embeddings)
Navigate the taxonomy
ancestors = taxonomy.get_ancestors(query_idx) common = taxonomy.get_common_ancestors(idx_a, idx_b) hubs = taxonomy.get_convergence_points(min_parents=10)