AttackLM
A high-performance fine-tuning pipeline (QLoRA, GaLore, Q-GaLore, Spectrum, PiSSA) for creating MITRE ATT&CK-grounded security AI assistants.
Table of Contents
- Quickstart
- Installation Guide
- Features
- Usage
- Dataset & Attribution
- Architecture
- CLI Reference
- License & Contributing
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.
- Training Pair Evolution: New capability to synthetically expand short, factual pairs into complex reasoning examples using three specialized strategies:
| Strategy | Approach | Impact |
|---|---|---|
| Evol-Instruct | Rewrites responses with deeper reasoning and edge cases | 3-5x increase in response length/depth |
| Multi-turn | Decomposes Q&A into interactive conversations | Improved conversational flow and context |
| CoT Injection | Adds explicit "Chain-of-Thought" reasoning steps | Higher logical consistency in complex tasks |
- Zero-Config Setup: One-shot
initcommand 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 that eliminates the need to memorize 40+ CLI flags. Features include:
- Tabbed Training Form — 40+ parameters organized across Basic, LoRA, GaLore, Advanced, and Hardware tabs
- Live Training Monitor — Real-time loss sparkline, VRAM gauge, token throughput, and scrolling log output
- Built-in Presets — One-click configurations for 3B/7B models (Q-GaLore Spectrum, QLoRA, etc.)
- One-Click Commands — Init, Balance, Infer, Build, and Eval all accessible from the main menu
- Pause/Resume Controls — SIGSTOP/SIGCONT the training process without losing progress
- Zero Dependencies — No X11, no GPU, no browser required. Works over SSH, WSL, and headless servers.
- 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.
Standard Training
# Train a single model on the entire balanced dataset
attacklm train -- --dataset all --epochs 10 --lora-r 16 --use-galore
Training with Evolved Pairs
Use the --evolved-ratio flag to mix synthetically evolved high-reasoning pairs into your training set.
# Train with 20% evolved pairs for better reasoning depth
attacklm train -- --dataset all --evolved-ratio 0.2 --epochs 10
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
Terminal GUI
attacklm gui
Launch the Textual-based Terminal GUI for an interactive training experience. No memorizing 40+ CLI flags.
attacklm gui
The GUI provides:
| Screen | What it does |
|---|---|
| Train | Tabbed form (Basic, LoRA, GaLore, Advanced, Hardware) with 5 built-in presets |
| Init | One-click dataset initialization (download, extract, organize) |
| Balance | Build balanced training subsets with configurable caps |
| Inference | Smoke-test trained models against security prompts |
| Build | Merge adapter → GGUF conversion → install to LM Studio/Ollama |
| Eval | Retention evaluation, reference collection, scoring, comparison |
Live Training Monitor — Once training starts, you get a real-time dashboard:
┌─────────────────────────────────────────────────────┐
│ Training: attacklm-3b-qgalore-spectrum │
│ Epoch 12/30 | Step 1896 | Elapsed: 1h 23m │
├──────────────────────┬──────────────────────────────┤
│ Loss: 1.1143 ▂▃▅▆▇ │ VRAM: 5.9/15.6 GB (62%) │
│ Eval Loss: 1.176 │ alloc: 5.9 cache: 4.8 │
│ Trend: ↓ -0.0116 │ ████████░░░░ │
├──────────────────────┴──────────────────────────────┤
│ [P]ause [S]top at checkpoint [Q]uit │
└─────────────────────────────────────────────────────┘
Built-in Presets:
3B Q-GaLore Spectrum— Full-parameter training on 16GB GPU3B Q-GaLore Rank 128— Higher quality variant3B LoRA Default— Standard QLoRA7B Q-GaLore— For 24GB GPUs7B QLoRA Default— Standard QLoRA for 7B
Other Tools
attacklm eval: Run the retention evaluation suite and score candidate models.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 --evolved-ratio 0.2 |
Mix evolved reasoning pairs into training |
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file attacklm-0.8.4.tar.gz.
File metadata
- Download URL: attacklm-0.8.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ba8492b049a9f723d1c0624402968c04639c0e1627a1702803ea20eaea68837
|
|
| MD5 |
ed9170ddfc086be0edd81497490bc718
|
|
| BLAKE2b-256 |
e5ec9a7e2c0f84d8e7f8e702d7d174aa14c57760dbe39fa121ae1624aaac8601
|
Provenance
The following attestation bundles were made for attacklm-0.8.4.tar.gz:
Publisher:
release.yml on Veedubin/AttackLM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
attacklm-0.8.4.tar.gz -
Subject digest:
8ba8492b049a9f723d1c0624402968c04639c0e1627a1702803ea20eaea68837 - Sigstore transparency entry: 2038507056
- Sigstore integration time:
-
Permalink:
Veedubin/AttackLM@a56c7b902710bec8b0d29b55ec16d233e814785f -
Branch / Tag:
refs/tags/v0.8.4 - Owner: https://github.com/Veedubin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a56c7b902710bec8b0d29b55ec16d233e814785f -
Trigger Event:
push
-
Statement type:
File details
Details for the file attacklm-0.8.4-py3-none-any.whl.
File metadata
- Download URL: attacklm-0.8.4-py3-none-any.whl
- Upload date:
- Size: 527.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b769ecccf327ca2c7957fc081f4892ebc4ec31a366de435de9220357fa8812e7
|
|
| MD5 |
23232c38dd34146a96494913959265c2
|
|
| BLAKE2b-256 |
12bf5ae927d01a153f765f3f22ffa837bd77bb620c68dfdaf954d2d5798dffee
|
Provenance
The following attestation bundles were made for attacklm-0.8.4-py3-none-any.whl:
Publisher:
release.yml on Veedubin/AttackLM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
attacklm-0.8.4-py3-none-any.whl -
Subject digest:
b769ecccf327ca2c7957fc081f4892ebc4ec31a366de435de9220357fa8812e7 - Sigstore transparency entry: 2038507281
- Sigstore integration time:
-
Permalink:
Veedubin/AttackLM@a56c7b902710bec8b0d29b55ec16d233e814785f -
Branch / Tag:
refs/tags/v0.8.4 - Owner: https://github.com/Veedubin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a56c7b902710bec8b0d29b55ec16d233e814785f -
Trigger Event:
push
-
Statement type: