ewhk9887 commited on
Commit
5f7e3fc
·
verified ·
1 Parent(s): f7b3c78

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +64 -0
README.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ language: en
4
+ tags:
5
+ - vulnerability-detection
6
+ - code-analysis
7
+ - autoencoder
8
+ - anomaly-detection
9
+ library_name: pytorch
10
+ metrics:
11
+ - mse
12
+ ---
13
+
14
+ # CATastrophe - Code Vulnerability Detector
15
+
16
+ This model is an autoencoder-based vulnerability detector for Python code. It uses TF-IDF
17
+ vectorization and an autoencoder architecture to detect anomalies in code that may indicate
18
+ vulnerabilities.
19
+
20
+ ## Model Details
21
+
22
+ - **Architecture**: Autoencoder (Input → 512 → 128 → 512 → Input)
23
+ - **Input Features**: 2000 (TF-IDF)
24
+ - **Training Loss**: 0.0005
25
+ - **Framework**: PyTorch
26
+
27
+ ## Usage
28
+
29
+ ```python
30
+ import torch
31
+ import pickle
32
+ from model import Autoencoder
33
+
34
+ # Load model
35
+ model = Autoencoder(input_dim=2000)
36
+ model.load_state_dict(torch.load('catastrophe_model.pth'))
37
+ model.eval()
38
+
39
+ # Load vectorizer
40
+ with open('vectorizer.pkl', 'rb') as f:
41
+ vectorizer = pickle.load(f)
42
+
43
+ # Analyze code
44
+ code_text = "your code here"
45
+ features = vectorizer.transform([code_text]).toarray()
46
+ features_tensor = torch.tensor(features, dtype=torch.float32)
47
+
48
+ with torch.no_grad():
49
+ reconstructed = model(features_tensor)
50
+ anomaly_score = torch.mean((features_tensor - reconstructed) ** 2, dim=1)
51
+ ```
52
+
53
+ ## Training Configuration
54
+
55
+ - Batch Size: 256
56
+ - Epochs: 50
57
+ - Learning Rate: 0.001
58
+ - Optimizer: Adam
59
+
60
+ ## Limitations
61
+
62
+ This model is trained on vulnerable commits only and uses reconstruction error as an
63
+ anomaly score. High scores indicate potential vulnerabilities, but manual review is
64
+ recommended.