Skip to main content

India's first granular AI ethics framework for RTI applications (36 metrics, 9 dimensions)

Project description

RTI Ethics Engine

India's first granular AI ethics framework for RTI applications - A production-ready Python package implementing 36 metrics across 9 ethical dimensions with granular formula access.

Python 3.9+ License: MIT

🚀 Installation

pip install rti-ethics-engine

Or install from source:

git clone https://github.com/rti-ethics/rti-ethics-engine.git
cd rti-ethics-engine
pip install -e .

⚡ Quick Start

from rti_ethics_engine import evaluate

# Define your metrics
metrics = {
    "fairness": {"spd": 0.02, "di": 1.0, "eop": 0.05, "aod": 0.03},
    "drift": {"psi": 0.1, "ks": 0.02},
    "legal": {"lawfulness": 1.0, "cvr": 0.98},
    "performance": {"accuracy": 0.92, "recall": 0.88},
    "explainability": {"confidence": 0.85, "fi": 0.3},
    "security": {"adv_acc": 0.8, "pisr": 0.02},
    "monitoring": {"alc": 0.98, "sla": 0.995},
    "ux": {"tcr": 0.92, "ftr": 0.08},
    "environmental": {"inf_cost": 0.02, "gpu_hours": 0.05}
}

# Evaluate
result = evaluate(metrics)

# Get the decision
print(result.final_label)    # "ETHICAL"
print(result.s_llm)          # 0.9234 (LLM Ethics Score)
print(result.risk_band)      # "LOW"

🎯 Granular Metric Access

The killer feature - access ANY formula value at ANY layer:

# Access specific L1 formula values
spd = result.get_l1_metric("fairness", "spd")      # 0.02
psi = result.get_l1_metric("drift", "psi")         # 0.1
accuracy = result.get_l1_metric("performance", "accuracy")  # 0.92

# Access L2 risk scores
fairness_risk = result.get_l2_risk("fairness")     # 0.12
legal_risk = result.get_l2_risk("legal")           # 0.00

# Access L3 forensic evidence
explanation = result.get_l3_evidence("legal")["explanation"]

# Aggregation helpers
failed_dims = result.get_failed_dims()   # ["Legal Compliance"]
pass_rate = result.l1_pass_rate()        # 0.889 (8/9 passed)

# Audit table for CIC compliance
result.print_audit_table()
# RTI-2026035174555 | ETHICAL | S_LLM=0.92
# ✅ Legal Compliance: L2=0.02
# ✅ Bias & Fairness: L2=0.05
# ...

📊 9 Ethical Dimensions

Dimension L1 Metrics Description
Legal Compliance lawfulness, cvr RTI Act 2005 alignment
Bias & Fairness spd, di, eop, aod Demographic equity
Explainability confidence, fi Model interpretability
Security adv_acc, pisr Adversarial robustness
Monitoring alc, sla Audit trail integrity
Performance accuracy, recall Statistical accuracy
Human-AI UX tcr, ftr User friction
Drift psi, ks Model stability
Environmental inf_cost, gpu_hours Carbon footprint

🏗️ Architecture

rti_ethics_engine/
├── __init__.py      # Public API
├── config.py        # Thresholds & weights
├── dimensions.py    # 9 dimension evaluators
├── core.py          # EthicsEngine orchestrator
├── results.py       # EthicsResult with accessors
└── metrics.py       # Computation helpers

📖 API Reference

evaluate(metrics: dict) -> EthicsResult

Quick evaluation entrypoint.

EthicsEngine

Full engine with run_protocol() method.

EthicsResult

Result object with:

  • final_label: "ETHICAL" / "CONDITIONALLY_ETHICAL" / "UNETHICAL"
  • s_llm: LLM Ethics Score [0, 1]
  • risk_band: "LOW" / "MEDIUM" / "HIGH" / "CRITICAL"
  • get_l1_metric(dim, metric): Access any L1 formula value
  • get_l2_risk(dim): Get dimension risk score
  • get_l3_evidence(dim): Get forensic evidence
  • get_failed_dims(): List failed dimensions
  • l1_pass_rate(): Fraction of L1 passes
  • to_json(): Export as JSON

🧪 Testing

pip install -e ".[dev]"
pytest tests/ -v

📄 License

MIT License - See LICENSE for details.

🇮🇳 Made for India

Designed specifically for RTI Act 2005 compliance and CIC audit requirements.

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

rti_ethics_engine-1.0.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

rti_ethics_engine-1.0.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file rti_ethics_engine-1.0.0.tar.gz.

File metadata

  • Download URL: rti_ethics_engine-1.0.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc2

File hashes

Hashes for rti_ethics_engine-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d60a47f8406084cf5e233416240b2d77138c65115ad1a1756bc7c191b136e7d7
MD5 1aca4aefe15054a53695452957fe4945
BLAKE2b-256 71b2fd610774d719a77251ad993fda3ddfe6533924e6e30fd56e4f3d5a960f14

See more details on using hashes here.

File details

Details for the file rti_ethics_engine-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rti_ethics_engine-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30f0bd6c7e6e69212ed50d6bda5e6ec9e246995f44833857bc023fd0f0fbf919
MD5 eae6dc3c20a923b3bdaedaa291c5d9f0
BLAKE2b-256 5a3df3afaa520c39fc496393236d77ac8f5b5b32fcca29f2b3885eb0a6d3438b

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