Skip to main content

AttackLM

PyPI version Python 3.10+ License: MIT Build Status

A high-performance QLoRA fine-tuning pipeline for creating MITRE ATT&CK-grounded security AI assistants.


Table of Contents


Quickstart

Get from zero to a trained security model in four commands:

# 1. Install the full training stack
pip install "attacklm[all]"

# 2. Initialize the MITRE-grounded dataset (downloads pre-built tarball)
attacklm init --yes

# 3. Balance the dataset to prevent source-bias (e.g., Metasploit overfitting)
attacklm balance

# 4. Launch training on Qwen2.5-Coder
attacklm train -- --dataset all --epochs 5 --train

Installation Guide

Prerequisites

  • OS: Linux (Ubuntu recommended) or WSL2
  • Python: 3.10+
  • Hardware: NVIDIA GPU with 8GB+ VRAM (RTX 30-series/40-series) or AMD ROCm compatible GPU.

Installation

Install based on your hardware acceleration preference:

NVIDIA CUDA (Recommended)

pip install "attacklm[all]"
# OR using uv for faster installation
uv pip install "attacklm[all]"

AMD ROCm

pip install "attacklm[all-rocm]"

Verification

attacklm --version

Memory Optimization: Flash-Attention vs. SDP

AttackLM is designed for maximum accessibility without sacrificing the efficiency of modern attention mechanisms.

The Problem with flash-attn Traditional flash-attn installations require a full CUDA toolkit, specific NVCC versions, and lengthy source compilation, which frequently fails in constrained environments or varying OS versions.

The AttackLM Solution: Memory Efficient SDP By default, AttackLM leverages PyTorch's built-in torch.backends.cuda.enable_mem_efficient_sdp().

  • Technical Advantage: It implements the same $\mathcal{O}(1)$ tiled algorithm as FlashAttention.
  • VRAM Impact: At a sequence length of 12,000, a standard $\mathcal{O}(n^2)$ attention matrix would consume ~8GB of VRAM just for the matrix. Memory Efficient SDP keeps this overhead constant.
  • Zero Friction: No compilation required. It works natively across all supported PyTorch/CUDA environments.

Note: If you have a perfectly configured environment and want the absolute maximum throughput, you can still install the standalone flash-attention: pip install "attacklm[flash-attn]".


Features

  • Comprehensive Security Corpus: 24,652 high-quality training pairs across 18 distinct security sources.
  • Advanced Training Methods: Support for QLoRA, GaLore, Q-GaLore, Spectrum, and PiSSA to enable training of large models on consumer hardware.
  • Zero-Config Setup: One-shot init command that handles dataset retrieval, extraction, and bucket organization.
  • Anti-Bias Balancing: Integrated balancing engine to ensure the model learns diverse tactics rather than just the most voluminous sources.
  • Provenance Tracking: Strict per-source attribution and license tracking for every record in the dataset.
  • Terminal GUI: A professional Textual-based TUI for managing training runs without memorizing 40+ CLI flags.
  • Deployment Ready: Built-in merge and conversion pipeline to export adapters to GGUF format for LM Studio or Ollama.
  • Rock-Solid Stability: 26/26 core tests passing.

Usage

Dataset Management

attacklm init Initialize the environment. Downloads the pre-built dataset for instant use.

attacklm init --yes

attacklm balance Create a balanced training subset to ensure tactical coverage.

attacklm balance --profile 7b-16gb --preset red-team

Model Training

attacklm train The core training engine. Supports Qwen2.5-Coder 3B and 7B base models.

# Train a single model on the entire balanced dataset
attacklm train -- --dataset all --epochs 10 --lora-r 16 --use-galore

Deployment & Testing

attacklm build Merge LoRA adapters and convert to GGUF for local deployment.

attacklm build -- --adapter models/attacklm-single_TIMESTAMP --name attacklm-security

attacklm infer Perform a smoke-test of the trained model against representative security prompts.

