MIAF is a Modular Infrastructure-Aware Fusion framework for malicious domain and URL detection. It is designed for research and reproducible experiments where domain strings and infrastructure metadata must be studied separately and together.
The framework keeps five components separated:
- String encoder: character models, PLM/URLBERT-style encoders.
- Metadata encoder: infrastructure feature projections.
- Fusion operator: concat, gated, and gated-add metadata fusion.
- Optimization objective: cross-entropy, focal loss, logit-adjusted loss, class weights, and samplers.
- Interpretation module: prediction explanations, counterfactual metadata analysis, and export utilities.
This repository is a clean package migration from an earlier experimental codebase. The current focus is a clear CLI and reusable modules rather than a direct copy of legacy scripts.
MIAF provides a working research framework with:
- canonical dataset registry
- Hugging Face dataset download patterns
- local split verification
- dataset inspection CLI
- lightweight training dry-runs
- real training MVP for
meta-onlyandchar-cnn - metadata fusion through the clean component interfaces
- interpretation and export utilities
- focused tests for migrated functionality
The roadmap is to keep extending the same clean interfaces for PLM checkpoint workflows, full experiment sweeps, and richer interpretation reports.
MIAF relies on the following core frameworks and libraries:
- Deep Learning Framework: PyTorch & PyTorch Lightning for neural string encoders, metadata fusion architectures, and reproducible training loops.
- Pretrained Language Models & Hub: Hugging Face Transformers & huggingface_hub for transformer-based encoders (e.g. PLM / URLBERT) and dataset distribution.
- Machine Learning & Data Processing: scikit-learn for data preprocessing, tabular feature scaling, and metrics; Pandas & NumPy for dataset manipulation and numeric computing.
- Metrics & Experiment Tracking: TorchMetrics for model evaluation and Weights & Biases (W&B) for run logging and visualization.
- Testing & Quality Assurance: PyTest for unit and integration testing.
For development:
pip install -e .Optional dataset download support:
pip install -e '.[datasets]'Optional training extras:
pip install -e '.[training]'The canonical dataset source is the Hugging Face dataset repository:
ahmedBargady/DomMalPhi_Datasets_Infra
Each registered dataset contains:
train.csvdev.csvtest.csvtrain_ip.csvdev_ip.csvtest_ip.csv
Set a default local dataset root with:
export MIAF_DATA_ROOT=/path/to/DomMalPhi_Datasets_InfraOr pass --root to each command.
List registered datasets:
miaf datasets listResolve and verify a local dataset path:
miaf datasets path hranicky-malware --root /path/to/DomMalPhi_Datasets_Infra
miaf datasets verify hranicky-malware --root /path/to/DomMalPhi_Datasets_InfraDownload one registered dataset with narrow Hugging Face allow_patterns:
miaf datasets download hranicky-malware --root data/DomMalPhi_Datasets_InfraPreview download patterns without network access:
miaf datasets download hranicky-malware --dry-runInspect split sizes, columns, labels, and metadata columns:
miaf inspect data hranicky-malware --root /path/to/DomMalPhi_Datasets_Infra
miaf inspect data hranicky-malware --root /path/to/DomMalPhi_Datasets_Infra --jsonBuild a normalized training configuration without importing heavy training dependencies or starting training:
miaf train --dataset hranicky-malware --encoder char-cnn --fusion concat --dry-run
miaf train --print-config --encoder meta-only --metadata all --no-wandbRun the first real-training MVP paths:
miaf train \
--dataset hranicky-malware \
--encoder meta-only \
--metadata all \
--epochs 5 \
--no-wandb \
--run-dir runs/meta_only
miaf train \
--dataset hranicky-malware \
--encoder char-cnn \
--metadata all \
--fusion concat \
--loss cross-entropy \
--epochs 5 \
--no-wandb \
--run-dir runs/char_cnnUse --data-dir to point directly at any directory containing train.csv, dev.csv, and test.csv.
Run the test suite:
python -m compileall miaf scripts tests
python -m pytest tests
python -m miaf.cli --help
python -m miaf.cli datasets listTraining smoke tests are skipped automatically when optional training dependencies are unavailable.
miaf/data split loading, metadata column selection, PyTorch datasets
miaf/datasets dataset registry, download patterns, verification
miaf/components metadata encoders, fusion operators, objectives
miaf/models string encoders and PLM wrappers
miaf/training builders, Lightning module, runner, artifacts
miaf/interpret online interpretation and visualization utilities
scripts compatibility entry points
tests focused migration tests
MIAF is released under the MIT License. You may use, modify, and distribute it for research and projects, including derivative work, subject to the license terms.
If MIAF supports your research, please cite the associated paper or repository once a formal citation is available.