Skip to main content

Constitutional Dynamics: An application for AI alignment analysis using State Transition Calculus principles from the PrincipiaDynamica project

Project description

PrincipiaDynamica 🧭

A research project developing State Transition Calculus (STC) for dynamic AI alignment, featuring the constitutional-dynamics Python package.
PyPI - Version Status PyPI - Python Version PyPI - License


PrincipiaDynamica is a research initiative focused on understanding and ensuring the safety and alignment of advanced AI systems through novel theoretical frameworks and practical tools. At its core is the development of State Transition Calculus (STC), a mathematical formalism for modeling how complex systems, like Large Language Models (LLMs), evolve through different behavioral states over time.

The flagship application of this research is constitutional-dynamics, a Python package (available on PyPI) designed to:

  • Treat AI alignment not as a static score, but as a dynamic trajectory through a vector space representing behavior.
  • Monitor LLM telemetry in real-time or from logs to detect alignment drift, subtle behavioral shifts, and latent potentialities.
  • Leverage STC principles to quantify alignment, stability, and robustness.
  • Provide a framework for analyzing and potentially intervening in these trajectories, including via optimization techniques like QUBO.

TL;DR constitutional-dynamics isn't "yet another" static alignment benchmark. It's an STC-powered toolkit from the PrincipiaDynamica project that treats alignment as a living trajectory—monitored in real time, quantified in both time- and frequency-domains, and (experimentally) optimizable. It aims to provide deeper insights into AI behavior, complementing existing alignment methodologies.


✨ Core Concepts & Features

The constitutional-dynamics package, driven by State Transition Calculus, offers:

  • Dynamic Alignment Tracking:
    • ϕ-alignment scores: Cosine similarity to defined "aligned regions" in embedding space, with exponential memory decay ($\tau$) making scores robust to momentary noise.
    • Δ-transition vectors: Analyzing the direction and magnitude of change between behavioral states.
  • State-Transition Calculus (STC) Primitives:
    • Models latent residual potentialities ($b(a_{res})$) – hidden capacities for behavior that can actualize under specific contexts.
    • Implements (simplified) STC activation functions ($\phi(a_i, t, \dots)$) representing the influence of state components over time.
  • Advanced Behavioral Analysis:
    • Stability Metrics: Including volatility, trend analysis, and an experimental Lyapunov exponent estimate to quantify trajectory stability.
    • Robustness Evaluation: Assessing alignment resilience against simulated perturbations.
    • Power Spectral Density (PSD) Deviation: Frequency-domain analysis to detect anomalous periodic patterns in behavior.
  • Trajectory Optimization (Experimental):
    • A dual-objective cost function $C(t)=\bigl[1-\bar{\phi}(t)\bigr];+;\lambda(t),\text{PSD_distance}(S_x,S_{\text{aligned}})$ to balance immediate alignment with behavioral consistency.
    • QUBO formulation for finding optimal behavioral paths, with integrations for classical and (via dwave-ocean-sdk) quantum-inspired solvers.
  • Live Telemetry Monitoring: Ingests real-time data (e.g., from psutil for system metrics as a proxy for model load/behavior) to track alignment dynamically.
  • Integrations:
    • Graph Databases (Neo4j): For logging and querying state transitions and alignment history.
    • LLM Strategist (Experimental): An LLM-powered component to generate strategic recommendations for realignment.

🧠 The Alignment Thermostat: Integrating with Mechanistic Interpretability (Experimental)

A key research direction within PrincipiaDynamica is the Circuit Tracer Bridge, an experimental integration designed to connect constitutional-dynamics with mechanistic interpretability tools like Anthropic's Circuit Tracer.

The vision is an "Alignment Thermostat" that:

  1. Monitors behavior externally using constitutional-dynamics (the "radar").
  2. Triggers deep mechanistic analysis via Circuit Tracer (the "microscope") when anomalies are detected.
  3. Uses circuit-level insights to inform and apply targeted interventions.
  4. Incorporates a stability-modulated activation (STC v0.2 concept), where the system's Lyapunov exponent estimate directly influences the activation probability ($\phi$) of STC state subsets, allowing for adaptive self-stabilization.

