Skip to content

Polarity Axis Triangulation Visualizations

These Python scripts demonstrate the Polarity Axis Triangulation approach from ADR-058 using matplotlib.

Files

  1. polarity_axis_visualization.py - 3D interactive visualization
  2. Shows polarity pairs as colored spheres
  3. Displays difference vectors between opposing pairs
  4. Visualizes the averaged polarity axis in gold
  5. Interactive sliders to move edge position
  6. Real-time projection calculation

  7. polarity_axis_2d_demo.py - 2D comparison and interactive demo

  8. Side-by-side comparison: Old binary vs New continuous approach
  9. Shows how multiple pairs create a robust axis
  10. Interactive angle slider to explore projections
  11. Clear visualization of grounding percentages

  12. run_demo.py - Simple launcher script

Requirements

pip install numpy matplotlib

Usage

Option 1: Run the launcher

python run_demo.py

Option 2: Run individual scripts

python polarity_axis_visualization.py  # 3D demo
python polarity_axis_2d_demo.py        # 2D demos

Key Concepts Demonstrated

Old Binary Approach (Problems)

  • Forces each edge into either SUPPORTS or CONTRADICTS bucket
  • Results in binary extremes (-100%, 0%, or +100%)
  • Loses nuance due to high similarity between prototypes (81%)

New Polarity Axis Triangulation (Solution)

  1. Multiple Pairs: Uses 5 opposing relationship pairs
  2. SUPPORTS ↔ CONTRADICTS
  3. VALIDATES ↔ REFUTES
  4. CONFIRMS ↔ DISPROVES
  5. REINFORCES ↔ OPPOSES
  6. ENABLES ↔ PREVENTS

  7. Difference Vectors: Calculates vectors from negative to positive pole

  8. Averaging: Averages all difference vectors to find true semantic direction

  9. Projection: Projects edge embeddings onto this axis using dot product

  10. Result: Continuous grounding values that reflect semantic nuance

Interactive Features

3D Visualization

  • Theta/Phi sliders: Move edge position in 3D space
  • Animate button: Rotate the 3D view
  • Mouse drag: Manual camera control (if using interactive backend)

2D Interactive Demo

  • Angle slider: Rotate edge vector around origin
  • Real-time updates: See projection change continuously
  • Color coding: Green (support), Red (contradict), Gray (neutral)

Mathematical Formula

Polarity Axis = normalize(mean([E(p⁺ᵢ) - E(p⁻ᵢ) for all pairs i]))
Grounding = Σ(confidence × dot(edge_embedding, polarity_axis)) / Σ(confidence)

Example Results

Edge Type Old Binary New Projection
MOUNTED_ON +100% or -100% +15% (slightly supportive)
PART_OF +100% or -100% +2% (nearly neutral)
SUPPORTS +100% +85% (strongly supportive)
CONTRADICTS -100% -78% (strongly contradictory)

The new approach provides nuanced, interpretable grounding values instead of misleading binary extremes.