Skip to main content

AttackLM

AttackLM — QLoRA fine-tuning pipeline for a MITRE ATT&CK-grounded security AI assistant. 24,652 training pairs · Qwen2.5-Coder base · 16GB+ VRAM.

License: MIT PyPI version Python 3.10+


Install

The recommended way to install the full CUDA training stack:

pip install attacklm[all]

Alternative: Use uv pip install "attacklm[all]" for faster installation. Note: flash-attn is optional and not included by default to avoid heavy compilation requirements.


Init

Initialize the dataset by cloning upstream repositories, extracting data, adding attribution, and organizing into buckets:

attacklm-init --yes

Balance (Optional)

Because Metasploit accounts for ~64% of the raw data, balancing is recommended to prevent overfitting and ensure broad tactical coverage.

attacklm-balance --profile 7b-16gb --output data/datasets/balanced/balanced.jsonl
  • Presets: Use --preset red-team, purple-team, or blue-team to control the offensive/defensive mix.
  • Profiles: Use profiles like 3b-16gb or 7b-16gb to automatically set per-bucket caps based on your VRAM.

Train

Train the model using the orchestrated pipeline. The default base model is Qwen/Qwen2.5-Coder-3B-Instruct.

attacklm-train-all --single-model --dataset all --epochs 5 --max-length 2048

Key Training Flags

Flag Default Description
--single-model off Train one model on all buckets combined
--dataset none Path to dataset or alias (all, base/, tools/, ai/, orchestrator)
--epochs 10 Total training epochs
--max-length 1024 Max sequence length (use 2048 for richer context)
--lora-r 16 LoRA rank
--use-galore off Use Q-GaLore for full-parameter training on low VRAM
--spectrum off SNR-based layer freezing to reduce VRAM

Multi-round SFT: AttackLM supports iterative training. You can train on tactics first, then tools, then a final general pass. Each round automatically backs up the previous state and uses the merged weights of the prior run as the new base.


Build

Perform a one-shot merge of the LoRA adapter and conversion to GGUF format for local deployment.

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

Infer

Smoke-test your trained adapter with a set of representative security prompts.

attacklm-infer --adapter models/attacklm-single_TIMESTAMP

Bucket Reference Table

The dataset is split into buckets to allow for granular control over training composition.

Bucket Pairs Category Description
base/collection 634 MITRE Tactic TA0009 - Collection techniques
base/command_and_control 0 MITRE Tactic TA0011 - C2 techniques (no data yet)
base/credential_access 589 MITRE Tactic TA0006 - Credential access
base/defense_evasion 1,375 MITRE Tactic TA0005 - Defense evasion
base/discovery 1,846 MITRE Tactic TA0007 - Discovery
base/execution 767 MITRE Tactic TA0002 - Execution
base/exfiltration 53 MITRE Tactic TA0010 - Exfiltration
base/lateral_movement 252 MITRE Tactic TA0008 - Lateral movement
base/persistence 1,120 MITRE Tactic TA0003 - Persistence
base/privilege_escalation 537 MITRE Tactic TA0004 - Privilege escalation
tools/metasploit 8,349 Tools Metasploit module knowledge
ai/jailbreaking 50 AI Security Jailbreak techniques (garak)
ai/prompt-injection 63 AI Security Prompt injection (promptfoo, promptmap)
orchestrator 380 Meta Agent routing decisions
cloud/attacks 10 Extended Cloud attack techniques
ics/attacks 290 Extended ICS/SCADA attacks
social_engineering/phishing 440 Extended Phishing techniques
wireless/attacks 197 Extended Wireless attacks
defensive/detection_engineering 7,154 Defensive Sigma + Elastic + Splunk detection rules
defensive/threat_hunting 366 Defensive Mordor + ThreatHunter playbooks
defensive/incident_response 168 Defensive NIST SP 800-61r3 IR procedures

Note: 6 defensive buckets (detection_engineering, threat_hunting, incident_response, plus sigma/elastic/splunk/mordor/threathunter/nist sources) are planned but have 0 records currently.


Data Sources

Source Pairs License
Metasploit Framework 13,997 BSD-3-Clause
Atomic Red Team 1,115 MIT
MITRE Caldera/Stockpile 390 Apache-2.0
LLM-generated 937 GPL-3.0
NVIDIA Garak / Promptfoo 113 Mixed MIT/Apache-2.0
Sigma 3,132 DRL-1.1
Elastic 1,908 Elastic-2.0
Splunk 2,114 Apache-2.0
Mordor 339 Apache-2.0
ThreatHunter 27 Apache-2.0
NIST IR 168 Public Domain

Architecture

Data is organized in a per-source hierarchy to ensure provenance and attribution.

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

This layout allows the pipeline to deterministically extract data from upstream sources without introducing hallucinations or API dependencies.


CLI Reference

Command Description
attacklm-init One-shot init: clone $\rightarrow$ extract $\rightarrow$ attribute $\rightarrow$ buckets
attacklm-train Train a single QLoRA adapter
attacklm-train-all Orchestrated training for all buckets / HPO
attacklm-balance Build a balanced subset of buckets
attacklm-hpo Coordinate-descent HPO sweep
attacklm-infer Smoke-test inference
attacklm-merge Merge LoRA adapter into base model
attacklm-gguf Convert merged model to GGUF (llama.cpp)
attacklm-build One-shot merge $\rightarrow$ GGUF $\rightarrow$ install
attacklm-demo Multi-agent orchestrator demo
attacklm-extract Extract data from cloned repositories
attacklm-buckets Organize data into bucket structure
attacklm-attribute Add source and license to JSONL records
attacklm-clone Clone upstream data repositories
attacklm-train-lora Direct LoRA training on single dataset
attacklm-eval Run retention evaluation suite
attacklm-collect-ref Collect reference model outputs
attacklm-score Score candidate models against reference
attacklm-compare Compare multiple candidate model scores
attacklm-golden Execute golden vector regression gates
attacklm-register-ollama Register GGUF model with Ollama

License

The code in this repository is licensed under the MIT License. Training data consists of mixed licenses per source; see ATTRIBUTION.md for the full mapping.

Contributing

See CONTRIBUTING.md for guidelines on contributing to AttackLM.

Changelog

See CHANGELOG.md for the full version history.

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.7.0.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.7.0-py3-none-any.whl (485.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: attacklm-0.7.0.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.7.0.tar.gz
Algorithm Hash digest
SHA256 4ea612b9643d61da6cba01d5dd07b32acfdf30526aab9d53f5460f57da8207d0
MD5 5500b560409da869cfa2c966580fb097
BLAKE2b-256 0d5ca2f8cca6e82e7621e957704c03960f373d5ab3119341ec03a0c55ead8f2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for attacklm-0.7.0.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.7.0-py3-none-any.whl.

File metadata

  • Download URL: attacklm-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 485.4 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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9ab547ddcff16dae531daee8ffc483aa878764643f2ec50a08ef695bef88a55
MD5 7da3c3112822355a7142628c9dd22815
BLAKE2b-256 9ae510b0d7b0c65f9406cc77f656c13056ff4f15e985e34b9245caef10506dd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for attacklm-0.7.0-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