attacklm infer -- --adapter models/attacklm-single_TIMESTAMP

Specialized Tools

  • attacklm eval: Run the retention evaluation suite and score candidate models.
  • attacklm gui: Launch the Terminal GUI for an interactive training experience.
  • attacklm demo: Run the multi-agent orchestrator demo.

Dataset & Attribution

The dataset is meticulously partitioned into "buckets" to allow granular control over training composition.

Core Composition

Category Source Examples Approx. Pairs License
Offensive Metasploit, Atomic Red Team 15,000+ BSD-3 / MIT
Defensive Sigma, Elastic, Splunk 7,000+ DRL-1.1 / Apache-2.0
AI Security Garak, Promptfoo 100+ Mixed
Meta/IR NIST IR, Orchestrator 500+ Public Domain

Total Records: 24,652
Base Models: Qwen2.5-Coder (3B, 7B)

For a complete mapping of every record to its original source and license, see ATTRIBUTION.md.


Architecture

AttackLM employs a deterministic pipeline that separates raw data extraction from training logic.

AttackLM/
├── data/
│   └── datasets/
│       └── buckets/
│           └── sources/
│               └── <source>/
│                   └── <bucket>/
│                       └── <tactic>/
│                           └── data.jsonl

This hierarchy ensures that the pipeline can be rebuilt from upstream sources without introducing hallucinations, while allowing the balance command to target specific tactics or sources for weighted sampling.


CLI Reference

Command Description
attacklm train Train a model (QLoRA, GaLore, Q-GaLore, Spectrum, PiSSA)
attacklm train --dataset all Train all buckets combined
attacklm train --hpo Run Hyper-Parameter Optimization sweep
attacklm init Initialize dataset: download pre-built or clone $\rightarrow$ extract $\rightarrow$ attribute
attacklm balance Build a balanced subset of buckets to prevent overfitting
attacklm build Merge adapter $\rightarrow$ GGUF conversion $\rightarrow$ LM Studio/Ollama register
attacklm infer Smoke-test inference on trained adapters
attacklm eval Run retention evaluation and regression gates
attacklm gui Launch Terminal GUI (TUI) for all operations
attacklm demo Run multi-agent orchestrator demo

License & Contributing

Code License: This project is licensed under the MIT License.

Data License: Training data consists of mixed licenses per source. Please refer to ATTRIBUTION.md for the full legal mapping.

Contributing: We welcome contributions to the extraction pipeline and training methods. See CONTRIBUTING.md for guidelines.

History: For a full list of changes and version milestones, see CHANGELOG.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

attacklm-0.8.2.tar.gz (5.5 MB view details)

Uploaded Source

Built Distribution

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

attacklm-0.8.2-py3-none-any.whl (497.1 kB view details)

Uploaded Python 3

File details

Details for the file attacklm-0.8.2.tar.gz.

File metadata

  • Download URL: attacklm-0.8.2.tar.gz
  • Upload date:
  • Size: 5.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for attacklm-0.8.2.tar.gz
Algorithm Hash digest
SHA256 d6d451f5645d5662941c5c5224d7b50bf1fda8a0a82270538155763b8fc984e5
MD5 af78ebec9c5402c7613e5618a1c9587b
BLAKE2b-256 68f11d8f1091462dfde404bfedf54f74c619ffd41d49023cb7a6ac270850c8bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for attacklm-0.8.2.tar.gz:

Publisher: release.yml on Veedubin/AttackLM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file attacklm-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: attacklm-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 497.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for attacklm-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a06f9af8bd014866dcdfa6264fcfc9be505672f85a1fdd16820370d266cdcb2e
MD5 60b9376209682d32c2b11c0c06e810c9
BLAKE2b-256 73216d3534d1a0a6ef8ad3e2c22619057abbc31f8d2e03395b1fab43db442938

See more details on using hashes here.

Provenance

The following attestation bundles were made for attacklm-0.8.2-py3-none-any.whl:

Publisher: release.yml on Veedubin/AttackLM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page