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.
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.
- π 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
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)
Backend (optional, defaults provided):
# CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000 # Comma-separated list for production
# Server Configuration
PORT=8000 # Used in Docker deploymentFrontend (create app/.env file):
# API Configuration
REACT_APP_API_URL=http://localhost:8000Default 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:8000Production:
# Backend
ALLOWED_ORIGINS=https://your-frontend-domain.com,https://staging-domain.com
# Frontend
REACT_APP_API_URL=https://your-api-server.comagi-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
- Python 3.11+
- Node.js 18+
- pip and npm/yarn/pnpm
-
Clone the repository
git clone <repository-url> cd agi-systemic-misalignment
-
Install all dependencies
make install
-
Start the FastAPI backend
make serve-api # Backend available at http://localhost:8000 -
Start the React frontend (in a new terminal)
make serve-frontend # Frontend available at http://localhost:3000 -
Access the application
- Main Application: http://localhost:3000
- API Documentation: http://localhost:8000/docs
- Alternative API Docs: http://localhost:8000/redoc
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# 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 validationThe 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.pyWhat it generates:
- 8 PNG files:
prompt1.pngthroughprompt8.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.pngThe generated plots are used by the frontend for research visualization and can be embedded in academic papers or presentations.
- 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
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
Research introduction, methodology explanation, and key findings summary
- Interactive statistical visualizations (KDE, radar, bar charts)
- Alignment and valence distributions
- Real-time statistics display
- Embedded Plotly.js charts
- t-SNE visualization exploration
- High-dimensional embedding analysis
- Interactive scatter plots
- Pattern discovery across responses
- Multi-parameter filtering
- Keyword search capabilities
- Alignment and valence range sliders
- Sortable results display
- Group summary statistics
GET /prompts- Available prompts with metadataGET /demographic-groups- Demographic groups for analysisGET /misalignment-stats/{prompt_idx}- Detailed prompt statisticsGET /plot/radar-interactive/{prompt_idx}- Interactive radar chartsGET /plot/bar-interactive/{prompt_idx}- Interactive bar chartsGET /group-summary/{prompt_idx}/{group}- Group-specific analysisGET /lowest-alignment/{prompt_idx}/{group}- Lowest alignment examplesPOST /search-outputs/{prompt_idx}- Single prompt searchPOST /search-outputs-multi- Multi-prompt search
GET /health- Health check (used by Railway deployment platform)
This is a research project focused on AI alignment and bias analysis. Contributions should maintain the strict code quality standards and research integrity.
- Backend: Python 3.11, type hints, comprehensive testing
- Frontend: TypeScript strict mode, React best practices
- Documentation: Clear, comprehensive, up-to-date
- Follow existing code patterns
- Maintain type safety
- Add comprehensive error handling
- Update documentation
- Test thoroughly
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.
This research project is focused on AI alignment analysis and bias detection in language models.
π Quick Links: API Docs | Frontend Guide | Live Demo