Text Classification
Transformers
ONNX
Safetensors
Transformers.js
English
modernbert
mitre-attack
cyber-threat-intelligence
cti
multi-label
security
ttp
threat-intelligence
soc
detection-engineering
attack
Eval Results (legacy)
text-embeddings-inference
Instructions to use Project-Bastion/attack-technique-tagger with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Project-Bastion/attack-technique-tagger with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Project-Bastion/attack-technique-tagger")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Project-Bastion/attack-technique-tagger") model = AutoModelForSequenceClassification.from_pretrained("Project-Bastion/attack-technique-tagger", device_map="auto") - Transformers.js
How to use Project-Bastion/attack-technique-tagger with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'Project-Bastion/attack-technique-tagger'); - Notebooks
- Google Colab
- Kaggle
attack-technique-tagger v0.1 (experimental)
Browse files- README.md +76 -0
- config.json +183 -0
- model.safetensors +3 -0
- onnx/model.onnx +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +17 -0
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: cisco-ai/SecureBERT2.0-base
|
| 4 |
+
pipeline_tag: text-classification
|
| 5 |
+
library_name: transformers
|
| 6 |
+
language: [en]
|
| 7 |
+
tags: [mitre-attack, cyber-threat-intelligence, cti, multi-label, security, ttp, onnx, transformers.js]
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# attack-technique-tagger (experimental v0.1)
|
| 11 |
+
|
| 12 |
+
Tags a sentence from a threat report with the MITRE ATT&CK techniques it describes (50 techniques, multi-label).
|
| 13 |
+
Meant as an assistant for CTI analysts and detection engineers who triage reports; **it is only moderately accurate (sealed test micro F1 0.59)**, so use its output as suggestions to review, not as ground truth.
|
| 14 |
+
|
| 15 |
+
**[Try it in your browser](https://huggingface.co/spaces/Project-Bastion/attack-technique-tagger-demo)**: a static page that runs the model locally (transformers.js, ONNX). The text you paste never leaves your device.
|
| 16 |
+
|
| 17 |
+
## Usage
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
import torch
|
| 21 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 22 |
+
repo = "Project-Bastion/attack-technique-tagger"
|
| 23 |
+
tok = AutoTokenizer.from_pretrained(repo); model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
|
| 24 |
+
|
| 25 |
+
sentences = ["The malware dumps credentials from LSASS memory using a Mimikatz-like routine.",
|
| 26 |
+
"It then creates a scheduled task to maintain persistence on the host.",
|
| 27 |
+
"Command and control traffic is sent over HTTPS to a hard-coded domain."] # sentences of ONE report, in order
|
| 28 |
+
|
| 29 |
+
def tag(i, threshold=0.2):
|
| 30 |
+
prev = sentences[i - 1] if i > 0 else ""; nxt = sentences[i + 1] if i + 1 < len(sentences) else ""
|
| 31 |
+
ctx = prev[-300:] + " | " + nxt[:300] # neighbouring sentences are part of the input (the model was trained this way)
|
| 32 |
+
enc = tok(sentences[i], ctx, truncation="longest_first", max_length=256, return_tensors="pt")
|
| 33 |
+
with torch.no_grad(): p = torch.sigmoid(model(**enc).logits[0])
|
| 34 |
+
return [(model.config.id2label[j], round(float(p[j]), 3)) for j in torch.nonzero(p >= threshold).flatten().tolist()]
|
| 35 |
+
|
| 36 |
+
for i, s in enumerate(sentences): print(s[:60], "->", tag(i))
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
Details that matter: input is the sentence plus its previous and next sentence from the same report (adding them improved validation F1 slightly); outputs are independent sigmoids over 50 technique ids
|
| 40 |
+
(see `config.json`; look any id up at `attack.mitre.org/techniques/<ID>`); the threshold 0.2 was chosen on validation data and trades precision for recall (raise it for fewer false positives).
|
| 41 |
+
|
| 42 |
+
## Evaluation (sealed test)
|
| 43 |
+
|
| 44 |
+
Data: the TRAM2 annotated threat-report sentences (Center for Threat-Informed Defense, Apache-2.0): 19,178 sentences from 151 public reports, 4,070 of them labelled with 1 or more of 50 techniques.
|
| 45 |
+
Split **by report** (so no report is in two splits): 105 reports train, 20 validation, 26 test (2,920 sentences, 683 with a technique). Two techniques that occur in only 1 and 5 reports were pinned to train, so test covers 48 of the 50.
|
| 46 |
+
All model and threshold choices (about 15 training runs over 4 base models, learning rates, class weights, context and seeds) used the validation split only. The test split was scored once, on the final model.
|
| 47 |
+
|
| 48 |
+
| System | Micro F1 | Macro F1 | "has any technique" F1 |
|
| 49 |
+
|---|---|---|---|
|
| 50 |
+
| **attack-technique-tagger (this model)** | **0.593** | **0.537** | **0.730** |
|
| 51 |
+
| TF-IDF + logistic regression (same split) | 0.536 | 0.496 | 0.672 |
|
| 52 |
+
| nanda-rani/TTPXHunter (MIT; best existing open model I found; its confidence threshold tuned on validation) | 0.296 | 0.243 | 0.499 |
|
| 53 |
+
|
| 54 |
+
Micro precision / recall of this model on test: 0.595 / 0.590. Validation micro F1: 0.605 (three seeds: 0.597, 0.606, 0.596). TTPXHunter was trained on a different corpus (ATT&CK procedure examples), covers all 50 of these techniques among its 193 classes, and was run off the shelf; its low score reflects that domain shift as much as model quality.
|
| 55 |
+
Averaging three seeds scored 0.612 on validation (not shipped).
|
| 56 |
+
|
| 57 |
+
## Training
|
| 58 |
+
|
| 59 |
+
`cisco-ai/SecureBERT2.0-base` (Apache-2.0, ModernBERT architecture) fine-tuned with binary cross-entropy (positive-class weight exponent 0.5), lr 6e-5, 12 epochs, max length 256, bf16, one A10G; the epoch with the best validation micro F1 is kept.
|
| 60 |
+
Code: GitHub `Project-Bastion/models`, `scripts/ttp/`.
|
| 61 |
+
|
| 62 |
+
## ONNX / browser
|
| 63 |
+
|
| 64 |
+
`onnx/model.onnx` (fp32, **599 MB**) is published for transformers.js / onnxruntime. Checked against PyTorch on 200 validation sentences: onnxruntime fp32 differs by <1e-5 in probability; the in-browser code path (run in Node with transformers.js) gives identical decisions at the 0.2 threshold on all 200 sentences (a handful of long inputs differ by up to 0.02 in probability, cause not isolated).
|
| 65 |
+
**int8 quantization does not work for this model**: four dynamic-quantization recipes kept only 91-94% of decisions, so no int8 file is published. The demo therefore downloads the full 599 MB once.
|
| 66 |
+
|
| 67 |
+
## Known limits
|
| 68 |
+
|
| 69 |
+
* 50 techniques only (the TRAM2 label set); sub-technique distinctions are limited to the ones in that set; anything else is invisible to the model.
|
| 70 |
+
* Sentence-level and context-limited; technique labels in the training reports are themselves noisy and sometimes depend on the whole report.
|
| 71 |
+
* Test set is small (26 reports); numbers will move on other report styles, languages (English only) or newer malware reports. Not evaluated on non-report text such as logs or alerts.
|
| 72 |
+
* Moderate accuracy: expect many missed and extra techniques. Do not use it to automate decisions.
|
| 73 |
+
|
| 74 |
+
## License and credits
|
| 75 |
+
|
| 76 |
+
Apache-2.0. Training data: TRAM2 data from the Center for Threat-Informed Defense TRAM project (Apache-2.0), derived from public threat reports labelled with MITRE ATT&CK techniques (ATT&CK is a trademark of The MITRE Corporation; use per the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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ModernBertForSequenceClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 50281,
|
| 8 |
+
"classifier_activation": "gelu",
|
| 9 |
+
"classifier_bias": false,
|
| 10 |
+
"classifier_dropout": 0.0,
|
| 11 |
+
"classifier_pooling": "mean",
|
| 12 |
+
"cls_token_id": 50281,
|
| 13 |
+
"decoder_bias": true,
|
| 14 |
+
"deterministic_flash_attn": false,
|
| 15 |
+
"dtype": "float32",
|
| 16 |
+
"embedding_dropout": 0.0,
|
| 17 |
+
"eos_token_id": 50282,
|
| 18 |
+
"global_attn_every_n_layers": 3,
|
| 19 |
+
"gradient_checkpointing": false,
|
| 20 |
+
"hidden_activation": "gelu",
|
| 21 |
+
"hidden_size": 768,
|
| 22 |
+
"id2label": {
|
| 23 |
+
"0": "T1003.001",
|
| 24 |
+
"1": "T1005",
|
| 25 |
+
"2": "T1012",
|
| 26 |
+
"3": "T1016",
|
| 27 |
+
"4": "T1021.001",
|
| 28 |
+
"5": "T1027",
|
| 29 |
+
"6": "T1033",
|
| 30 |
+
"7": "T1036.005",
|
| 31 |
+
"8": "T1041",
|
| 32 |
+
"9": "T1047",
|
| 33 |
+
"10": "T1053.005",
|
| 34 |
+
"11": "T1055",
|
| 35 |
+
"12": "T1056.001",
|
| 36 |
+
"13": "T1057",
|
| 37 |
+
"14": "T1059.003",
|
| 38 |
+
"15": "T1068",
|
| 39 |
+
"16": "T1070.004",
|
| 40 |
+
"17": "T1071.001",
|
| 41 |
+
"18": "T1072",
|
| 42 |
+
"19": "T1074.001",
|
| 43 |
+
"20": "T1078",
|
| 44 |
+
"21": "T1082",
|
| 45 |
+
"22": "T1083",
|
| 46 |
+
"23": "T1090",
|
| 47 |
+
"24": "T1095",
|
| 48 |
+
"25": "T1105",
|
| 49 |
+
"26": "T1106",
|
| 50 |
+
"27": "T1110",
|
| 51 |
+
"28": "T1112",
|
| 52 |
+
"29": "T1113",
|
| 53 |
+
"30": "T1140",
|
| 54 |
+
"31": "T1190",
|
| 55 |
+
"32": "T1204.002",
|
| 56 |
+
"33": "T1210",
|
| 57 |
+
"34": "T1218.011",
|
| 58 |
+
"35": "T1219",
|
| 59 |
+
"36": "T1484.001",
|
| 60 |
+
"37": "T1518.001",
|
| 61 |
+
"38": "T1543.003",
|
| 62 |
+
"39": "T1547.001",
|
| 63 |
+
"40": "T1548.002",
|
| 64 |
+
"41": "T1552.001",
|
| 65 |
+
"42": "T1557.001",
|
| 66 |
+
"43": "T1562.001",
|
| 67 |
+
"44": "T1564.001",
|
| 68 |
+
"45": "T1566.001",
|
| 69 |
+
"46": "T1569.002",
|
| 70 |
+
"47": "T1570",
|
| 71 |
+
"48": "T1573.001",
|
| 72 |
+
"49": "T1574.002"
|
| 73 |
+
},
|
| 74 |
+
"initializer_cutoff_factor": 2.0,
|
| 75 |
+
"initializer_range": 0.02,
|
| 76 |
+
"intermediate_size": 1152,
|
| 77 |
+
"label2id": {
|
| 78 |
+
"T1003.001": 0,
|
| 79 |
+
"T1005": 1,
|
| 80 |
+
"T1012": 2,
|
| 81 |
+
"T1016": 3,
|
| 82 |
+
"T1021.001": 4,
|
| 83 |
+
"T1027": 5,
|
| 84 |
+
"T1033": 6,
|
| 85 |
+
"T1036.005": 7,
|
| 86 |
+
"T1041": 8,
|
| 87 |
+
"T1047": 9,
|
| 88 |
+
"T1053.005": 10,
|
| 89 |
+
"T1055": 11,
|
| 90 |
+
"T1056.001": 12,
|
| 91 |
+
"T1057": 13,
|
| 92 |
+
"T1059.003": 14,
|
| 93 |
+
"T1068": 15,
|
| 94 |
+
"T1070.004": 16,
|
| 95 |
+
"T1071.001": 17,
|
| 96 |
+
"T1072": 18,
|
| 97 |
+
"T1074.001": 19,
|
| 98 |
+
"T1078": 20,
|
| 99 |
+
"T1082": 21,
|
| 100 |
+
"T1083": 22,
|
| 101 |
+
"T1090": 23,
|
| 102 |
+
"T1095": 24,
|
| 103 |
+
"T1105": 25,
|
| 104 |
+
"T1106": 26,
|
| 105 |
+
"T1110": 27,
|
| 106 |
+
"T1112": 28,
|
| 107 |
+
"T1113": 29,
|
| 108 |
+
"T1140": 30,
|
| 109 |
+
"T1190": 31,
|
| 110 |
+
"T1204.002": 32,
|
| 111 |
+
"T1210": 33,
|
| 112 |
+
"T1218.011": 34,
|
| 113 |
+
"T1219": 35,
|
| 114 |
+
"T1484.001": 36,
|
| 115 |
+
"T1518.001": 37,
|
| 116 |
+
"T1543.003": 38,
|
| 117 |
+
"T1547.001": 39,
|
| 118 |
+
"T1548.002": 40,
|
| 119 |
+
"T1552.001": 41,
|
| 120 |
+
"T1557.001": 42,
|
| 121 |
+
"T1562.001": 43,
|
| 122 |
+
"T1564.001": 44,
|
| 123 |
+
"T1566.001": 45,
|
| 124 |
+
"T1569.002": 46,
|
| 125 |
+
"T1570": 47,
|
| 126 |
+
"T1573.001": 48,
|
| 127 |
+
"T1574.002": 49
|
| 128 |
+
},
|
| 129 |
+
"layer_norm_eps": 1e-05,
|
| 130 |
+
"layer_types": [
|
| 131 |
+
"full_attention",
|
| 132 |
+
"sliding_attention",
|
| 133 |
+
"sliding_attention",
|
| 134 |
+
"full_attention",
|
| 135 |
+
"sliding_attention",
|
| 136 |
+
"sliding_attention",
|
| 137 |
+
"full_attention",
|
| 138 |
+
"sliding_attention",
|
| 139 |
+
"sliding_attention",
|
| 140 |
+
"full_attention",
|
| 141 |
+
"sliding_attention",
|
| 142 |
+
"sliding_attention",
|
| 143 |
+
"full_attention",
|
| 144 |
+
"sliding_attention",
|
| 145 |
+
"sliding_attention",
|
| 146 |
+
"full_attention",
|
| 147 |
+
"sliding_attention",
|
| 148 |
+
"sliding_attention",
|
| 149 |
+
"full_attention",
|
| 150 |
+
"sliding_attention",
|
| 151 |
+
"sliding_attention",
|
| 152 |
+
"full_attention"
|
| 153 |
+
],
|
| 154 |
+
"local_attention": 128,
|
| 155 |
+
"max_position_embeddings": 8192,
|
| 156 |
+
"mlp_bias": false,
|
| 157 |
+
"mlp_dropout": 0.0,
|
| 158 |
+
"model_type": "modernbert",
|
| 159 |
+
"norm_bias": false,
|
| 160 |
+
"norm_eps": 1e-05,
|
| 161 |
+
"num_attention_heads": 12,
|
| 162 |
+
"num_hidden_layers": 22,
|
| 163 |
+
"pad_token_id": 50283,
|
| 164 |
+
"position_embedding_type": "absolute",
|
| 165 |
+
"problem_type": "multi_label_classification",
|
| 166 |
+
"repad_logits_with_grad": false,
|
| 167 |
+
"rope_parameters": {
|
| 168 |
+
"full_attention": {
|
| 169 |
+
"rope_theta": 160000.0,
|
| 170 |
+
"rope_type": "default"
|
| 171 |
+
},
|
| 172 |
+
"sliding_attention": {
|
| 173 |
+
"rope_theta": 10000.0,
|
| 174 |
+
"rope_type": "default"
|
| 175 |
+
}
|
| 176 |
+
},
|
| 177 |
+
"sep_token_id": 50282,
|
| 178 |
+
"sparse_pred_ignore_index": -100,
|
| 179 |
+
"sparse_prediction": false,
|
| 180 |
+
"tie_word_embeddings": true,
|
| 181 |
+
"transformers_version": "5.23.0",
|
| 182 |
+
"vocab_size": 50368
|
| 183 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eab9410204467f4ea1830b0dcb184f82309bfe1020e831a4e45f5630226d14c2
|
| 3 |
+
size 598587440
|
onnx/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43667209aef031f2e859c617267981b0b1e2289cacbacdc9ab207c701d669cc9
|
| 3 |
+
size 599156397
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"clean_up_tokenization_spaces": true,
|
| 4 |
+
"cls_token": "[CLS]",
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_input_names": [
|
| 9 |
+
"input_ids",
|
| 10 |
+
"attention_mask"
|
| 11 |
+
],
|
| 12 |
+
"model_max_length": 8192,
|
| 13 |
+
"pad_token": "[PAD]",
|
| 14 |
+
"sep_token": "[SEP]",
|
| 15 |
+
"tokenizer_class": "TokenizersBackend",
|
| 16 |
+
"unk_token": "[UNK]"
|
| 17 |
+
}
|