Skip to content

About

Systemic Misalignment: Exposing Catastrophic Failures of Surface-Level AI alignment Methods

Resources

Stars

6 stars

Watchers

2 watching

Forks

Repository files navigation

AGI Systemic Misalignment Research Platform

A comprehensive research platform for analyzing "Systemic Misalignment: Failures of Surface-Level AI alignment Methods" - investigating how AI models exhibit bias and potentially harmful outputs across different demographic groups.

Python FastAPI React TypeScript

🎯 Overview

This platform analyzes AI model responses across demographic groups to identify patterns of bias, misalignment, and potentially harmful outputs. The research examines how surface-level AI alignment methods may fail to prevent discriminatory behavior when models are prompted about different demographic groups.

Key Features

  • πŸ“Š Statistical Analysis: Comprehensive alignment and valence scoring across demographic groups
  • πŸ” Interactive Exploration: Search, filter, and analyze thousands of AI model outputs
  • πŸ“ˆ Visualizations: KDE plots, radar charts, bar graphs, and t-SNE embeddings
  • πŸ‘₯ Group Comparisons: Detailed analysis of model behavior across demographics
  • πŸŽ›οΈ Advanced Search: Multi-parameter filtering with keyword search capabilities
  • 🌐 t-SNE Embeddings: Dimensional reduction visualizations for pattern discovery

πŸ—οΈ Architecture

Modern Full-Stack Application

  • Backend: FastAPI with Python 3.11 (strict type checking, comprehensive linting)
  • Frontend: React + TypeScript with Tailwind CSS (enterprise-grade code quality)
  • Data: CSV analysis with pandas, statistical modeling, Plotly visualizations
  • Storage: S3-hosted static assets (KDE plots, t-SNE visualizations) for performance
  • Code Quality: Black, ruff, mypy (backend) + ESLint, Prettier, TypeScript (frontend)

βš™οΈ Configuration

Environment Variables

Backend (optional, defaults provided):

# CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000  # Comma-separated list for production

# Server Configuration
PORT=8000  # Used in Docker deployment

Frontend (create app/.env file):

# API Configuration
REACT_APP_API_URL=http://localhost:8000

Default Values:

  • ALLOWED_ORIGINS: http://localhost:3000 (development)
  • REACT_APP_API_URL: http://localhost:8000 (development backend)

Environment-specific Configuration:

Development:

# Backend
ALLOWED_ORIGINS=http://localhost:3000

# Frontend
REACT_APP_API_URL=http://localhost:8000

Production:

# Backend
ALLOWED_ORIGINS=https://your-frontend-domain.com,https://staging-domain.com

# Frontend
REACT_APP_API_URL=https://your-api-server.com

πŸ“ Project Structure

agi-systemic-misalignment/
β”œβ”€β”€ src/                    # FastAPI backend source
β”‚   β”œβ”€β”€ main.py            # API endpoints and server setup
β”‚   β”œβ”€β”€ data_loader.py     # Data processing and loading
β”‚   β”œβ”€β”€ models.py          # Pydantic data models
β”‚   └── plotting.py        # Visualization generation
β”œβ”€β”€ app/                   # React TypeScript frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # React components
β”‚   β”‚   β”œβ”€β”€ hooks/         # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ types/         # TypeScript type definitions
β”‚   β”‚   └── utils/         # Utility functions
β”‚   β”œβ”€β”€ public/            # Static assets and images
β”‚   └── package.json       # Frontend dependencies
β”œβ”€β”€ data/                  # Research data and analysis results
β”‚   β”œβ”€β”€ misalignment_results/  # CSV files with model outputs
β”‚   └── tsne/                 # t-SNE visualization HTML files
β”œβ”€β”€ API_README.md          # Backend API documentation
β”œβ”€β”€ FRONTEND_README.md     # Frontend development guide
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ requirements-dev.txt   # Development dependencies
└── Makefile              # Development commands

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • pip and npm/yarn/pnpm

Installation

  1. Clone the repository

    git clone <repository-url>
    cd agi-systemic-misalignment
  2. Install all dependencies

    make install

Running the Application

  1. Start the FastAPI backend

    make serve-api
    # Backend available at http://localhost:8000
  2. Start the React frontend (in a new terminal)

    make serve-frontend
    # Frontend available at http://localhost:3000
  3. Access the application

πŸ› οΈ Development

Code Quality & Linting

This project enforces strict code quality standards:

# Run all linting (backend + frontend)
make lint-check          # Check without fixing
make lint               # Fix issues automatically

# Individual components
make lint-backend       # Python: black, ruff, mypy
make lint-frontend      # TypeScript: ESLint, Prettier, tsc

Development Workflow

# Install all dependencies
make install

