Update README.md
Browse files
README.md
CHANGED
|
@@ -62,11 +62,6 @@ from huggingface_hub import hf_hub_download
|
|
| 62 |
import json
|
| 63 |
|
| 64 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 65 |
-
# Load explicitly your fine-tuned MPNet model
|
| 66 |
-
classifier_model = AutoModelForSequenceClassification.from_pretrained("selfconstruct3d/AttackGroup-MPNET").to(device)
|
| 67 |
-
|
| 68 |
-
# Load explicitly your tokenizer
|
| 69 |
-
tokenizer = AutoTokenizer.from_pretrained("selfconstruct3d/AttackGroup-MPNET")
|
| 70 |
|
| 71 |
|
| 72 |
label_to_groupid_file = hf_hub_download(
|
|
@@ -77,6 +72,12 @@ label_to_groupid_file = hf_hub_download(
|
|
| 77 |
with open(label_to_groupid_file, "r") as f:
|
| 78 |
label_to_groupid = json.load(f)
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
def predict_group(sentence):
|
| 81 |
classifier_model.eval()
|
| 82 |
encoding = tokenizer(
|
|
@@ -109,13 +110,25 @@ Predicted GroupID: G0001
|
|
| 109 |
```python
|
| 110 |
import torch
|
| 111 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
|
|
|
|
|
| 112 |
|
| 113 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
# Load your fine-tuned classification model
|
| 116 |
model_name = "selfconstruct3d/AttackGroup-MPNET"
|
| 117 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 118 |
-
classifier_model = AutoModelForSequenceClassification.from_pretrained(model_name).to(device)
|
| 119 |
|
| 120 |
def get_embedding(sentence):
|
| 121 |
classifier_model.eval()
|
|
|
|
| 62 |
import json
|
| 63 |
|
| 64 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
label_to_groupid_file = hf_hub_download(
|
|
|
|
| 72 |
with open(label_to_groupid_file, "r") as f:
|
| 73 |
label_to_groupid = json.load(f)
|
| 74 |
|
| 75 |
+
# Load explicitly your fine-tuned MPNet model
|
| 76 |
+
classifier_model = AutoModelForSequenceClassification.from_pretrained("selfconstruct3d/AttackGroup-MPNET", num_labels=len(label_to_groupid)).to(device)
|
| 77 |
+
|
| 78 |
+
# Load explicitly your tokenizer
|
| 79 |
+
tokenizer = AutoTokenizer.from_pretrained("selfconstruct3d/AttackGroup-MPNET")
|
| 80 |
+
|
| 81 |
def predict_group(sentence):
|
| 82 |
classifier_model.eval()
|
| 83 |
encoding = tokenizer(
|
|
|
|
| 110 |
```python
|
| 111 |
import torch
|
| 112 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 113 |
+
from huggingface_hub import hf_hub_download
|
| 114 |
+
import json
|
| 115 |
|
| 116 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 117 |
|
| 118 |
+
|
| 119 |
+
label_to_groupid_file = hf_hub_download(
|
| 120 |
+
repo_id="selfconstruct3d/AttackGroup-MPNET",
|
| 121 |
+
filename="label_to_groupid.json"
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
with open(label_to_groupid_file, "r") as f:
|
| 125 |
+
label_to_groupid = json.load(f)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
# Load your fine-tuned classification model
|
| 129 |
model_name = "selfconstruct3d/AttackGroup-MPNET"
|
| 130 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 131 |
+
classifier_model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=len(label_to_groupid)).to(device)
|
| 132 |
|
| 133 |
def get_embedding(sentence):
|
| 134 |
classifier_model.eval()
|