Skip to main content

Graph Attention Engine (GAE)

Graph Attention Engine is a standalone, NumPy-only scoring engine that implements Cross-Graph Attention for domain-independent decision systems. It is pure Python and requires no database, network access, or event loop. GAE is licensed under Apache 2.0.

Install

Install the published package:

pip install graph-attention-engine

For editable development installs:

pip install -e ".[dev]"

Quick Start

Scaled dot-product attention

import numpy as np
from gae import scaled_dot_product_attention

rng = np.random.default_rng(7)
Q = rng.normal(size=(4, 8))
K = rng.normal(size=(6, 8))
V = rng.normal(size=(6, 16))

out, weights = scaled_dot_product_attention(Q, K, V)

assert out.shape == (4, 16)
assert weights.shape == (4, 6)

Profile scoring

ProfileScorer compares a factor vector with category-specific action centroids. The convenience factory accepts named categories and actions:

import numpy as np
from gae import ProfileScorer, build_profile_scorer

categories = ["routine", "critical"]
actions = ["accept", "review", "escalate"]

# Shape: (2 categories, 3 actions, 4 factors)
mu = np.array(
    [
        [
            [0.2, 0.2, 0.1, 0.2],
            [0.5, 0.4, 0.5, 0.4],
            [0.8, 0.8, 0.9, 0.8],
        ],
        [
            [0.1, 0.2, 0.2, 0.1],
            [0.5, 0.6, 0.5, 0.6],
            [0.9, 0.9, 0.8, 0.9],
        ],
    ],
    dtype=np.float64,
)

centroids = {
    category: {
        action: mu[category_index, action_index].tolist()
        for action_index, action in enumerate(actions)
    }
    for category_index, category in enumerate(categories)
}

scorer: ProfileScorer = build_profile_scorer(
    categories=categories,
    actions=actions,
    centroids=centroids,
    n_factors=4,
)
result = scorer.score(np.array([0.85, 0.90, 0.80, 0.90]), category_index=1)

print(result.action_index)
print(result.confidence)
print(result.probabilities)

The returned ScoringResult contains the recommended action_index, action_name, calibrated confidence, full probabilities, distances, entropy, and confidence gap.

Core API

Core Scoring

API Description
ProfileScorer Scores factor vectors against category and action centroids.
ScoringResult Contains the recommendation, confidence, probabilities, and diagnostics.
KernelType Selects the distance kernel used for scoring.
build_profile_scorer Builds a scorer from named categories, actions, and centroid mappings.

Oracle

API Description
OracleProvider Protocol for producing independent ground-truth outcomes.
GTAlignedOracle Returns outcomes aligned with supplied ground truth.
BernoulliOracle Samples deterministic-seeded Bernoulli outcomes.

Evaluation

API Description
EvaluationScenario Defines one scored evaluation case and expected action.
compute_ece Computes expected calibration error.
run_evaluation Evaluates a scorer across a scenario collection.

Judgment

API Description
compute_judgment Converts a scoring result into an explained judgment.
CONFIDENCE_HIGH Threshold for high-confidence judgments.
CONFIDENCE_MEDIUM Threshold for medium-confidence judgments.

Calibration

API Description
CalibrationProfile Holds scoring and learning calibration parameters.
compute_theta_min Computes the deployment-aware conservation threshold.

Primitives

API Description
scaled_dot_product_attention Computes scaled dot-product attention and its weights.
softmax Computes a numerically stable probability distribution.

Learning

API Description
LearningState Tracks centroids and learning metadata.
WeightUpdate Describes a validated learning update.

Convergence

API Description
get_convergence_metrics Reports centroid movement and convergence diagnostics.

Kernels

API Description
L2Kernel Computes standard squared Euclidean distance.
DiagonalKernel Applies per-factor diagonal weights.
CovarianceEstimator Estimates covariance for adaptive distance calculations.
KernelSelector Recommends a kernel from observed data properties.

Persistence

API Description
save_state Saves learning state to JSON.
load_state Loads learning state from JSON.

The complete public export list is available in gae/__init__.py.

Conservation Law

GAE checks the constraint alpha * q * V >= theta_min, combining category coverage (alpha), observed quality (q), and verified volume (V). Meeting the threshold provides the operational guarantee that evidence is sufficient to maintain accuracy above the configured boundary; use compute_theta_min to derive the deployment-aware threshold.

Testing

pytest tests/ -v

The current suite contains 1,244 passing tests.

Documentation

License

Apache 2.0. See the LICENSE file.

Metadata

Release files for graph-attention-engine 0.7.25

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graph-attention-engine 0.7.25
File Size Uploaded Provenance Actions
graph_attention_engine-0.7.25.tar.gz 233.0 kB Without provenance Details for graph_attention_engine-0.7.25.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for graph-attention-engine 0.7.25
File Interpreter ABI Platform Actions
graph_attention_engine-0.7.25-py3-none-any.whl Python 3 none any Details for graph_attention_engine-0.7.25-py3-none-any.whl

Total release size: 352.9 kB

Release files / graph_attention_engine-0.7.25.tar.gz

Download URL graph_attention_engine-0.7.25.tar.gz
Size 233.0 kB
Tags Source
SHA-256 checksum
How to use checksums
01fdbc50b398430147e2886b7a8f75ae1da4b860aa6ac0d78e3958382bb2a047
BLAKE2b-256 checksum
How to use checksums
43bad2b78c10d06f840393a50e6234296f13ba1e834973ed7892873772ffd759
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4

Release files / graph_attention_engine-0.7.25-py3-none-any.whl

Download URL graph_attention_engine-0.7.25-py3-none-any.whl
Size 119.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76dc7d014bcd8401a69fc7220387a0f15e0df5451cc8b069816fa159a73c9edb
BLAKE2b-256 checksum
How to use checksums
9b04dab8054de4af0c5db13e83c791e48c07cfd0a26471d016657a93e91b1914
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4

Security for graph-attention-engine 0.7.25

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page