Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- graph-neural-network
|
| 6 |
+
- rgcn
|
| 7 |
+
- heterogeneous-graph
|
| 8 |
+
- cybersecurity
|
| 9 |
+
- anomaly-detection
|
| 10 |
+
- pytorch-geometric
|
| 11 |
+
- multi-cloud
|
| 12 |
+
- threat-detection
|
| 13 |
+
pipeline_tag: graph-ml
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Stage 6: Heterogeneous RGCN — Multi-Cloud Threat Detection
|
| 17 |
+
|
| 18 |
+
Part of the research project:
|
| 19 |
+
**Intelligent Threat Detection using GNN in Multi-Cloud Environments**
|
| 20 |
+
|
| 21 |
+
## Architecture
|
| 22 |
+
|
| 23 |
+
| Property | Value |
|
| 24 |
+
|---|---|
|
| 25 |
+
| Model | Heterogeneous RGCN (RGCNConv) |
|
| 26 |
+
| Framework | PyTorch Geometric |
|
| 27 |
+
| Init Strategy | GraphSAGE-style projection (Stanford) |
|
| 28 |
+
| PEFT | GNN Adapter layers (residual bottleneck) |
|
| 29 |
+
| Hidden Dim | 256 |
|
| 30 |
+
| Output Dim | 128 |
|
| 31 |
+
| Layers | 3 |
|
| 32 |
+
| Node Types | user, device, cve, cloud, role, ip |
|
| 33 |
+
| Edge Types | assumes_role, accesses, connects_to, has_vuln, deployed_on, lateral_movement, exploits, grants_access |
|
| 34 |
+
| Task | Node threat scoring + edge anomaly detection |
|
| 35 |
+
| Best Val AUC | 0.9853 |
|
| 36 |
+
|
| 37 |
+
## Graph Schema
|
| 38 |
+
|
| 39 |
+
```
|
| 40 |
+
user ──assumes_role──► role ──grants_access──► cloud
|
| 41 |
+
user ──accesses──────► device ──has_vuln──────► cve
|
| 42 |
+
user ──connects_to───► ip ──connects_to───────► device
|
| 43 |
+
device ──lateral_movement──► device
|
| 44 |
+
device ──deployed_on──► cloud
|
| 45 |
+
cve ──exploits──────────────► device
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Sample Output
|
| 49 |
+
|
| 50 |
+
```
|
| 51 |
+
Node: user_4456
|
| 52 |
+
Type: user
|
| 53 |
+
Probability: 0.7231
|
| 54 |
+
Risk: 🔴 HIGH
|
| 55 |
+
Top Edge: lateral_movement
|
| 56 |
+
|
| 57 |
+
Influence per relation:
|
| 58 |
+
lateral_movement +0.21031
|
| 59 |
+
has_vuln +0.14203
|
| 60 |
+
assumes_role +0.08821
|
| 61 |
+
accesses −0.03102
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## How to Load
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
import torch, json
|
| 68 |
+
from huggingface_hub import hf_hub_download
|
| 69 |
+
|
| 70 |
+
weights_path = hf_hub_download(repo_id="adarsh-aur/Heterogenous_GNN", filename="model_final.pt")
|
| 71 |
+
config_path = hf_hub_download(repo_id="adarsh-aur/Heterogenous_GNN", filename="config.json")
|
| 72 |
+
|
| 73 |
+
with open(config_path) as f:
|
| 74 |
+
cfg = json.load(f)
|
| 75 |
+
|
| 76 |
+
model = HeteroRGCN(
|
| 77 |
+
feat_dims = cfg["feat_dims"],
|
| 78 |
+
node_types = cfg["node_types"],
|
| 79 |
+
edge_types = [tuple(et) for et in cfg["edge_types"]],
|
| 80 |
+
hidden_dim = cfg["hidden_dim"],
|
| 81 |
+
out_dim = cfg["out_dim"],
|
| 82 |
+
num_layers = cfg["num_layers"],
|
| 83 |
+
dropout = cfg["dropout"],
|
| 84 |
+
adapter_rank = cfg["adapter_rank"],
|
| 85 |
+
predict_types = cfg["predict_types"],
|
| 86 |
+
)
|
| 87 |
+
model.load_state_dict(torch.load(weights_path, map_location="cpu"))
|
| 88 |
+
model.eval()
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
## Pipeline Position
|
| 92 |
+
|
| 93 |
+
| Stage | Component |
|
| 94 |
+
|---|---|
|
| 95 |
+
| Stage 5 | Graph Construction + Feature Fusion |
|
| 96 |
+
| **Stage 6** | **Heterogeneous Structural GNN ← this model** |
|
| 97 |
+
| Stage 7 | Temporal GNN |
|
| 98 |
+
| Stage 8 | Risk Fusion MLP |
|
| 99 |
+
|
| 100 |
+
## Training Details
|
| 101 |
+
|
| 102 |
+
| Property | Value |
|
| 103 |
+
|---|---|
|
| 104 |
+
| Optimizer | AdamW |
|
| 105 |
+
| Scheduler | CosineAnnealingWarmRestarts |
|
| 106 |
+
| Loss | BCEWithLogitsLoss + pos_weight (imbalance correction) |
|
| 107 |
+
| Epochs | 150 |
|
| 108 |
+
| Hardware | Kaggle T4 x2 |
|