Views
No views yet
pip install torch transformers1from model import TransformerMultiLabelClassifier
2from transformers import AutoTokenizer
3import torch
4
5# Load the model
6model = TransformerMultiLabelClassifier.from_pretrained("path/to/saved/model")
7tokenizer = AutoTokenizer.from_pretrained("path/to/saved/model")
8
9# Prepare input
10text = "আপনার বাংলা টেক্সট এখানে"
11inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
12
13# Get predictions
14outputs = model.predict(inputs['input_ids'], inputs['attention_mask'])
15
16probabilities = outputs['probabilities'][0]
17predictions = outputs['predictions'][0]
18
19labels = ['bully', 'sexual', 'religious', 'threat', 'spam']
20for label, prob, pred in zip(labels, probabilities, predictions):
21 status = "✓ Detected" if pred else "✗ Not detected"
22 print(f"{label}: {prob:.4f} ({status})")1# For batch inference
2texts = ["টেক্সট ১", "টেক্সট ২", "টেক্সট ৩"]
3inputs = tokenizer(texts, return_tensors="pt", truncation=True, padding=True, max_length=128)
4outputs = model.predict(inputs['input_ids'], inputs['attention_mask'])| Label | Description |
|---|---|
| bully | General bullying content |
| sexual | Sexual harassment or inappropriate content |
| religious | Religious hate or discrimination |
| threat | Threatening content |
| spam | Spam or irrelevant content |
1@misc{bangla-cyberbullying-detection,
2 author = {Your Name},
3 title = {Bangla Cyberbullying Detection Model},
4 year = {2024},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/your-username/your-model}
7}