Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- qwedxzawsedr/emorag_defense
|
5 |
+
metrics:
|
6 |
+
- accuracy
|
7 |
+
base_model:
|
8 |
+
- google-bert/bert-base-uncased
|
9 |
+
pipeline_tag: text-classification
|
10 |
+
---
|
11 |
+
# Malicious Text Detection Model for EmoRAG
|
12 |
+
## Model Description
|
13 |
+
This model is designed to detect malicious texts, particularly those containing emoticons, using a BERT-based architecture.
|
14 |
+
## Intended Use
|
15 |
+
- **Primary Use**: Detection of malicious texts containing emoticons.
|
16 |
+
- **Applications**:
|
17 |
+
- Content moderation for online platforms.
|
18 |
+
- Adversarial text filtering in natural language processing pipelines.
|
19 |
+
- Research on malicious text detection and adversarial attacks.
|
20 |
+
|
21 |
+
Each data point contains up to eight emoticons, and the dataset was carefully curated to ensure diversity and balance.
|
22 |
+
## How to Use the Model
|
23 |
+
You can load and use the trained BERT-based model for malicious text detection with the following code:
|
24 |
+
```python
|
25 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
26 |
+
import torch
|
27 |
+
|
28 |
+
# Load the trained model and tokenizer
|
29 |
+
model = BertForSequenceClassification.from_pretrained('path_to_your_model')
|
30 |
+
tokenizer = BertTokenizer.from_pretrained('path_to_your_model')
|
31 |
+
|
32 |
+
# Example text (malicious with emoticons)
|
33 |
+
text = "However, there (●′ω`●) is any huge evidence ⊙︿⊙ that one single drug shot may induce a permanent ƪ(•̃͡ε•̃͡)∫ʃ psychotic disorder. +ˍ+ The other hand is in regards of the the use of dopaminergic agonists in Parkinson desease, what did (ΘoΘ) not ╰(*´︶`*)╯ show in that patients a ゚ヽ(●´ω`●)ノ。 psychotic disorder but induce a hard psychotic effect in a normal subject mainly mixed 桃カラ≪( \(・ω・)/ )≫オハヨゥ☆ with alcholl.",
|
34 |
+
|
35 |
+
# Tokenize the input text
|
36 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
37 |
+
|
38 |
+
# Make a prediction
|
39 |
+
with torch.no_grad():
|
40 |
+
outputs = model(**inputs)
|
41 |
+
logits = outputs.logits
|
42 |
+
prediction = torch.argmax(logits, dim=-1)
|
43 |
+
|
44 |
+
# Print the prediction
|
45 |
+
print(f"Prediction: {'Malicious' if prediction.item() == 1 else 'Clean'}")
|