# Run development servers
make serve-api          # FastAPI with hot reload
make serve-frontend     # React with hot reload

# Code quality checks
make lint-check         # CI-ready linting
make type-check         # TypeScript validation

KDE Plot Generation

The platform includes a script to generate high-quality KDE (Kernel Density Estimation) plots for research publication and analysis:

# Generate KDE plots for all prompts
python generate_kde_plots.py

What it generates:

  • 8 PNG files: prompt1.png through prompt8.png (one per prompt scenario)
  • High-resolution plots: 300 DPI, publication-ready quality
  • Demographic group analysis: 2x5 grid showing all 10 demographic groups
  • Severity indicators: Color-coded backgrounds and harm rate annotations
  • Alignment vs Valence visualization: Density plots with highlighted harmful quadrants

Output location: kde_plots/ directory (created automatically)

Upload to S3: After generation, upload the plots to the S3 bucket for frontend access:

# Upload all KDE plots to S3 (requires AWS CLI configured)
aws s3 cp kde_plots/ s3://systemic-misalignment/kde_plots/ --recursive

# Individual file upload example
aws s3 cp kde_plots/prompt1.png s3://systemic-misalignment/kde_plots/prompt1.png

The generated plots are used by the frontend for research visualization and can be embedded in academic papers or presentations.

πŸ“š Documentation

Detailed Guides

  • API Documentation - Complete FastAPI backend guide
    • API endpoints and schemas
    • Data models and validation
    • Development setup and testing
  • Frontend Documentation - React development guide
    • Component architecture
    • TypeScript configuration
    • UI/UX implementation details

Research Data

The platform analyzes responses from AI models prompted with scenarios involving different demographic groups:

Demographics Analyzed: Jewish, Christian, Muslim, Black, White, Hispanic, Buddhist, Hindu, Asian, Arab

Prompt Variants: 8 different scenarios testing model responses across contexts

Metrics:

  • Alignment Score: Measures how aligned responses are with safety guidelines
  • Valence Score: Emotional tone and sentiment analysis
  • Statistical Analysis: Distribution patterns and group comparisons

🎨 Features Overview

1. Overview Tab

Research introduction, methodology explanation, and key findings summary

2. Data Analysis Tab

  • Interactive statistical visualizations (KDE, radar, bar charts)
  • Alignment and valence distributions
  • Real-time statistics display
  • Embedded Plotly.js charts

3. Response Patterns Tab

  • t-SNE visualization exploration
  • High-dimensional embedding analysis
  • Interactive scatter plots
  • Pattern discovery across responses

4. Search & Filter Tab

  • Multi-parameter filtering
  • Keyword search capabilities
  • Alignment and valence range sliders
  • Sortable results display
  • Group summary statistics

πŸ”§ API Endpoints

Active Endpoints

  • GET /prompts - Available prompts with metadata
  • GET /demographic-groups - Demographic groups for analysis
  • GET /misalignment-stats/{prompt_idx} - Detailed prompt statistics
  • GET /plot/radar-interactive/{prompt_idx} - Interactive radar charts
  • GET /plot/bar-interactive/{prompt_idx} - Interactive bar charts
  • GET /group-summary/{prompt_idx}/{group} - Group-specific analysis
  • GET /lowest-alignment/{prompt_idx}/{group} - Lowest alignment examples
  • POST /search-outputs/{prompt_idx} - Single prompt search
  • POST /search-outputs-multi - Multi-prompt search

Infrastructure Endpoints

  • GET /health - Health check (used by Railway deployment platform)

🀝 Contributing

This is a research project focused on AI alignment and bias analysis. Contributions should maintain the strict code quality standards and research integrity.

Code Standards

  • Backend: Python 3.11, type hints, comprehensive testing
  • Frontend: TypeScript strict mode, React best practices
  • Documentation: Clear, comprehensive, up-to-date

Development Process

  1. Follow existing code patterns
  2. Maintain type safety
  3. Add comprehensive error handling
  4. Update documentation
  5. Test thoroughly

⚠️ Ethics & Research Disclaimer

This research platform is designed to identify and study AI bias and safety failures. The content analyzed may include outputs that demonstrate bias or potentially harmful responses. This research is conducted to improve AI alignment and should not be interpreted as endorsing any biased viewpoints.

Research Purpose: This platform is specifically designed for academic research into AI alignment failures and should be used responsibly for advancing the field of AI safety.

πŸ“„ License

This research project is focused on AI alignment analysis and bias detection in language models.


πŸ”— Quick Links: API Docs | Frontend Guide | Live Demo

About

Systemic Misalignment: Exposing Catastrophic Failures of Surface-Level AI alignment Methods

Resources

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages