Skip to content

🧠 Enterprise-grade Machine Unlearning architecture. Surgically erases data from trained Neural Networks without retraining, providing cryptographic verification for GDPR/CCPA compliance.

License

Notifications You must be signed in to change notification settings

ibhushani/amnesia

Repository files navigation

🧠 Amnesia: Verifiable Machine Unlearning as a Service (VMUaaS)

License Python FastAPI Next.js Status

"You can bake the cake, but can you take the eggs out?"

Amnesia is an enterprise-grade platform that enables Machine Unlearningβ€”surgically removing specific data points from trained AI models without full retraining. It provides cryptographic verification of erasure for GDPR/CCPA compliance.


πŸš€ Features

  • SISA Architecture: Sharded, Isolated, Sliced, Aggregated training for efficient unlearning (75%+ faster than retraining).
  • Gradient Ascent: Mathematical "erasure" of specific data points from model weights.
  • Verifiable Compliance: Membership Inference Attacks (MIA) to prove data is truly forgotten.
  • Premium Dashboard: Modern Next.js interface for managing datasets, training, and unlearning.
  • Compliance Certificates: PDF generation for legal audit trails (GDPR Article 17).

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 14 (React)
  • Styling: Tailwind CSS v4 + Framer Motion (Animations)
  • Components: Custom Premium UI (Glassmorphism, Dark Mode)

Backend

  • API: FastAPI (Python)
  • ML Core: PyTorch (Neural Networks)
  • Task Queue: Celery + Redis (Background Processing)
  • Database: PostgreSQL / SQLite (Metadata & Logs)
  • Visualization: Streamlit (Legacy/Admin Dashboard)

🏁 Getting Started

Prerequisites

  • Python 3.10+
  • Node.js 18+ (for Frontend)
  • Docker (Optional, for containerized run)

Option A: Quick Start (Local)

1. Clone the Repository

git clone https://github.com/YOUR_USERNAME/amnesia.git
cd amnesia

2. Backend Setup

# Create virtual environment
python -m venv .venv

# Activate it
# Windows:
.\.venv\Scripts\Activate
# Mac/Linux:
# source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

3. Frontend Setup

cd frontend
npm install
cd ..

4. Run the Application

You need two terminals:

Terminal 1 (Backend API):

python -m uvicorn api.main:app --reload --port 8000

Terminal 2 (Frontend):

cd frontend
npm run dev

Visit http://localhost:3000 to access the dashboard.

πŸ”¬ The Core Algorithm (Vision MVP)

Why Vision (CIFAR-10)?

Text models (LLMs) entangle knowledge (e.g., removing "Harry Potter" removes "Wizards"). Vision models have distinct classes, making them perfect for proving unlearning works.

The Task:

  1. Train a ResNet-18 on CIFAR-10 (Cars, Cats, Planes...).
  2. Unlearn Class 3 (Cats) while keeping Class 1 (Cars) accurate.

Gradient Ascent (The "Eraser")

Located in: core/unlearning/simple_unlearn.py

Normally, you train a model to minimize error:

loss.backward()  # Gradient DESCENT

To unlearn, we maximize error on the specific target data:

(-loss).backward()  # Gradient ASCENT (The "Anti-Learning")

This pushes the model's weights away from recognizing the target concept.


Option B: Docker (Production)

Run the entire stack with one command:

docker-compose up -d --build

πŸ“‚ Repository Structure

The project follows a modern monorepo structure:

Amnesia/
β”œβ”€β”€ api/                  # FastAPI Backend
β”‚   β”œβ”€β”€ main.py           # App Entrypoint
β”‚   └── routes/           # API Endpoints (Training, Unlearning, etc.)
β”œβ”€β”€ core/                 # Machine Learning Logic
β”‚   β”œβ”€β”€ sisa/             # SISA Architecture Implementation
β”‚   β”œβ”€β”€ unlearning/       # Gradient Ascent Algorithms
β”‚   └── verification/     # Membership Inference Attacks
β”œβ”€β”€ dashboard/            # Admin Dashboard (Streamlit)
β”œβ”€β”€ frontend/             # User Dashboard (Next.js)
β”‚   β”œβ”€β”€ src/app/          # Pages (Landing, Dashboard, Login)
β”‚   └── src/components/   # Reusable UI Components
β”œβ”€β”€ scripts/              # Helper Scripts
β”‚   └── demo.py           # End-to-end System Test
β”œβ”€β”€ storage/              # Local Storage for Models & DB (Gitignored)
β”œβ”€β”€ tests/                # Unit & Integration Tests
└── requirements.txt      # Python Dependencies

🌿 Branching Strategy

We follow a simplified GitFlow for collaboration:

  1. main: Stable, production-ready code.
  2. develop: Integration branch for next release.
  3. feature/xyz: New features (merge into develop).
  4. fix/xyz: Bug fixes (merge into main or develop).

To contribute:

  1. Checkout main.
  2. Create a branch: git checkout -b feature/new-ui-component.
  3. Commit & Push.
  4. Open a Pull Request.

πŸ“œ Legal

This project is licensed under the Apache 2.0 License.

Disclaimer: This tool is a proof-of-concept for Verifiable Machine Unlearning. While it implements state-of-the-art algorithms, ensure validation before using for critical legal compliance.

Verification Proof πŸ“œ

Once unlearning is complete, you can verify the results and generate a GDPR-compliant Certificate of Erasure.

  1. Go to the Verification page.
  2. Run the Membership Inference Attack (MIA) on the target data.
  3. If successful (Confidence < Threshold), a PDF certificate is generated.
  4. Download it directly from the UI.

Sample Proof: A sample certificate generated from our Vision MVP is included in this repository: πŸ‘‰ PROOF_OF_ERASURE_VISION_MVP.pdf

Certificate Location: All generated certificates are stored locally in: storage/certificates/

About

🧠 Enterprise-grade Machine Unlearning architecture. Surgically erases data from trained Neural Networks without retraining, providing cryptographic verification for GDPR/CCPA compliance.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published