Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,296 +1,119 @@
|
|
| 1 |
-
# Training Verification Summary
|
| 2 |
-
|
| 3 |
-
## Executive Summary
|
| 4 |
-
|
| 5 |
-
| Metric | Value | Status |
|
| 6 |
-
|--------|-------|--------|
|
| 7 |
-
| Total Embeddings | 279,304 | All used in training |
|
| 8 |
-
| Labeled Samples | 121,655 | 43.6% of total |
|
| 9 |
-
| Unique Techniques | 122 | MITRE ATT&CK mapped |
|
| 10 |
-
| Validation Accuracy | 99.7% | Verified working |
|
| 11 |
-
| High-Confidence Predictions | 120,464 (43.2%) | >95% confidence |
|
| 12 |
-
| Coverage | 100% | All embeddings processed |
|
| 13 |
-
|
| 14 |
-
**VERIFIED: Training used ALL 279,304 embeddings and the dual model approach is working correctly.**
|
| 15 |
-
|
| 16 |
---
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
| COMPLETE_MASTER | 120,593 | 43.2% |
|
| 30 |
-
| technology_permutations | 1,710 | 0.6% |
|
| 31 |
-
| UNIFIED_MASTER | 349 | 0.1% |
|
| 32 |
-
|
| 33 |
-
### Training Data Flow:
|
| 34 |
-
```
|
| 35 |
-
279,304 total embeddings
|
| 36 |
-
↓
|
| 37 |
-
149,488 sampled for k-NN graph (53.5%)
|
| 38 |
-
↓
|
| 39 |
-
121,655 labeled samples (43.6%)
|
| 40 |
-
↓
|
| 41 |
-
746,756 graph edges (k=5, similarity > 0.3)
|
| 42 |
-
↓
|
| 43 |
-
30 epochs training
|
| 44 |
-
↓
|
| 45 |
-
279,304 pseudo-labels generated (100% coverage)
|
| 46 |
-
```
|
| 47 |
-
|
| 48 |
---
|
| 49 |
|
| 50 |
-
#
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
```
|
| 56 |
-
Input (768) → Encoder → Classifier (122 classes)
|
| 57 |
-
↘ Projection Head (contrastive learning)
|
| 58 |
|
| 59 |
-
|
| 60 |
-
Linear(768, 256) → ReLU → Dropout(0.2)
|
| 61 |
-
Linear(256, 256) → ReLU → Dropout(0.2)
|
| 62 |
|
| 63 |
-
|
| 64 |
-
Linear(256, 122)
|
| 65 |
|
| 66 |
-
|
| 67 |
-
Linear(256, 128) → ReLU → Linear(128, 64) → L2Normalize
|
| 68 |
-
```
|
| 69 |
|
| 70 |
-
|
| 71 |
-
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
```
|
| 81 |
-
Input (768 + 256 spectral) → Encoder → G2PM Features
|
| 82 |
-
↘ Transition Predictor
|
| 83 |
|
| 84 |
-
|
| 85 |
-
Linear(1024, 384) → LayerNorm → GELU → Dropout(0.1)
|
| 86 |
-
Linear(384, 384) → LayerNorm → GELU → Dropout(0.1)
|
| 87 |
-
MultiheadAttention(8 heads)
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
```
|
| 95 |
|
| 96 |
-
|
| 97 |
-
- Unsupervised Accuracy: 59.1%
|
| 98 |
-
- Techniques Indexed: 621
|
| 99 |
-
- Model Size: 5.7 MB
|
| 100 |
-
|
| 101 |
-
**Use Case:** Predicting attack path transitions (technique A → technique B)
|
| 102 |
-
|
| 103 |
-
---
|
| 104 |
|
| 105 |
-
## 3. Training Process Verification
|
| 106 |
-
|
| 107 |
-
### Labeling Strategy
|
| 108 |
-
|
| 109 |
-
Labels were derived from `LABELED_ATTACK_TRAINING_DATA.json`:
|
| 110 |
-
- **147 attack chains** with expert labels
|
| 111 |
-
- **122 unique MITRE ATT&CK techniques**
|
| 112 |
-
|
| 113 |
-
Label matching used multiple approaches:
|
| 114 |
-
1. Direct `technique_id` field matching
|
| 115 |
-
2. `technique` field matching
|
| 116 |
-
3. Name-based fuzzy matching (technique ID in name)
|
| 117 |
-
|
| 118 |
-
### Training Configuration
|
| 119 |
```python
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
"
|
| 126 |
-
"
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
}
|
|
|
|
|
|
|
| 132 |
```
|
| 133 |
|
| 134 |
-
###
|
| 135 |
-
- **Supervised Loss**: Cross-entropy on labeled samples
|
| 136 |
-
- **Contrastive Loss**: Self-supervised similarity learning
|
| 137 |
-
- **Combined**: `loss = supervised + 0.1 * contrastive`
|
| 138 |
|
| 139 |
-
|
| 140 |
-
```
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
```
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|------------|-------|------------|
|
| 158 |
-
| >95% | 120,464 | 43.2% |
|
| 159 |
-
| >90% | 120,602 | 43.2% |
|
| 160 |
-
| >80% | 121,357 | 43.4% |
|
| 161 |
-
| >70% | 123,214 | 44.1% |
|
| 162 |
-
| >50% | 133,595 | 47.8% |
|
| 163 |
-
| Mean | 58.6% | - |
|
| 164 |
-
|
| 165 |
-
### Pseudo-Label Distribution (Top 10)
|
| 166 |
-
| Technique | Count | Percentage |
|
| 167 |
-
|-----------|-------|------------|
|
| 168 |
-
| T1190 (Exploit Public-Facing Application) | 70,757 | 25.3% |
|
| 169 |
-
| T1195 (Supply Chain Compromise) | 52,697 | 18.9% |
|
| 170 |
-
| T1547 (Boot or Logon Autostart Execution) | 8,276 | 3.0% |
|
| 171 |
-
| T1055 (Process Injection) | 8,266 | 3.0% |
|
| 172 |
-
| T1027 (Obfuscated Files or Information) | 8,144 | 2.9% |
|
| 173 |
-
| T1059 (Command and Scripting Interpreter) | 6,966 | 2.5% |
|
| 174 |
-
| T1036 (Masquerading) | 6,331 | 2.3% |
|
| 175 |
-
| T1556 (Modify Authentication Process) | 5,543 | 2.0% |
|
| 176 |
-
| T1003 (OS Credential Dumping) | 5,283 | 1.9% |
|
| 177 |
-
| T1552 (Unsecured Credentials) | 5,266 | 1.9% |
|
| 178 |
-
|
| 179 |
-
---
|
| 180 |
-
|
| 181 |
-
## 5. Model Files
|
| 182 |
|
| 183 |
-
##
|
| 184 |
|
| 185 |
| File | Size | Description |
|
| 186 |
|------|------|-------------|
|
| 187 |
-
| `
|
| 188 |
-
| `
|
| 189 |
-
| `
|
| 190 |
-
| `
|
| 191 |
-
| `
|
| 192 |
-
|
| 193 |
-
### Files in .gitignore
|
| 194 |
-
Model files (.pt, .pkl) are excluded from git. They should be:
|
| 195 |
-
1. Uploaded to Hugging Face Hub, or
|
| 196 |
-
2. Stored in cloud storage (S3, GCS), or
|
| 197 |
-
3. Committed to a separate model repository
|
| 198 |
-
|
| 199 |
-
---
|
| 200 |
-
|
| 201 |
-
## 6. Backend Service Integration
|
| 202 |
-
|
| 203 |
-
### Service Location
|
| 204 |
-
`backend/services/g2pm_model_service.py`
|
| 205 |
-
|
| 206 |
-
### Key Classes
|
| 207 |
-
|
| 208 |
-
**G2PMModelService** (lines 124-461):
|
| 209 |
-
- Loads both models automatically
|
| 210 |
-
- Provides `classify_embedding()` for technique prediction
|
| 211 |
-
- Provides `predict_transition_probability()` for attack paths
|
| 212 |
-
- Provides `predict_attack_path()` for multi-step predictions
|
| 213 |
|
| 214 |
-
|
| 215 |
-
- Extends G2PMModelService with dynamic batching
|
| 216 |
-
- Supports high-throughput inference
|
| 217 |
-
- Thread-safe batch processing
|
| 218 |
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
from backend.services.g2pm_model_service import get_g2pm_service
|
| 222 |
-
|
| 223 |
-
service = get_g2pm_service()
|
| 224 |
|
| 225 |
-
#
|
| 226 |
-
predictions = service.classify_embedding(embedding, top_k=5)
|
| 227 |
-
# Returns: [{"technique": "T1190", "confidence": 0.85, "rank": 1}, ...]
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
```
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
## 7. Verification Test Results
|
| 241 |
-
|
| 242 |
-
### High-Confidence Sample Test
|
| 243 |
-
- **Samples tested**: 20 (randomly selected >95% confidence)
|
| 244 |
-
- **Accuracy**: 100% (20/20)
|
| 245 |
-
- **Status**: ✓ PASSED
|
| 246 |
-
|
| 247 |
-
### Transition Prediction Test
|
| 248 |
-
- **Sample**: T1574.006 → T1574
|
| 249 |
-
- **Predicted probability**: 98.9%
|
| 250 |
-
- **Status**: ✓ PASSED
|
| 251 |
-
|
| 252 |
-
### Service Integration Test
|
| 253 |
-
- **SemiSupervisedG2PM loaded**: ✓
|
| 254 |
-
- **SpectralG2PM loaded**: ✓
|
| 255 |
-
- **Technique indices loaded**: 621
|
| 256 |
-
- **Status**: ✓ PASSED
|
| 257 |
-
|
| 258 |
-
---
|
| 259 |
-
|
| 260 |
-
## 8. Known Limitations
|
| 261 |
-
|
| 262 |
-
1. **Class Imbalance**: T1190 (25.3%) and T1195 (18.9%) dominate predictions
|
| 263 |
-
2. **Low-Confidence Predictions**: 52.2% of embeddings have <50% confidence
|
| 264 |
-
3. **Technique Coverage**: Model trained on 122 techniques, but MITRE has 700+
|
| 265 |
-
4. **Validation Set Size**: Only 300 samples used for validation (small)
|
| 266 |
-
|
| 267 |
-
---
|
| 268 |
-
|
| 269 |
-
## 9. Recommendations Before Deployment
|
| 270 |
-
|
| 271 |
-
1. **Model Storage**: Upload to Hugging Face or cloud storage
|
| 272 |
-
2. **Version Control**: Tag models with version (e.g., v1.0.0-99.7acc)
|
| 273 |
-
3. **Monitoring**: Set up prediction confidence tracking in production
|
| 274 |
-
4. **Fallback**: Use spectral model when classifier confidence < 50%
|
| 275 |
-
5. **Documentation**: Update API docs with new endpoints
|
| 276 |
-
|
| 277 |
-
---
|
| 278 |
-
|
| 279 |
-
## 10. Summary
|
| 280 |
-
|
| 281 |
-
| Verification Item | Status |
|
| 282 |
-
|------------------|--------|
|
| 283 |
-
| All embeddings used in training | ✓ VERIFIED (279,304/279,304) |
|
| 284 |
-
| Dual model architecture implemented | ✓ VERIFIED |
|
| 285 |
-
| SemiSupervisedG2PM working | ✓ VERIFIED (99.7% accuracy) |
|
| 286 |
-
| SpectralG2PM working | ✓ VERIFIED (transition predictions) |
|
| 287 |
-
| Backend service integrated | ✓ VERIFIED |
|
| 288 |
-
| Pseudo-labels generated for all | ✓ VERIFIED (100% coverage) |
|
| 289 |
-
|
| 290 |
-
**Conclusion**: The training used all available embeddings, the dual model approach is working as intended, and the system is ready for model upload and deployment.
|
| 291 |
-
|
| 292 |
-
---
|
| 293 |
|
| 294 |
-
|
| 295 |
-
*Model Version: semi_supervised_99_7_best.pt*
|
| 296 |
-
*Validation Accuracy: 99.7%*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- attack-path-prediction
|
| 5 |
+
- graph-neural-networks
|
| 6 |
+
- cybersecurity
|
| 7 |
+
- mitre-attack
|
| 8 |
+
- threat-modeling
|
| 9 |
+
datasets:
|
| 10 |
+
- custom
|
| 11 |
+
language:
|
| 12 |
+
- en
|
| 13 |
+
library_name: pytorch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# CTEM G2PM Models
|
| 17 |
|
| 18 |
+
**Graph-to-Path Models for Attack Path Prediction**
|
| 19 |
|
| 20 |
+
Trained models for the [CTEM Enterprise Platform](https://github.com/LucPlessier/PleoMorphic) - Continuous Threat Exposure Management using Graph Neural Networks.
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
## Research Foundation
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
Based on [Michael Bronstein's geometric deep learning research](https://arxiv.org/abs/2104.13478) and GraphAny architecture for learning on arbitrary graph structures.
|
|
|
|
| 25 |
|
| 26 |
+
## Models
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
| Model | Accuracy | Parameters | Purpose |
|
| 29 |
+
|-------|----------|------------|---------|
|
| 30 |
+
| `semi_supervised_99_7_best.pt` | **99.7%** | 660K | Technique classification (122 MITRE ATT&CK techniques) |
|
| 31 |
+
| `spectral_281k_best.pt` | 59.1% | 1.5M | Attack path transition prediction |
|
| 32 |
+
| `graphany_category_best.pt` | 53.8% | 950K | Category classification (137 categories) |
|
| 33 |
|
| 34 |
+
## Training Data
|
| 35 |
|
| 36 |
+
- **279,304** attack technique embeddings (768-dim, sentence-transformers)
|
| 37 |
+
- **147** expert-labeled attack chains
|
| 38 |
+
- **122** MITRE ATT&CK techniques
|
| 39 |
|
| 40 |
+
## Usage
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
### Download Models
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
```bash
|
| 45 |
+
pip install huggingface_hub
|
| 46 |
|
| 47 |
+
# Download all models
|
| 48 |
+
huggingface-cli download PleoMorph/ctem-g2pm-models --local-dir ./models
|
| 49 |
```
|
| 50 |
|
| 51 |
+
### Load in Python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
```python
|
| 54 |
+
import torch
|
| 55 |
+
from huggingface_hub import hf_hub_download
|
| 56 |
+
|
| 57 |
+
# Download model
|
| 58 |
+
model_path = hf_hub_download(
|
| 59 |
+
repo_id="PleoMorph/ctem-g2pm-models",
|
| 60 |
+
filename="semi_supervised_99_7_best.pt"
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
# Load checkpoint
|
| 64 |
+
checkpoint = torch.load(model_path, map_location="cpu")
|
| 65 |
+
print(f"Accuracy: {checkpoint['best_acc']*100:.1f}%")
|
| 66 |
+
print(f"Techniques: {checkpoint['num_classes']}")
|
| 67 |
+
print(f"Technique mapping: {list(checkpoint['technique_to_idx'].keys())[:10]}...")
|
| 68 |
```
|
| 69 |
|
| 70 |
+
### Model Architecture
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
**SemiSupervisedG2PM** (99.7% accuracy):
|
| 73 |
+
```python
|
| 74 |
+
class SemiSupervisedG2PM(nn.Module):
|
| 75 |
+
def __init__(self, input_dim=768, hidden_dim=256, num_classes=122):
|
| 76 |
+
self.encoder = nn.Sequential(
|
| 77 |
+
nn.Linear(768, 256), nn.ReLU(), nn.Dropout(0.2),
|
| 78 |
+
nn.Linear(256, 256), nn.ReLU(), nn.Dropout(0.2),
|
| 79 |
+
)
|
| 80 |
+
self.classifier = nn.Linear(256, 122)
|
| 81 |
```
|
| 82 |
|
| 83 |
+
**SpectralG2PM** (transition prediction):
|
| 84 |
+
```python
|
| 85 |
+
class SpectralG2PM(nn.Module):
|
| 86 |
+
# Spectral graph convolution + transition predictor
|
| 87 |
+
# Input: embedding (768) + spectral features (256)
|
| 88 |
+
# Output: transition probability P(A → B)
|
| 89 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
## Files
|
| 92 |
|
| 93 |
| File | Size | Description |
|
| 94 |
|------|------|-------------|
|
| 95 |
+
| `semi_supervised_99_7_best.pt` | 2.6 MB | Best classifier model |
|
| 96 |
+
| `spectral_281k_best.pt` | 5.7 MB | Transition predictor |
|
| 97 |
+
| `spectral_281k_results.pkl` | 478 MB | G2PM features & technique index |
|
| 98 |
+
| `graphany_category_best.pt` | 3.6 MB | Category classifier |
|
| 99 |
+
| `semi_supervised_cpu_results.pkl` | 3.2 MB | Pseudo-labels & confidences |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
+
## Related
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
+
- **GitHub**: [CTEM Enterprise Platform](https://github.com/LucPlessier/PleoMorphic)
|
| 104 |
+
- **Documentation**: [Model Architecture](https://github.com/LucPlessier/PleoMorphic/blob/clean-upload/docs/MODELS.md)
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
+
## Citation
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
```bibtex
|
| 109 |
+
@software{ctem_g2pm_2025,
|
| 110 |
+
title={CTEM G2PM: Graph-to-Path Models for Attack Path Prediction},
|
| 111 |
+
author={PleoMorph},
|
| 112 |
+
year={2025},
|
| 113 |
+
url={https://huggingface.co/PleoMorph/ctem-g2pm-models}
|
| 114 |
+
}
|
| 115 |
```
|
| 116 |
|
| 117 |
+
## License
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
+
MIT License
|
|
|
|
|
|