Update README.md
Browse files
README.md
CHANGED
|
@@ -33,32 +33,29 @@ It is a classification model and is aimed to assist in classifying vulnerabiliti
|
|
| 33 |
## How to get started with the model
|
| 34 |
|
| 35 |
```python
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
that could severely harm the host system. This could significantly affect the confidentiality, integrity, and availability of the targeted system."
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
...
|
| 60 |
-
Predictions: tensor([[4.9335e-04, 3.4782e-02, 2.6257e-01, 7.0215e-01]])
|
| 61 |
-
Predicted severity: critical
|
| 62 |
```
|
| 63 |
|
| 64 |
### Training hyperparameters
|
|
|
|
| 33 |
## How to get started with the model
|
| 34 |
|
| 35 |
```python
|
| 36 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 37 |
+
import torch
|
| 38 |
+
|
| 39 |
+
labels = ["low", "medium", "high", "critical"]
|
| 40 |
+
|
| 41 |
+
model_name = "CIRCL/vulnerability-severity-classification-distilbert-base-uncased"
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 43 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 44 |
+
model.eval()
|
| 45 |
+
|
| 46 |
+
test_description = "SAP NetWeaver Visual Composer Metadata Uploader is not protected with a proper authorization, allowing unauthenticated agent to upload potentially malicious executable binaries \
|
| 47 |
that could severely harm the host system. This could significantly affect the confidentiality, integrity, and availability of the targeted system."
|
| 48 |
+
inputs = tokenizer(test_description, return_tensors="pt", truncation=True, padding=True)
|
| 49 |
+
|
| 50 |
+
# Run inference
|
| 51 |
+
with torch.no_grad():
|
| 52 |
+
outputs = model(**inputs)
|
| 53 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 54 |
+
|
| 55 |
+
# Print results
|
| 56 |
+
print("Predictions:", predictions)
|
| 57 |
+
predicted_class = torch.argmax(predictions, dim=-1).item()
|
| 58 |
+
print("Predicted severity:", labels[predicted_class])
|
|
|
|
|
|
|
|
|
|
| 59 |
```
|
| 60 |
|
| 61 |
### Training hyperparameters
|