AutoDefenceML (ADML) is an open-source initiative designed to enhance the security of machine learning (ML) models. In the age of AI-driven technologies, ensuring the security and integrity of ML systems is critical. From data poisoning to adversarial attacks, ML models face numerous vulnerabilities. AutoDefenceML addresses these challenges by automating the security evalaution process, helping ML engineers identify potential security threats and providing actionable recommendations to bolster defenses.
This platform aims to bridge the gap between ML development and security expertise, making robust ML security accessible to all engineers, regardless of their background in cybersecurity. By automating complex vulnerability assessments and defense recommendations, it streamlines the path to safer, more reliable AI deployments.
AutoDefenceML is packed with powerful features to ensure the robustness and fairness of your ML models and datasets. Here's what it offers:
- Comprehensive evaluation of model robustness to adversarial examples.
- Defence Evalautions are automatically scaled over a GPU node-pool over GCP.
- Assesment of the latest attacks and defences; some developed for this platform exclusivly and the rest sourced from the ART community.
- Evaluation of adaptive adversaries against potential defences.
- A JSON and PDF health report detailing vulnerabilities and recommended optimal defenses.
- Optional hyperparameter optimization for both the attacks and defences.
- Supports TensorFlow, PyTorch, Scikit-learn, XGBoost, and CatBoost.
- Supports various modalities, including image and tabular data.
- Automatic detection of poisoning in training datasets using the method of Cretu, Gabriela F., et al.
- A JSON and PDF report identifying suspicious samples in the dataset.
- Identifies biases in provided training datasets.
- Evalutates a suite of bias mitigation methods to improve fairness.
- Produces comprehensive JSON and PDF reports on bias detection and correction.
In terms of user experience, ADML offer the following:
- A REST API for easy intergration and interaction
- The ability to provide a custom model and dataset python definitions or non-conventional formats.
- The ability to dynamically change python requirements in individual evaautuions (under developent)
- Developers can easily add new attacks an defences to ADML. Details on how to dot his can be found in the plugin documentation.
AutoDefenceML is in its early stages of development so there are some limitations to be aware of:
- Model Support: Limited to classification models and specific frameworks (TensorFlow, PyTorch, Scikit-learn, XGBoost, CatBoost).
- Modality: While the
Model Evlautioncan handle any non-sequential data (images, tabular, ...), theData EvalautionandBias Evaluationsonly support tabular data at this time. - Adversarial Examples Currently, the
Model Evalautiononly evaluates untargeted adversarial examples.
- FastAPI
- Google Cloud Platform (GCP)
- Cloud Firestore
- Pub/Sub
- Kubernetes Engine
- Container Registry
- Terraform
- Python ML Frameworks Support:
- PyTorch
- TensorFlow
- scikit-learn
- XGBoost
- Keras
- CatBoost
- Python 3.10
- Google Cloud SDK
- Terraform
- kubectl
- Docker
- Clone the repository
- Create a
.envfile with the following variables:
PROJECT_ID=your_project_id
FIRESTORE_DB=your_database
FIRESTORE_REPORTS_COLLECTION=your_reports_collection
FIRESTORE_ESTIMATOR_COLLECTION= your_estimator_params_collection
FIRESTORE_EVAL_STATUS_COLLECTION=your_eval_status_collection
FIRESTORE_VAL_STATUS_COLLECTION=your_validate_status_collection
FIRESTORE_BIAS_VAL_STATUS_COLLECTION= your_bias_validate_status_collection
FIRESTORE_BIAS_DET_STATUS_COLLECTION = your_bias_detection_status_collection
FIRESTORE_BIAS_MIT_STATUS_COLLECTION = your_bias_mitigation_status_collection
FIRESTORE_DATA_VAL_STATUS_COLLECTION= your_data_validate_status_collection
FIRESTORE_DATA_EVAL_STATUS_COLLECTION = your_data_evaluate_status_collection
TOPIC_EVAL=your_eval_topic
FROM_BUCKET=your_bucket_status (TRUE or FALSE for local)
BUCKET_NAME=your_bucket_name
ACCOUNT_SERVICE_KEY=your_service_key
FILES_PATH_VAL=src.user_files
FILES_PATH_EVAL=src.eval.user_files_eval
FILES_PATH_BIAS=src.bias_eval.user_files_bias
FILES_PATH_DATA=src.data_eval.user_files_data- Install dependencies:
pip install -r requirements.txt- Install additional packages:
pip install --index-url https://us-central1-python.pkg.dev/autodefenseml/filehandler/simple/ file-loader
pip install --index-url https://us-central1-python.pkg.dev/autodefenseml/art-handler/simple/ art-handler
pip install --index-url https://me-west1-python.pkg.dev/autodefenseml/art-attacks-plugin/simple/ art-attacks-plugin
First, configure the CI/CD pipeline by setting up the Terraform configuration for the build triggers.
Navigate to the CI/CD Terraform directory and create/modify terraform.tfvars:
project_id = "autodefenseml"
branch = "master"
region = "us-central1"
repo_name = "api"
git_owner = "MABADATA"
repository_id = "autodefenseml"
services_names = {
"terraform" = {
trigger_name = "api-terraform-trigger"
manager_dir = "api"
image_name = "app"
}
}# Initialize Terraform
terraform init
# Review planned changes
terraform plan
# Apply CI/CD configuration
terraform applyAfter setting up CI/CD, deploy the main infrastructure components.
cd Backend/api/src/Infrastructure# Initialize Terraform for infrastructure
terraform init
# Review infrastructure changes
terraform plan
# Deploy infrastructure
terraform applyThis will create:
- Kubernetes cluster configuration
- GPU-enabled node pools
- Load balancers
- Service accounts and IAM roles
- Network configuration
- Storage buckets
- Pub/Sub topics and subscriptions
After both CI/CD and infrastructure deployment are complete:
- Verify build triggers:
gcloud builds triggers list- Configure kubectl:
gcloud container clusters get-credentials autodefenseml --region us-central1- Verify kubernetes deployment:
kubectl get nodes
kubectl get pods- Check GPU availability:
kubectl get nodes -l gpu=trueTo remove all created resources:
# Clean up infrastructure
cd Backend/api/src/Infrastructure
terraform destroy
# Clean up CI/CD
cd <ci-cd-terraform-directory>
terraform destroyInstallation
Install dependencies:
bashCopypip install -r requirements.txt
Install additional packages:
bashCopypip install --index-url https://us-central1-python.pkg.dev/autodefenseml/filehandler/simple/ file-loader pip install --index-url https://us-central1-python.pkg.dev/autodefenseml/art-handler/simple/ art-handler
The following is a brief summary of the REST API after launching AutoDefenceML. For more details see the API documentation.
POST /validate/- Validate model configuration and compatibilityGET /validation_status/{job_id}- Get validation statusPOST /evaluate/-Evaluate the model with specific attacks and defensesGET /evaluation_status/{job_id}- Get evaluation status
POST /bias_validate/- validate the dataset and dataloadedr the user uploadedGET /bias_validate_status/{job_id}- Get bias validation status
POST /bias_detection/- Perform bias detection analysisGET /bias_detection_status/{job_id}- Get bias detection status
POST /bias_mitigation/- Apply bias mitigation strategiesGET /bias_mitigation_status/{job_id}- Get bias mitigation status
POST /dataset_validate/- Validate dataset structurePOST /dataset_evaluate/- Evaluate dataset characteristicsGET /dataset_validate_status/{job_id}- Get dataset validation statusGET /dataset_evaluate_status/{job_id}- Get dataset evaluation status
GET /listofgpu/- List available GPU nodesDELETE /removegpu/{gpu_id}- Remove specific GPU nodeDELETE /delete_node_pool_and_deployment/{short_id}- Delete node pool and deployment
The service uses Terraform for infrastructure management and includes:
- Kubernetes cluster configuration
- GPU node pool management
- Load balancer setup
- Service account configuration
Build the Docker image using the provided Dockerfile:
docker build -t ml-validation-service .
docker run -p 8080:8080 ml-validation-service- Create new router in
src/api/routers/ - Register router in
main.py - Update infrastructure code if needed
- Add tests and documentation
Run tests using:
pytest tests/Common issues and solutions:
-
GPU Node Pool Issues
- Check permissions
- Verify GCP configuration
- Ensure correct service account setup
-
Firestore Connection
- Verify credentials
- Check project configuration
- Ensure correct collection names
- Fork the repository
- Create feature branch
- Commit changes
- Create pull request
MIT License
Thank you to all the amazing contributors! (listed in no particular order)
- Eran Simtob
- Michal Alhindi
- Roey Bokobza
- Tomer Meshulam
Project lead: Yisroel Mirsky