AI-Powered Charitable Investment Optimization, Giving Strategy & Impact Measurement
Prototype v0.4 Β· Gates Foundation Grand Challenges 2026 Β· Project 3: AI to Accelerate Charitable Giving
PAI uses Federated Retrieval-Augmented Generation (Federated RAG) to ground every AI recommendation in verified institutional knowledge while ensuring sensitive data never leaves local servers. It uniquely unifies investment optimization, grant recommendations, and impact measurement into a closed-loop system where real-world outcomes continuously improve future decisions.
Key stat: A pre-registered experiment (White et al., 2026, N=1,949) showed LLM-based dialogue increases effective charitable donations by 45.9% β the strongest causal evidence to date that AI can accelerate giving.
PAI/
βββ app.py # Streamlit Cloud single-file version (v0.4, 1,226 lines)
βββ requirements.txt # Cloud dependencies
βββ LICENSE # MIT License
βββ README.md # This file
β
βββ pai-audit/ # Full modular version (v0.4) β main development
βββ app.py # Streamlit dashboard (7 tabs)
βββ pyproject.toml # Package config (v0.4.0)
βββ requirements.txt # Full dependencies
βββ core/
β βββ __init__.py # Module exports
β βββ portfolio_optimizer.py # Markowitz MVO + Impact-Aware optimization
β βββ llm_client.py # GiveSmart LLM advisor
β βββ give_nudge.py # GiveNudge behavioral engine
β βββ impact_feedback.py # Impact Feedback Loop
β βββ federated_learning.py # FedShield reference implementation
β βββ federated_rag/ # Federated RAG module
β βββ __init__.py
β βββ config.py # Dataclass configs
β βββ document_loader.py # PDF/CSV/JSON/MD loader
β βββ embeddings.py # sentence-transformers wrapper
β βββ vector_store.py # FAISS vector store
β βββ federated_client.py # Federated aggregation client
β βββ reranker.py # Cross-encoder reranker
β βββ hallucination_detector.py # Claim verification engine
β βββ streamlit_ui.py # Streamlit integration
βββ tests/
β βββ test_portfolio.py # Portfolio optimizer tests
β βββ test_llm_client.py # LLM advisor tests
β βββ test_federated_rag.py # Federated RAG tests
β βββ test_v04_modules.py # GiveNudge + Impact Loop + Hallucination tests
βββ data/
βββ knowledge_base/ # Verified reference data
βββ givewell_charities.md
βββ daf_investment.md
βββ daf_tax_strategies.md
βββ impact_measurement.md
βββ behavioral_economics.md
βββ rare_disease.md
βββ federated_learning.md
Extends Markowitz Mean-Variance Optimization to jointly maximize financial returns and charitable impact. Recognizes that the highest-returning portfolio may produce less good if gains flow to saturated programs.
- Maximum Sharpe, Minimum Variance, Risk Parity strategies
- Impact-Aware optimization (v0.4): maximizes
U = Ξ±Β·Sharpe + Ξ²Β·Impact - Efficient frontier visualization
- DAF-specific optimization with charitable impact metrics
- Financial vs. Impact portfolio comparison
Personalized donation strategy with hallucination detection. Every claim is verified against institutional knowledge bases.
- Real OpenAI/Anthropic API integration (demo fallback)
- Tax optimization (DAFs, bunching, appreciated securities)
- Charity matching using GiveWell/ACE evidence ratings
- Hallucination Detection (v0.4): claim extraction β KB verification β confidence scoring
- +45.9% effective giving increase (White et al. 2026)
Multi-dimensional charity scoring aligned with GiveWell's cost-effectiveness methodology.
- QALY/DALY-based scoring
- Cost per life saved analysis
- Evidence strength ratings
- Radar chart visualization
Data-driven donation optimization based on behavioral economics (Andreoni 1990 warm-glow theory).
- 6 nudge types: default reminder, social proof, matching, impact framing, urgency, warm-glow
- 4 delivery channels: email, in-app, SMS, push
- 5 donor segments with tailored strategies
- Built-in A/B testing framework
- Optimal timing engine (year-end 1.45Γ conversion boost)
PAI's most transformative component β connects measured outcomes to future allocation decisions.
- Effect signal collection (health, education, environmental metrics)
- Saturation detection: diminishing returns curves per cause area
- Automatic reallocation recommendations
- "What happened" β "What should we do next" closed loop
Reference implementation for privacy-preserving cross-institutional collaboration.
- FedAvg algorithm (McMahan et al. 2017)
- Differential privacy support
- Audit trail with blockchain-style logging
- Simulated multi-institution training
First architecture combining LLM conversational ability, RAG factual grounding, and federated privacy for charitable giving.
- Embeddings: sentence-transformers (all-MiniLM-L6-v2)
- Vector search: FAISS
- Cross-encoder reranking (ms-marco-MiniLM)
- Federated embedding training
- Knowledge sharing without data sharing
pip install streamlit pandas numpy plotly scipy
streamlit run app.pycd pai-audit
pip install -r requirements.txt
streamlit run app.pycd pai-audit
pytest tests/ -v
# 110 tests passed| Tab | Module | Description |
|---|---|---|
| 1 | InvestOpt | Portfolio optimization with 63 mutual funds |
| 2 | GiveSmart | AI donation advisor with hallucination detection |
| 3 | ImpactLens | Charity effectiveness evaluation |
| 4 | GiveNudge | Behavioral engagement engine |
| 5 | Impact Loop | Closed-loop outcome measurement |
| 6 | Rare Disease | Rare disease foundation blueprint + FedShield |
| 7 | Federated RAG | Cross-institutional knowledge retrieval |
| Component | Technology |
|---|---|
| Frontend | Streamlit |
| Charts | Plotly |
| Optimization | SciPy |
| Embeddings | sentence-transformers (all-MiniLM-L6-v2) |
| Vector Search | FAISS |
| Federated Training | PyTorch + FedAvg |
| LLM | OpenAI / Anthropic / Demo fallback |
| Data | Pandas + NumPy |
- White, J.P. et al. (2026). Increasing the effectiveness of charitable giving with AI-generated persuasion. PsyArXiv. β LLM dialogue increases effective donations by 45.9%
- Andreoni, J. (1990). Impure Altruism and Donations to Public Goods. The Economic Journal, 100(401), 464-477. β Warm-glow giving theory
- Lo, A., Matveyev, A., & Zeume, S. (2025). The Risk, Reward, and Asset Allocation of Nonprofit Endowment Funds. NBER Working Paper. β Charity endowments systematically underperform
- Gates Foundation (2026). AI to Accelerate Charitable Giving. Grand Challenges RFP.
- GiveWell. Cost-Effectiveness Analysis. β ~$3,000-5,000 per life saved (top charities)
- McMahan, B. et al. (2017). Communication-Efficient Learning of Deep Networks from Decentralized Data. AISTATS. β FedAvg algorithm
| Project | Description |
|---|---|
| FundFL | Mutual fund analysis (Rust + Python) |
| organoid-fl | Federated learning for medical images |
| defect-fl | PCB defect detection with FL |
Built for the Gates Foundation Grand Challenges 2026