Choose the method that works best for your workflow:
pip install moderatorsuv venv --python 3.10
source .venv/bin/activate
uv add moderatorsuv sync --extra transformers- Python: 3.10+
- For image tasks: Pillow and a deep learning framework (PyTorch preferred)
- Moderators can auto-install these dependencies when needed
If something is missing (e.g., torch, transformers, Pillow), Moderators can automatically install it via uv or pip unless you disable this feature.
To disable auto-installation:
export MODERATORS_DISABLE_AUTO_INSTALL=1If you prefer to manage dependencies manually, install with extras:
pip install "moderators[transformers]"After caching models, you can run completely offline:
CLI:
moderators <model_id> <input> --local-files-onlyPython API:
moderator = AutoModerator.from_pretrained("model-id", local_files_only=True)Moderators works on CPU by default. If your deep learning framework (e.g., PyTorch) is installed with CUDA support, GPU acceleration will be used automatically.
To ensure GPU usage:
- Install PyTorch with CUDA support following PyTorch installation guide
- Verify CUDA availability in your environment