Text Classification
Transformers
Safetensors
English
modernbert
cyber-threat-intelligence
mitre-attack
multi-label-classification
defensive-security
blue-team
threat-intelligence
text-embeddings-inference
Instructions to use ctokx/cti-attack-mapper-modernbert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ctokx/cti-attack-mapper-modernbert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="ctokx/cti-attack-mapper-modernbert")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("ctokx/cti-attack-mapper-modernbert") model = AutoModelForSequenceClassification.from_pretrained("ctokx/cti-attack-mapper-modernbert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| """Regenerate every number in the model card from scratch. | |
| python scripts/reproduce_all.py # ModernBERT only (~40 min on an RTX 4060) | |
| python scripts/reproduce_all.py --all-models # adds DeBERTa-v3 and SecureBERT | |
| If this script does not run clean, the model card is wrong. That is the rule | |
| this repo is built around. | |
| """ | |
| import argparse | |
| import subprocess | |
| import sys | |
| import time | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def run(cmd: list[str]) -> None: | |
| print(f"\n{'=' * 70}\n$ {' '.join(cmd)}\n{'=' * 70}", flush=True) | |
| t0 = time.time() | |
| result = subprocess.run([sys.executable, *cmd], cwd=ROOT) | |
| if result.returncode != 0: | |
| sys.exit(f"FAILED: {' '.join(cmd)}") | |
| print(f"[{time.time() - t0:.0f}s]", flush=True) | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--all-models", action="store_true", | |
| help="also train DeBERTa-v3-base and SecureBERT") | |
| ap.add_argument("--epochs", type=int, default=6) | |
| args = ap.parse_args() | |
| run(["scripts/01_build_dataset.py"]) | |
| run(["scripts/02_run_baselines.py"]) | |
| models = ["modernbert"] + (["deberta", "securebert"] if args.all_models else []) | |
| for model in models: | |
| for scheme in ("document", "random"): | |
| run(["scripts/03_train.py", "--model", model, | |
| "--scheme", scheme, "--epochs", str(args.epochs)]) | |
| run(["scripts/04_report.py"]) | |
| run(["-m", "pytest", "tests/", "-q"]) | |
| print("\nAll steps completed. results/RESULTS.md is current.") | |
| if __name__ == "__main__": | |
| main() | |