Skip to main content

Training-time adaptive data curriculum for PyTorch with safety guards

Project description

🛡 CurriculumGuard

Training-Time Data Control for PyTorch

PyPI
License

CurriculumGuard is an open-source training-time data control system for PyTorch that dynamically adapts which samples a model sees during training using live learning dynamics — while enforcing stability via rollback-based safety guards.

Models and optimizers are controlled.
Hyperparameters are tuned.
But the data stream itself has been ignored — until now.


🔥 Why CurriculumGuard?

Modern datasets are increasingly:

  • Noisy
  • Imbalanced
  • Web-scraped
  • Non-stationary

Yet most training pipelines assume the dataset is static and trustworthy.

CurriculumGuard introduces a missing layer in ML infrastructure:

Adaptive Data Curriculum with Stability-First Control

Instead of changing how models learn, CurriculumGuard changes what they learn from — safely, during training.


⚙ Installation

pip install curriculumguard

🚀 Quick Start (v0.2 API)

1️⃣ Dataset must return sample IDs

CurriculumGuard needs sample-level identity to track learning dynamics.

def __getitem__(self, idx):
    return idx, data, label

2️⃣ Minimal usage (Beginner)

from curriculum_guard.curriculum import Curriculum

curriculum = Curriculum.auto(train_dataset)

for ids, x, y in curriculum(train_loader):
    logits = model(x)
    loss   = criterion(logits, y)

    curriculum.step(ids, loss, logits, y)

    loss.mean().backward()
    optimizer.step()
    optimizer.zero_grad()

That's it.

  • No custom samplers
  • No weighting logic
  • No curriculum math
  • Same PyTorch training loop

🧠 Mental Model

CurriculumGuard acts like an optimizer for data:

Data → Model → Loss → Curriculum → Safer Data → Model

It continuously answers:

"Which samples are helping learning right now — and which are destabilizing it?"


🧠 Signals Observed (Automatically)

Signal What It Represents
EMA loss Sample difficulty
Loss variance Label noise
Prediction entropy Shortcut learning
Forgetting events Unstable / harmful samples
Exposure count Over-training risk

These signals are observed, not enforced — safety decisions are made separately.


🛡 Safety Model

CurriculumGuard is conservative by design.

  • Curriculum decisions are advisory
  • Safety mechanisms are authoritative
  • Harmful curriculum updates are rolled back
  • Training stability is never sacrificed

Policy proposes. Safety decides.


📊 Benchmarks

Task Baseline CurriculumGuard
AG News (noisy labels) 68% 74%
FashionMNIST (35% noise) 84% 87.5%
Fraud Detection (recall) slow & unstable fast, high recall
Continual Drift fragile stable

🧩 Progressive API Design (v0.2)

CurriculumGuard scales with user expertise.

🟢 Beginner (default)

curriculum = Curriculum.auto(dataset)

Safe defaults, minimal setup.


🟡 Intermediate (optional tuning)

curriculum = Curriculum.auto(
    dataset,
    sensitivity="medium",   # low | medium | high
    warmup_epochs=2,
    safety=True
)

🔵 Advanced (explicit strategies)

curriculum = Curriculum.custom(
    dataset,
    policy="anti_noise",
    bucketing="quantile",
    safety="rollback",
    entropy_weight=0.3
)

🔴 Research-level (full control)

curriculum = Curriculum.from_components(
    profiler=CustomProfiler(),
    policy=MyPolicy(),
    safety=MySafetyController(),
    bucketer=MyBucketer()
)

🧪 Where CurriculumGuard Shines

  • Noisy labels
  • Long training runs
  • Expensive experiments
  • Continual / non-stationary data
  • High-risk domains (fraud, medical, finance)

If your dataset is clean, CurriculumGuard stays out of the way.

If it's not — it stabilizes learning.


📜 License

MIT

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

curriculumguard-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

curriculumguard-0.2.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file curriculumguard-0.2.0.tar.gz.

File metadata

  • Download URL: curriculumguard-0.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for curriculumguard-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2388757696d0f2ee51410d2a3d5de3b48bc572898c985aadd7dd279450ebd0a5
MD5 50b784a35412c2be02506db99b273f5c
BLAKE2b-256 2484c567b1e8e45370501eb2d10ff290f70dd7aa4d0213d4cd1081bec61c30c9

See more details on using hashes here.

File details

Details for the file curriculumguard-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for curriculumguard-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75f61170be13856bfc4de62c19f70171775cdc65aeb97a96a035e73514ba3cf2
MD5 cb8446f3c542fbd2fc0a4375b30ec1d9
BLAKE2b-256 c0ef0eaf08e9f22fde785e8421c247e2f6bd52f054c9ea7778f2e708e9ad7c45

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