The examples are demonstrations and small training runs, not benchmark evidence. Metrics they print depend on epochs, dimension, seed, and backend; short default budgets do not reproduce published numbers.
| I want to... | Run |
|---|---|
| See box containment, overlap, and volume by hand | containment_hierarchy |
| See Gumbel soft containment and temperature | gumbel_box_exploration |
| Train boxes on a small taxonomy | box_training |
| Train cones on a small taxonomy | cone_training |
| Answer multi-hop queries with box intersection | query2box |
| Load, train, and evaluate a triple dataset end to end | dataset_training |
| Compare region geometries on one small hierarchy | geometry_comparison |
| Train EL++ box embeddings on an ontology | el_training |
| Bring graph data in from petgraph | petgraph_adapter (feature petgraph) |
cargo run -p subsume --example containment_hierarchy
cargo run -p subsume --example gumbel_box_exploration
cargo run -p subsume --example box_training --release
cargo run -p subsume --example cone_training --release
cargo run -p subsume --example query2box
cargo run -p subsume --example dataset_training --release
cargo run -p subsume --example geometry_comparison --release
cargo run -p subsume --example el_training --release
cargo run -p subsume --features petgraph --example petgraph_adapterndarray-backend and kge are default features. Each example below is
registered in Cargo.toml with these required-features.
| Feature | Examples |
|---|---|
kge (default) |
dataset_training, geometry_comparison, imagenet_hierarchy, lattix_bridge, save_checkpoint, wn18rr_ball, wn18rr_training |
burn-ndarray (or burn-wgpu, which implies it) |
el_benchmark_burn, el_clqa_benchmark, el_clqa_galen, el_clqa_trained |
burn-ndarray + kge |
taxobell_box_uncertainty, taxobell_precinct, wn18rr_ball_burn, wn18rr_box_burn, wn18rr_cone_burn, wn18rr_geometry_comparison_burn, wn18rr_transbox_burn |
hyperbolic |
hyperbolic_demo |
density + rand |
density_el_demo |
petgraph |
petgraph_adapter |
These read datasets that are not committed. Without the data they print what to fetch and exit 0.
| Data | Examples | Setup |
|---|---|---|
data/WN18RR/ |
wn18rr_ball, wn18rr_ball_burn, wn18rr_box_burn, wn18rr_cone_burn, wn18rr_geometry_comparison_burn (or DATA=<dir>), wn18rr_training, wn18rr_transbox_burn |
python3 scripts/download_wn18rr.py |
data/GALEN/ (Box2EL) |
el_benchmark, el_benchmark_burn, el_clqa_galen |
GALEN download and conversion commands |
The full WN18RR examples use the published head and tail order for filtered
link prediction across all 11 relations. For _hypernym, that order is
(child, relation, parent). The standalone dataset_training example reverses
its hypernym-only subset to train a taxonomy where parent boxes contain child
boxes. The save_checkpoint and geometry_comparison examples keep their
WordNet subsets in the original link-prediction order.
gene_ontology reads the committed data/go_subset/go_normalized.tsv.
| Example | What it demonstrates |
|---|---|
containment_hierarchy |
Hand-constructed box hierarchy; containment/overlap probabilities; volume ratios reflect concept generality |
gumbel_box_exploration |
Gumbel box properties: soft containment, membership probability, temperature annealing (no training) |
cone_training |
Training cone embeddings on an 18-entity taxonomy (3+ levels); aperture reflects generality |
box_training |
Training box embeddings with direct coordinate updates on a 25-entity taxonomy; volume reflects generality |
query2box |
Query2Box-style compositional query answering: multi-hop KG queries via box intersection, containment ranking, and alpha-weighted distance scoring |
octagon_demo |
Octagon embeddings: diagonal constraints, point containment, intersection (closure), volume comparison, soft containment/overlap |
taxobell_demo |
TaxoBell Gaussian box losses on a mini taxonomy (no training, loss inspection only) |
dataset_training |
Load a WordNet subset, orient hypernyms as parent contains child, evaluate filtered MRR/Hits@k, and round-trip a checkpoint |
save_checkpoint |
Generate the pretrained WordNet subset checkpoint (writes pretrained/wordnet_subset.json) |
imagenet_hierarchy |
Real-scale training on 252 Tiny ImageNet WordNet synsets; volume-depth correlation (Spearman) |
hyperbolic_demo |
Poincare ball embeddings: norm-depth correlation, hierarchy preservation, exponential capacity |
el_training |
End-to-end EL++ box embedding training on a biomedical-style ontology |
density_el_demo |
Density matrix EL++ training; parent-child fidelity vs disjoint-pair fidelity |
el_benchmark |
Full EL++ evaluation on Box2EL datasets (GALEN, GO, Anatomy); per-NF MRR/Hits@k |
el_benchmark_burn |
Box2EL benchmark via Burn; GPU via burn-wgpu, CPU fallback via burn-ndarray |
el_clqa_trained |
Conjunctive LCA queries over trained EL++ Burn boxes |
el_clqa_benchmark |
Synthetic CLQA benchmark comparing faithful EL++ boxes with TransE |
el_clqa_galen |
Data-gated GALEN CLQA benchmark with containment and join-match scoring |
gene_ontology |
EL++ box embeddings on a Gene Ontology subset; full train/eval pipeline |
geometry_comparison |
All 6 new geometry types (ball, cap, subspace, ellipsoid, transbox, annular) on a WordNet subset; side-by-side MRR/Hits@k/MeanRank |
lattix_bridge |
Convert a lattix::KnowledgeGraph into a subsume Dataset |
petgraph_adapter |
Convert a directed petgraph taxonomy into a subsume Dataset |
region_generic |
Geometry-generic ranking through the Region trait; shows why scores are not cross-geometry calibrated |
taxobell_box_uncertainty |
Propagate input uncertainty through a Burn TaxoBell encoder with stableprop and compare against Monte Carlo |
taxobell_precinct |
Train TaxoBell Gaussian boxes, convert them to precinct AxisBox regions, and query them through RegionIndex |
wn18rr_ball |
Ball embeddings (SpherE + RegD) on WN18RR; per-triple SGD with analytical gradients |
wn18rr_ball_burn |
Batched ball training on WN18RR via Burn; InfoNCE loss; GPU via burn-wgpu, CPU fallback via burn-ndarray |
wn18rr_box_burn |
Batched relation-aware box training on WN18RR via Burn |
wn18rr_cone_burn |
Batched relation-aware cone training on WN18RR via Burn |
wn18rr_geometry_comparison_burn |
Compare Burn region trainers on WN18RR |
wn18rr_transbox_burn |
Batched TransBox training on WN18RR via Burn; GPU via burn-wgpu, CPU fallback via burn-ndarray |
wn18rr_training |
Box embeddings on WN18RR via CPU ndarray backend; reference pipeline |
-
Want to understand box geometry (containment, overlap, volume)? Start with
containment_hierarchy. -
Want to understand Gumbel temperature effects and soft membership? Start with
gumbel_box_exploration. -
Want to answer multi-hop knowledge graph queries with box intersection? Start with
query2box. -
Want to understand octagon embeddings (boxes + diagonal constraints)? Start with
octagon_demo. -
Want to embed a tree-like hierarchy in hyperbolic space? Start with
hyperbolic_demo. -
Want to train embeddings on a hierarchy?
- Real-scale (252 entities, Tiny ImageNet synsets):
imagenet_hierarchy - Dataset pipeline (load, train, evaluate with metrics):
dataset_training - Cone model (angular containment, supports negation):
cone_training - Box model (axis-aligned hyperrectangles, volume-based):
box_training - EL++ ontology (subsumption + roles):
el_training
- Real-scale (252 entities, Tiny ImageNet synsets):
-
Want to benchmark all geometry types on a small hierarchy? Start with
geometry_comparison(~0.4s, no data download required). -
Want to train ball embeddings on WN18RR?
- Per-triple SGD (no extra features required):
wn18rr_ball - Batched training via Burn (
--features burn-wgpu,kgeor--features burn-ndarray,kge):wn18rr_ball_burn
- Per-triple SGD (no extra features required):
-
Want to run the full WN18RR benchmark?
- CPU ndarray (boxes):
wn18rr_training
- CPU ndarray (boxes):
-
Want to benchmark EL++ on GALEN/GO/Anatomy? Start with
el_benchmark(ndarray) orel_benchmark_burn(Burn). Both require dataset files indata/. -
Want to compare region geometries behind one interface? Start with
region_generic. -
Want to move graph or ontology data into subsume? Use
petgraph_adapterfor in-process directed graphs orlattix_bridgefor RDF-style knowledge graphs. -
Want to serve trained region embeddings? Start with
taxobell_precinct, which indexes TaxoBell boxes in precinct. -
Want to see TaxoBell losses without training? Start with
taxobell_demo.
cargo run -p subsume --example containment_hierarchy
cargo run -p subsume --example gumbel_box_exploration
cargo run -p subsume --example cone_training --release
cargo run -p subsume --example box_training --release
cargo run -p subsume --example query2box
cargo run -p subsume --example octagon_demo
cargo run -p subsume --example taxobell_demo
cargo run -p subsume --example dataset_training --release
cargo run -p subsume --example save_checkpoint
cargo run -p subsume --example imagenet_hierarchy --release
cargo run -p subsume --features hyperbolic --example hyperbolic_demo
cargo run -p subsume --example el_training --release
cargo run -p subsume --features density,rand --example density_el_demo --release
cargo run -p subsume --example el_benchmark --release -- data/GALEN
cargo run -p subsume --features burn-wgpu --example el_benchmark_burn --release
cargo run -p subsume --features burn-wgpu --example el_clqa_trained --release
cargo run -p subsume --features burn-wgpu --example el_clqa_benchmark --release
cargo run -p subsume --features burn-wgpu --example el_clqa_galen --release
cargo run -p subsume --example gene_ontology --release
cargo run -p subsume --example geometry_comparison --release
cargo run -p subsume --features kge --example lattix_bridge
cargo run -p subsume --features petgraph --example petgraph_adapter
cargo run -p subsume --example region_generic
cargo run -p subsume --features burn-ndarray,kge --example taxobell_box_uncertainty --release
cargo run -p subsume --features burn-ndarray,kge --example taxobell_precinct --release
cargo run -p subsume --example wn18rr_ball --release
cargo run -p subsume --features burn-wgpu,kge --example wn18rr_ball_burn --release
cargo run -p subsume --features burn-wgpu,kge --example wn18rr_box_burn --release
cargo run -p subsume --features burn-wgpu,kge --example wn18rr_cone_burn --release
cargo run -p subsume --features burn-wgpu,kge --example wn18rr_geometry_comparison_burn --release
cargo run -p subsume --features burn-wgpu,kge --example wn18rr_transbox_burn --release
cargo run -p subsume --example wn18rr_training --releaseFor the real-ontology CLQA benchmark, use the harness:
scripts/run_clqa_eval.sh boxIt writes a metrics CSV under target/clqa-eval/ and exits successfully with a
message when the Box2EL dataset files are absent. See docs/CLQA_EVAL.md.
Each example below shows actual output from a single run.
containment_hierarchy -- box geometry basics
=== Box Embeddings: Containment Hierarchy ===
--- Volumes (larger = more general) ---
animal: volume = 1.0000
mammal: volume = 0.7290
dog: volume = 0.0270
cat: volume = 0.0480
fish: volume = 0.0048
--- Containment P(row inside col) ---
animal mammal dog cat fish
animal 1.000 0.729 0.027 0.048 0.005
mammal 1.000 1.000 0.037 0.066 0.000
dog 1.000 1.000 1.000 0.000 0.000
cat 1.000 1.000 0.000 1.000 0.000
fish 1.000 0.000 0.000 0.000 1.000
--- Overlap (intersection volume / union volume) ---
animal mammal dog cat fish
animal 1.000 0.729 0.027 0.048 0.005
mammal 0.729 1.000 0.037 0.066 0.000
dog 0.027 0.037 1.000 0.000 0.000
cat 0.048 0.066 0.000 1.000 0.000
fish 0.005 0.000 0.000 0.000 1.000
--- Volume ratios (generality) ---
animal / mammal = 1.4x
mammal / dog = 27.0x
animal / dog = 37.0x
--- Key relationships (computed) ---
P(dog in mammal) = 1.0000, P(mammal in animal) = 1.0000, P(dog in animal) = 1.0000
-> Transitive containment: dog inside mammal inside animal
overlap(dog, cat) = 0.0000, overlap(cat, dog) = 0.0000
-> Low overlap: dog and cat occupy different regions
P(fish in mammal) = 0.0000, P(fish in animal) = 1.0000
-> Fish is inside animal but outside mammal (different sub-hierarchy)
P(animal in dog) = 0.0270
-> The dog box covers 2.7% of the animal box.
gumbel_box_exploration -- Gumbel temperature and soft membership
=== Gumbel Box Embeddings: Probabilistic Containment ===
--- Temperature effect on membership probability ---
At low temperature (t=0.01, hard boxes): P(center in animal) = 1.0000
At high temperature (t=1.00, soft boxes): P(center in animal) = 0.0582
(Low temp recovers the intuitive ~1.0; high temp spreads probability mass.)
--- Part 1: Gumbel boxes created ---
animal: dim=3, temp=1.00, volume=0.2371
mammal: dim=3, temp=1.00, volume=0.1891
dog: dim=3, temp=1.00, volume=0.0446
vehicle: dim=3, temp=1.00, volume=0.2371
--- Part 2: Soft containment probabilities ---
P(dog inside animal) = 0.0549 (dog IS-A animal; <1 due to temp=1.0 softening)
P(dog inside mammal) = 0.0488 (dog IS-A mammal; <1 due to temp=1.0 softening)
P(mammal inside animal) = 0.0337 (mammal IS-A animal; <1 due to temp=1.0 softening)
P(animal inside dog) = 0.0103 (should be < P(dog|animal): animal is NOT a dog)
P(dog inside vehicle) = 0.0028 (should be ~0.0: dog is NOT a vehicle)
--- Part 3: Temperature effect on containment ---
temperature P(dog|animal) P(dog|vehicle)
------------------------------------------------------
0.01 0.999995 0.000000
0.10 0.650159 0.000000
0.50 0.109745 0.000021
1.00 0.054885 0.002848
2.00 0.035328 0.015144
5.00 0.026238 0.022753
10.00 0.023628 0.022793
100.00 0.021449 0.021441
--- Part 4: Point membership probability ---
point P(in animal) P(in dog)
--------------------------------------------------------------
center (0.5,0.5,0.5) 0.058166 0.023001
inside dog (0.2,0.2,0.2) 0.054600 0.024050
boundary (0.0,0.0,0.0) 0.048839 0.023001
outside (5.0,5.0,5.0) 0.000006 0.000001
--- Part 5: Temperature sharpens membership ---
temperature P(boundary_pt in animal)
---------------------------------------
0.01 0.125000
0.10 0.124983
0.50 0.085416
1.00 0.048839
5.00 0.020778
100.00 0.018086
Key takeaways:
- Gumbel boxes compute soft containment: gradients flow even for disjoint boxes
- Low temperature -> sharp boundaries (good for final predictions)
- High temperature -> smooth gradients (good for early training)
- Temperature annealing: start high, decrease during training
- Reference: Dasgupta et al. (2020), NeurIPS 2020
octagon_demo -- octagon embeddings with diagonal constraints
=== Octagon Embeddings Demo ===
Part 1: Octagon vs Box
Bounding box [0,4]x[0,4] volume: 16.00
Octagon volume (with diagonal cuts): 8.00
Ratio: 50.0% -- the diagonal constraints remove 50.0% of the box area
Part 2: Point containment
(2.0, 2.0) center: INSIDE
(0.1, 0.1) corner (0.1, 0.1) -- inside box, outside octagon: outside
(1.0, 1.5) off-center (1.0, 1.5): INSIDE
(3.5, 3.5) near corner (3.5, 3.5) -- x+y=7 > 6: outside
(0.0, 2.0) edge (0.0, 2.0) -- x+y=2, x-y=-2: INSIDE
Part 3: Intersection (closure property)
Octagon A: axis [0,3]x[0,3], volume=7.00
Octagon B: axis [1,4]x[1,4], volume=4.00
Intersection: axis [1,3]x[1,3], volume=2.00
Volume ratio: 28.6% of A, 50.0% of B
Part 4: Soft containment and overlap probabilities
P(wide contains narrow) = 0.5597 (should be high)
P(narrow contains wide) = 0.0000 (should be low)
P(overlap) = 0.9998 (should be high)
Part 5: Bounding box (drop diagonal constraints)
Original octagon: axis [0,4]x[0,4] with diagonal cuts
Bounding box: [0,4]x[0,4] (outer approximation)
--- Summary ---
Octagons are strictly more expressive than boxes:
- Any box is an octagon with vacuous diagonal constraints
- Diagonal cuts remove unreachable corners, improving fit
- Closed under intersection: composing relations stays in the octagon domain
- O(d) storage: 2d axis bounds + 4(d-1) diagonal bounds
query2box -- compositional multi-hop query answering
=== Query2Box: Compositional Query Answering ===
Q1: What cities are in France?
Rank by P(France contains city):
1: Paris score=1.0000 <-- answer
2: Lyon score=1.0000 <-- answer
3: London score=0.0000
Q2: What languages are spoken in France?
Rank by P(France contains language):
1: French score=1.0000 <-- answer
2: English score=0.0000
Q3: Languages spoken in countries with French cities (2-hop)
Hop 1: intersect France with city-containing region
intersection volume: 0.1409 (> 0 confirms France has cities)
Hop 2: rank languages by containment in hop-1 result
Rank by P(hop1_box contains language):
1: French score=1.0000 <-- answer
2: English score=0.0000
Q4: Alpha-weighted distance scoring (Ren et al., 2020)
alpha = 0.02 (inside penalty << outside penalty)
Q1 re-scored: cities in France (by distance, ascending)
1: Lyon dist=0.0188 <-- answer
2: Paris dist=0.0424 <-- answer
3: London dist=8.0970
Q2 re-scored: languages in France (by distance, ascending)
1: French dist=0.0212
2: English dist=8.9910
Alpha sensitivity: distance for Paris across alpha values
alpha=0.00: dist=0.0000
alpha=0.02: dist=0.0424
alpha=0.10: dist=0.2120
alpha=0.50: dist=1.0600
alpha=1.00: dist=2.1200
--- Summary ---
Q1 correctly ranks Paris and Lyon above London.
Q2 ranks French highest (fully inside France).
Q3 chains two hops: city containment, then language containment.
Intersection volume decreases at each hop, narrowing the answer set.
Q4 shows Query2Box distance scoring: lower distance = better answer.
Alpha controls inside-vs-outside penalty balance.
taxobell_demo -- Gaussian box losses (no training)
=== TaxoBell: Gaussian Box Embeddings for Taxonomy Expansion ===
--- Part 1: Taxonomy nodes (dim=8) ---
concept log-volume sigma[0]
------------------------------------
entity 11.0904 4.0000
animal 5.5452 2.0000
vehicle 5.5452 2.0000
dog -5.5452 0.5000
cat -5.5452 0.5000
car -5.5452 0.5000
truck -5.5452 0.5000
--- Part 2: KL divergence (child -> parent containment) ---
child parent D_KL interpretation
-------------------------------------------------------
animal entity 2.7952 partial containment
vehicle entity 4.7952 partial containment
dog animal 7.5904 poor containment
cat animal 7.5904 poor containment
car vehicle 7.5904 poor containment
truck vehicle 7.5904 poor containment
Asymmetry: D_KL(dog||animal) = 7.5904, D_KL(animal||dog) = 52.9096
dog fits in animal (small KL), but animal does NOT fit in dog (large KL)
Cross-domain: D_KL(dog||vehicle) = 27.5904 (no containment)
--- Part 3: Bhattacharyya coefficient (symmetric similarity) ---
concept_a concept_b BC relationship
--------------------------------------------------
dog cat 0.018316 some overlap
car truck 0.018316 some overlap
dog car 0.000000 near-disjoint
animal vehicle 0.018316 some overlap
--- Part 4: TaxoBell combined loss ---
L_sym (symmetric triplet) = 4.014859
L_asym (KL containment) = 5.868443
L_reg (volume regulation) = 0.000000
L_clip (sigma clipping) = 0.857143
Total = 1.00*4.0149 + 1.00*5.8684 + 0.01*0.0000 + 0.01*0.8571
= 9.891873
Key takeaways:
- KL divergence is asymmetric: it measures directed containment (child in parent)
- Bhattacharyya coefficient is symmetric: it measures distributional overlap
- TaxoBell combines both with regularization for end-to-end taxonomy training
- Wider sigmas = more general concepts; narrower sigmas = more specific
- Reference: TaxoBell (WWW 2026, arXiv:2601.09633)
hyperbolic_demo -- Poincare ball embeddings
=== Poincare Ball Embeddings: Biological Taxonomy ===
--- Norm by depth (general near origin, specific near boundary) ---
entity depth norm conformal
Life 0 0.0000 2.0000
Animalia 1 0.3000 2.1978
Plantae 1 0.3000 2.1978
Fungi 1 0.3000 2.1978
Carnivora 2 0.6000 3.1250
Primates 2 0.6000 3.1250
Rosales 2 0.6000 3.1250
Poales 2 0.6000 3.1250
Agaricales 2 0.6000 3.1250
Wolf 3 0.8800 8.8652
Lion 3 0.8800 8.8652
Human 3 0.8800 8.8652
Chimp 3 0.8800 8.8652
Rose 3 0.8800 8.8652
Wheat 3 0.8800 8.8652
Amanita 3 0.8800 8.8652
Conformal factor = 2/(1 - ||x||^2). Grows sharply near the boundary,
meaning a small coordinate shift near the boundary covers much more
hyperbolic distance than the same shift near the origin.
--- Selected pairwise hyperbolic distances ---
Life -> Animalia (depth 0->1) d = 0.6190
Animalia -> Carnivora (depth 1->2) d = 0.7835
Carnivora -> Wolf (depth 2->3) d = 1.3846
Wolf <-> Lion (siblings) d = 1.0433
Wolf <-> Human (cross-order) d = 1.9878
Wolf <-> Rose (cross-kingdom) d = 5.3872
Human <-> Chimp (siblings) d = 1.0433
Life -> Amanita (root to leaf) d = 2.7515
--- Hierarchy preservation: 100.0% (15/15 parent-child pairs correct) ---
--- Exponential capacity: distance from origin by depth ---
depth norm d(origin,p) ratio
0 0.0000 0.0000 -
1 0.3000 0.6190 -
2 0.6000 1.3863 2.24x
3 0.8800 2.7515 1.98x
Distance-to-origin grows faster than linearly with norm because the
hyperbolic metric inflates near the boundary: d = 2 * arctanh(||x||).
This is the exponential capacity that lets trees embed without distortion.
Key observations:
- All parent-child norm orderings are satisfied (hierarchy preserved)
- Cross-kingdom distances (Wolf<->Rose) exceed within-order distances (Wolf<->Lion)
- Hyperbolic distance from origin accelerates with depth, encoding exponential
branching capacity in bounded coordinates
cone_training -- cone embeddings on an 18-entity taxonomy
=== Cone Embeddings (ConE): Training on a Taxonomy (18 entities, 4 levels) ===
Training for 500 epochs (50 warmup + 450 joint, dim=16, 18 entities, 17 pos + 29 neg pairs)...
Epoch 0 [warmup]: avg_loss = 0.0192
Epoch 125 [joint]: avg_loss = 0.0678
Epoch 250 [joint]: avg_loss = 0.0639
Epoch 375 [joint]: avg_loss = 0.0648
Epoch 499 [joint]: avg_loss = 0.0649
--- Learned Cone Properties ---
entity mean_aper mean_deg
----------------------------------------
entity 3.0610 175.4
animal 2.5595 146.6
vehicle 2.5235 144.6
mammal 2.1850 125.2
bird 1.5128 86.7
fish 1.2583 72.1
land_vehicle 1.7302 99.1
aircraft 0.8409 48.2
dog 0.0777 4.4
cat 0.1512 8.7
whale 0.1380 7.9
eagle 0.0846 4.8
sparrow 0.2093 12.0
salmon 0.0767 4.4
tuna 0.1543 8.8
car 0.0665 3.8
truck 0.2899 16.6
helicopter 0.2095 12.0
--- Selected Containment Distances (lower = better containment) ---
[POS] entity > animal dist = 0.1324
[POS] entity > vehicle dist = 0.2503
[POS] animal > mammal dist = 0.1163
[POS] animal > bird dist = 0.2217
[POS] mammal > dog dist = 0.1396
[POS] mammal > cat dist = 0.2195
[POS] bird > eagle dist = 0.1114
[POS] fish > salmon dist = 0.1318
[POS] land_vehicle > car dist = 0.1142
[POS] aircraft > helicopter dist = 0.0568
[NEG] dog > entity (reverse) dist = 14.3115
[NEG] dog > cat (sibling) dist = 13.9929
[NEG] animal > vehicle (cross) dist = 0.4439
[NEG] mammal > land_vehicle (cross) dist = 1.4487
Avg positive distance: 0.1494, Avg negative distance: 7.5492
Positive pairs have lower distance than negatives (as expected).
Key takeaways:
- More general concepts (entity, animal) get wider mean apertures
- More specific concepts (dog, car) get narrower mean apertures
- Containment is directional: animal > mammal, but NOT mammal > animal
- Cross-branch distance (animal > vehicle) stays high
- Unlike boxes, cones support negation: complement of a cone is a cone
box_training -- direct coordinate training on 25-entity taxonomy
=== Box Embedding Training (25 entities, direct coordinate updates) ===
Entities: 25
Containment pairs: 24
Training for 300 epochs (dim=8, lr=0.05, neg_lr=0.04)...
Epoch 0: total_violation = 34.9070
Epoch 50: total_violation = 3.8661
Epoch 100: total_violation = 1.7840
Epoch 150: total_violation = 1.4926
Epoch 200: total_violation = 1.3762
Epoch 250: total_violation = 1.2435
Epoch 299: total_violation = 1.1112
--- Learned Box Volumes (larger = more general) ---
entity: volume = 2.401828e4
vehicle: volume = 6.491940e2
car: volume = 5.161266e1
truck: volume = 5.140411e1
bicycle: volume = 5.140404e1
animal: volume = 2.756642e1
plant: volume = 6.517150e0
mammal: volume = 5.015008e-1
bird: volume = 3.474687e-1
tree: volume = 2.028825e-1
flower: volume = 2.028822e-1
fish: volume = 1.978809e-1
salmon: volume = 1.235360e-3
tuna: volume = 1.235357e-3
oak: volume = 1.235354e-3
pine: volume = 1.235352e-3
rose: volume = 1.235350e-3
tulip: volume = 1.235348e-3
eagle: volume = 1.179650e-3
penguin: volume = 1.161592e-3
sparrow: volume = 1.161585e-3
bat: volume = 1.108423e-3
cat: volume = 1.091402e-3
dog: volume = 1.056696e-3
whale: volume = 1.038240e-3
--- Containment Checks ---
[ OK] entity > animal P = 1.000
[ OK] entity > vehicle P = 1.000
[ OK] animal > mammal P = 1.000
[ OK] animal > bird P = 1.000
[ OK] mammal > dog P = 1.000
[ OK] mammal > cat P = 1.000
[ OK] bird > eagle P = 1.000
[ OK] fish > salmon P = 1.000
[ OK] plant > tree P = 1.000
[ OK] tree > oak P = 1.000
[ OK] flower > rose P = 1.000
[ OK] vehicle > car P = 0.875
[ OK] dog > animal (reverse) P = 0.000
[ OK] cat > dog (sibling) P = 0.000
[ OK] animal > vehicle (cross) P = 0.000
Hierarchy accuracy: 15/15 (100%)
Notes:
- This uses direct coordinate updates, not backpropagation
- Negative separation pushes sibling/cross-branch boxes apart
- Leaf shrinkage produces varied volumes (more specific = smaller)
- Volume ordering (general > specific) emerges from containment constraints
dataset_training -- WN18RR-format pipeline with MRR/Hits@k
=== Dataset-Driven Box Embedding Training (BoxEmbeddingTrainer) ===
First training example: canine.n.02 contains dog.n.01
Dataset: 47 entities, 1 relations, 46 train / 7 valid / 7 test triples
Training up to 200 epochs (dim=12, 46 train triples, early stopping patience=30)...
Early stopping filters other answers observed in train or validation.
Trained 81 epochs (best epoch: 50)
Loss: 4.8178 -> 0.0339
Val MRR: 0.1585 -> 0.6071
--- Evaluation (test set, filtered) ---
MRR: 0.7321
Head MRR: 0.9286
Tail MRR: 0.5357
Hits@1: 0.5714
Hits@3: 0.7857
Hits@10: 1.0000
Mean Rank: 1.9
Rank each head and tail against the 47-entity vocabulary (14 ranks).
Higher scores mean more of the tail lies inside the relation-translated head.
Exact ties rank by ascending entity name.
Test filtering removes other answers observed in train, validation or test.
--- Per-Relation Breakdown ---
has_hyponym: MRR=0.7321, Hits@10=1.0000 (7 triples)
Checkpoint: 62467 bytes (serialized 47 entity boxes + optimizer state)
Checkpoint round-trip: OK (47 entities restored)
imagenet_hierarchy -- 252 Tiny ImageNet synsets, volume-depth correlation
=== Tiny ImageNet Hierarchy: Box Embedding Training ===
Hierarchy: 252 entities (114 leaves, 138 internal), depth 12, 251 edges
Training 400 epochs (dim=16, lr=0.06, 251 containment, 470 negative pairs)...
... (training output truncated, showing final results)
epoch 399: total_violation = 17.5900
--- Evaluation (held-out transitive hypernym triples) ---
MRR: 0.3291
Hits@1: 0.0938
Hits@3: 0.4688
Hits@10: 1.0000
Mean Rank: 4.5
(32 test triples, 252 candidate entities)
--- Volume-Depth Correlation ---
depth count avg_log_vol
----- ------ ------------
0 1 29.38
1 5 14.66
2 15 7.15
3 40 1.39
4 55 -3.80
5 45 -10.47
6 28 -18.99
7 19 -26.28
8 13 -28.90
9 14 -47.49
10 6 -31.32
11 9 -72.14
12 2 -64.82
Spearman(depth, log_volume) = -0.9555 (n=252)
-> Negative correlation confirms: specific concepts have smaller boxes.
--- Volume Extremes ---
Largest boxes (most general):
entity depth=0 log_vol=29.38
organism depth=1 log_vol=23.69
animal depth=2 log_vol=19.29
artifact depth=1 log_vol=17.05
chordate depth=3 log_vol=13.91
Smallest boxes (most specific):
cougar depth=11 log_vol=-86.14
lion depth=11 log_vol=-86.08
tabby_cat depth=11 log_vol=-82.38
Persian_cat depth=11 log_vol=-81.98
Egyptian_cat depth=11 log_vol=-81.85
252 total entities trained
el_training -- EL++ ontology embedding training
=== EL++ Ontology Embedding Training ===
Ontology: 15 concepts, 4 roles, 21 axioms
Training with dim=30, epochs=500...
epoch 50/500: avg_loss = 1.946908, lr = 0.004960, |c|=0.433, o_avg=0.348, o_range=[0.010, 1.331]
epoch 100/500: avg_loss = 0.959389, lr = 0.004706, |c|=0.381, o_avg=0.269, o_range=[0.010, 1.345]
epoch 150/500: avg_loss = 0.685724, lr = 0.004245, |c|=0.358, o_avg=0.239, o_range=[0.010, 1.345]
epoch 200/500: avg_loss = 0.807297, lr = 0.003625, |c|=0.348, o_avg=0.221, o_range=[0.010, 1.345]
epoch 250/500: avg_loss = 0.565984, lr = 0.002912, |c|=0.343, o_avg=0.213, o_range=[0.010, 1.345]
epoch 300/500: avg_loss = 0.632636, lr = 0.002182, |c|=0.338, o_avg=0.208, o_range=[0.010, 1.345]
epoch 350/500: avg_loss = 0.625155, lr = 0.001512, |c|=0.336, o_avg=0.206, o_range=[0.010, 1.345]
epoch 400/500: avg_loss = 0.574665, lr = 0.000974, |c|=0.334, o_avg=0.206, o_range=[0.010, 1.345]
epoch 450/500: avg_loss = 0.602590, lr = 0.000624, |c|=0.334, o_avg=0.206, o_range=[0.010, 1.345]
epoch 500/500: avg_loss = 0.578887, lr = 0.000500, |c|=0.333, o_avg=0.205, o_range=[0.010, 1.345]
Loss: 5.2844 (epoch 1) -> 0.5789 (epoch 500)
eval sample: sub=0 sup=1 correct_score=0.7561 min=0.7561 median=2.0532 max=2.3169
eval sample: sub=2 sup=1 correct_score=0.7365 min=0.7365 median=2.7294 max=3.7536
eval sample: sub=3 sup=1 correct_score=0.6522 min=0.6522 median=2.4338 max=3.4445
Subsumption prediction (on training axioms):
Hits@1: 0.31
Hits@10: 1.00
MRR: 0.5591
--- Spot checks (lower = better containment) ---
Dog ⊑ Mammal: 0.7561 (SHOULD be low)
Dog ⊑ Animal: 1.8465 (SHOULD be low)
Dog ⊑ LivingThing: 1.9577 (SHOULD be low)
Dog ⊑ Cat: 1.2252 (SHOULD be high)
Mammal ⊑ Fish: 3.8667 (SHOULD be high)
Animal ⊑ Plant: 5.5494 (SHOULD be high)
Eagle ⊑ Bird: 0.2841 (SHOULD be low)
Salmon ⊑ Fish: 0.2483 (SHOULD be low)
Saved TrainedElModel to /tmp/subsume_el_demo.json (30.7 KB)
Loaded: 15 concepts, 4 roles, dim=30
--- Name-based lookup (via TrainedElModel) ---
Dog ⊑ Mammal: 0.7561
Dog ⊑ Animal: 1.8465
Dog ⊑ LivingThing: 1.9577
Dog ⊑ Cat: 1.2252
Mammal ⊑ Fish: 3.8667
Animal ⊑ Plant: 5.5494
Eagle ⊑ Bird: 0.2841
Salmon ⊑ Fish: 0.2483
The scripts/ directory contains Python plotting scripts (PEP 723, run with uv run):
scripts/plot_box_concept.py-- generatesdocs/box_concepts.png(containment and the Gumbel soft boundary)scripts/plot_training.py-- generatesdocs/training_convergence.png(loss curve + containment probability convergence)scripts/plot_gumbel_robustness.py-- generatesdocs/gumbel_robustness.png(gradient landscape: Gumbel membership + gradient magnitude at box boundary)scripts/plot_temperature_sensitivity.py-- generatesdocs/temperature_sensitivity.png(containment probability vs Gumbel temperature)scripts/plot_fuzzy_tnorms.py-- generatesdocs/fuzzy_tnorms.png(t-norm contour plots and 1D slices)