This aims to create a closed-loop system for more robust and proactive alignment. ➡️ Learn more: Circuit Tracer Bridge Conceptual Overview


🚀 Quick Start

Installation

From PyPI:

pip install constitutional-dynamics

Available on PyPI: constitutional-dynamics v0.2.0 (or your latest version)

From source (for development):

git clone https://github.com/FF-GardenFn/principiadynamica.git
cd principiadynamica
pip install -e .                                # Core package
pip install -e ".[dev]"                         # For development (includes test tools)
pip install -e ".[graph,quantum,circuit_tracer]" # For all integration features

Basic Usage Examples

  1. Offline Log Analysis:

    python -m constitutional_dynamics \
      --embeddings path/to/embeddings.json \
      --aligned path/to/aligned_examples.json \
      --output report.json \
      --spectral --steps 5
    
  2. Live System Monitoring (Example):

    python -m constitutional_dynamics --live --interval 1.0
    

(Refer to the full documentation for more examples and API usage.)

📚 Full Documentation

Detailed information, including tutorials, the mathematical framework of STC, and complete API references:

🔮 Roadmap Highlights

Milestone Status Target
constitutional-dynamics v0.2.0 Release June 2025
↳ STC v0.1 Primitives (Activation, Residuals) Included
↳ Dynamic Alignment & Stability Metrics Included
↳ Circuit Tracer Bridge (Prototype & Architecture) 🏗️ Included
↳ MetaStrategist (Conceptual Integration) 💭 Included
STC v0.2: Lyapunov-Modulated Activation 💭 Q3-Q4 2025
Circuit Tracer Bridge: Functional Implementation 🏗️ Q3 2025
LLM MetaStrategist: Full Integration & Testing 🏗️ Q4 2025
Advanced QUBO Solvers & Classical Alternatives Ongoing
Comprehensive Visualization Dashboard (GraphQL API) 💡 v0.3+

Status Legend: 💡 Idea, 💭 Planning, 🏗️ Under Construction/Prototyping, ✨ Implemented/Included, 🧪 Testing, ✅ Released, ⏳ Ongoing/Backlog

Note: This is an indicative roadmap for a research project and subject to change.

Contributing

PrincipiaDynamica is an open research project. Contributions, feedback, and collaborations are welcome, especially in areas of STC development, alignment metrics, mechanistic interpretability integrations, and novel optimization strategies. Please see CONTRIBUTING.md (to be created) or open an issue to discuss.

📜 License & Attribution

  • Code for constitutional-dynamics is licensed under the Apache License 2.0.
  • The theoretical work on State Transition Calculus and PrincipiaDynamica is shared under a spirit of open research.

This project gratefully acknowledges and builds upon inspiring work from the AI safety and interpretability community, including research by Anthropic (e.g., Constitutional AI, Circuit Tracer). Specific citations are provided in relevant documentation.

"In theory there is no difference between theory and practice.
In practice, there is."
— Yogi Berra

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

constitutional_dynamics-0.2.0.tar.gz (129.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

constitutional_dynamics-0.2.0-py3-none-any.whl (149.9 kB view details)

Uploaded Python 3

File details

Details for the file constitutional_dynamics-0.2.0.tar.gz.

File metadata

  • Download URL: constitutional_dynamics-0.2.0.tar.gz
  • Upload date:
  • Size: 129.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for constitutional_dynamics-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9c02e9fb4f32ed8a348a87d8a3824acaf10a7c08c18b3154ecf23c26b9b1f697
MD5 0075142054b9b1fcd7af9d7c9d339eb4
BLAKE2b-256 9a94d4616d53a5fd9aee6d2858f05067585dbfaa0023c0fa090fd7224553a704

See more details on using hashes here.

File details

Details for the file constitutional_dynamics-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for constitutional_dynamics-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1efac34d97f2ca1001ffaf64e888aab1ccc1cc99983d071f188a56a52d1a75f4
MD5 5c5eb95e784da277eeef0022ff093bcc
BLAKE2b-256 a9343b9700ffe6346ffff4f29eb4d6e7886531f5c49e8c1992f5381494135987

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page