Project-Bastion commited on
Commit
c639544
·
verified ·
1 Parent(s): f38812c

Update model card

Browse files
Files changed (1) hide show
  1. README.md +23 -36
README.md CHANGED
@@ -9,7 +9,7 @@ model-index:
9
  - name: attack-technique-tagger
10
  results:
11
  - task: {type: text-classification, name: ATT&CK technique tagging (multi-label, 50 techniques)}
12
- dataset: {type: tram2-report-split-sealed-test, name: TRAM2 sealed test (26 held-out reports, 2920 sentences)}
13
  metrics:
14
  - {type: f1, value: 0.593, name: micro F1}
15
  - {type: f1, value: 0.537, name: macro F1}
@@ -17,13 +17,24 @@ model-index:
17
  inference: false
18
  ---
19
 
20
- # attack-technique-tagger (experimental v0.1)
21
 
22
- Tags a sentence from a threat report with the MITRE ATT&CK techniques it describes (50 techniques, multi-label).
23
- 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.
24
 
25
  **[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.
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  ## Usage
28
 
29
  ```python
@@ -38,7 +49,7 @@ sentences = ["The malware dumps credentials from LSASS memory using a Mimikatz-l
38
 
39
  def tag(i, threshold=0.2):
40
  prev = sentences[i - 1] if i > 0 else ""; nxt = sentences[i + 1] if i + 1 < len(sentences) else ""
41
- ctx = prev[-300:] + " | " + nxt[:300] # neighbouring sentences are part of the input (the model was trained this way)
42
  enc = tok(sentences[i], ctx, truncation="longest_first", max_length=256, return_tensors="pt")
43
  with torch.no_grad(): p = torch.sigmoid(model(**enc).logits[0])
44
  return [(model.config.id2label[j], round(float(p[j]), 3)) for j in torch.nonzero(p >= threshold).flatten().tolist()]
@@ -46,41 +57,17 @@ def tag(i, threshold=0.2):
46
  for i, s in enumerate(sentences): print(s[:60], "->", tag(i))
47
  ```
48
 
49
- 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
50
- (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).
51
-
52
- ## Evaluation (sealed test)
53
-
54
- 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.
55
- 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.
56
- 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.
57
-
58
- | System | Micro F1 | Macro F1 | "has any technique" F1 |
59
- |---|---|---|---|
60
- | **attack-technique-tagger (this model)** | **0.593** | **0.537** | **0.730** |
61
- | TF-IDF + logistic regression (same split) | 0.536 | 0.496 | 0.672 |
62
- | nanda-rani/TTPXHunter (MIT; best existing open model I found; its confidence threshold tuned on validation) | 0.296 | 0.243 | 0.499 |
63
-
64
- 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.
65
- Averaging three seeds scored 0.612 on validation (not shipped).
66
-
67
- ## Training
68
-
69
- `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.
70
- Code: GitHub `Project-Bastion/models`, `scripts/ttp/`.
71
 
72
- ## ONNX / browser
73
 
74
- `onnx/model.onnx` (fp32, **599 MB**) and `onnx/model_quantized.onnx` (weight-only int8, 151 MB) are 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, with probabilities identical for 197 of them and within 0.014 on 3 long inputs (the demo works around a transformers.js quirk that drops the closing `[SEP]` when it truncates; a small residual on very long inputs remains, cause not fully isolated).
75
- **Weight-only int8** (`onnx/model_quantized.onnx`, **151 MB**, the demo default): int8 weights with per-channel scales are dequantized at load while activations stay fp32. On 200 validation sentences it gives the same thresholded decisions as PyTorch for 198 (browser stack) / 197 (onnxruntime) of 200, mean probability change 0.0001, max 0.16; an int8 run can add or drop a low-confidence tag near the 0.2 threshold (for example the demo's last sample sentence gets an extra T1070.004 at 0.28 in int8 only). Standard dynamic int8 (91-94% of decisions kept) and static int8 with calibration (0% kept; ModernBERT activation outliers get clipped) do **not** work for this model, which is why the recipe quantizes weights only. Use the 599 MB fp32 file for exact agreement with the Python reference.
76
 
77
- ## Known limits
78
 
79
- * 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.
80
- * Sentence-level and context-limited; technique labels in the training reports are themselves noisy and sometimes depend on the whole report.
81
- * 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.
82
- * Moderate accuracy: expect many missed and extra techniques. Do not use it to automate decisions.
83
 
84
  ## License and credits
85
 
86
- 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 ATT&CK Terms of Use).
 
9
  - name: attack-technique-tagger
10
  results:
11
  - task: {type: text-classification, name: ATT&CK technique tagging (multi-label, 50 techniques)}
12
+ dataset: {type: tram2-report-split-test, name: TRAM2 test (26 reports, 2920 sentences)}
13
  metrics:
14
  - {type: f1, value: 0.593, name: micro F1}
15
  - {type: f1, value: 0.537, name: macro F1}
 
17
  inference: false
18
  ---
19
 
20
+ # attack-technique-tagger
21
 
22
+ Tag a sentence from a threat report with the MITRE ATT&CK techniques it describes (50 techniques, multi-label). It beats the best open ATT&CK tagger I found (TTPXHunter) by a wide margin on TRAM2 and runs on CPU or in your browser with no server.
 
23
 
24
  **[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.
25
 
26
+ ## Results
27
+
28
+ TRAM2 annotated threat-report sentences (Center for Threat-Informed Defense): test split of 26 reports, 2,920 sentences, 683 labelled with at least one technique; 50 techniques. One number per cell: the score on that benchmark.
29
+
30
+ | System | Micro F1 | Macro F1 | "has any technique" F1 |
31
+ |---|---|---|---|
32
+ | **attack-technique-tagger** | **0.593** | **0.537** | **0.730** |
33
+ | nanda-rani/TTPXHunter (off the shelf, scored on the same 50 techniques) | 0.296 | 0.243 | 0.499 |
34
+ | TF-IDF + logistic regression | 0.536 | 0.496 | 0.672 |
35
+
36
+ Micro precision / recall of this model: 0.595 / 0.590.
37
+
38
  ## Usage
39
 
40
  ```python
 
49
 
50
  def tag(i, threshold=0.2):
51
  prev = sentences[i - 1] if i > 0 else ""; nxt = sentences[i + 1] if i + 1 < len(sentences) else ""
52
+ ctx = prev[-300:] + " | " + nxt[:300] # neighbouring sentences are part of the input
53
  enc = tok(sentences[i], ctx, truncation="longest_first", max_length=256, return_tensors="pt")
54
  with torch.no_grad(): p = torch.sigmoid(model(**enc).logits[0])
55
  return [(model.config.id2label[j], round(float(p[j]), 3)) for j in torch.nonzero(p >= threshold).flatten().tolist()]
 
57
  for i, s in enumerate(sentences): print(s[:60], "->", tag(i))
58
  ```
59
 
60
+ Input is the sentence plus its previous and next sentence from the same report; outputs are independent sigmoids over 50 technique ids (see `config.json`; look any id up at `attack.mitre.org/techniques/<ID>`). Raise the 0.2 threshold for fewer false positives.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
+ ## Files
63
 
64
+ `onnx/model.onnx` (fp32, 599 MB) and `onnx/model_quantized.onnx` (weight-only int8, 151 MB, the demo default) for transformers.js / onnxruntime. int8 can add or drop a low-confidence tag near the threshold; use the fp32 file for exact agreement with the Python reference.
 
65
 
66
+ ## Limits
67
 
68
+ * Covers the 50 TRAM2 techniques only, and is English-only and sentence-level: review its tags as suggestions.
69
+ * Trained on threat-report prose; use other text such as logs or alerts only after checking it on your own samples.
 
 
70
 
71
  ## License and credits
72
 
73
+ Apache-2.0. Base model: cisco-ai/SecureBERT2.0-base (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 ATT&CK Terms of Use).