Views
No views yet
| Metric | Value |
|---|---|
| F1 Score | N/A |
| Accuracy | N/A |
| Unsafe F1 | N/A |
benignjailbreakS1 Violent CrimesS2 Non-Violent CrimesS4 Child Sexual ExploitationS7 PrivacyS10 HateS11 Self-HarmS12 Sexual ContentS14 Code Abuse1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("jainsatyam26/bertclassfier")
5model = AutoModelForSequenceClassification.from_pretrained("jainsatyam26/bertclassfier")
6
7def predict(text):
8 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
9 with torch.no_grad():
10 outputs = model(**inputs)
11 probs = torch.softmax(outputs.logits, dim=-1)
12 predicted_id = torch.argmax(probs, dim=-1).item()
13
14 labels = ['benign', 'jailbreak', 'S1 Violent Crimes', 'S2 Non-Violent Crimes', 'S4 Child Sexual Exploitation', 'S7 Privacy', 'S10 Hate', 'S11 Self-Harm', 'S12 Sexual Content', 'S14 Code Abuse']
15 return {
16 "prediction": labels[predicted_id],
17 "confidence": probs[0][predicted_id].item(),
18 "all_scores": {labels[i]: probs[0][i].item() for i in range(len(labels))}
19 }
20
21# Example
22result = predict("How to make a bomb?")
23print(result)1{
2 "model_name": "microsoft/deberta-v3-large",
3 "dataset_name": "jainsatyam26/guardrail-215k-splits",
4 "max_length": 512,
5 "epochs": 4,
6 "batch_size": 8,
7 "grad_accum": 4,
8 "learning_rate": 1e-05,
9 "weight_decay": 0.01,
10 "warmup_ratio": 0.1,
11 "use_llrd": true,
12 "llrd_alpha": 0.9,
13 "use_multisample_dropout": true,
14 "num_dropout_samples": 5,
15 "dropout_rate": 0.3,
16 "use_label_smoothing": true,
17 "label_smoothing": 0.1,
18 "use_focal_loss": true,
19 "focal_alpha": 0.7,
20 "focal_gamma": 2.0,
21 "use_hard_negative": true,
22 "hard_negative_ratio": 0.3,
23 "num_folds": 3,
24 "optimize_thresholds": true,
25 "output_dir": "./guardrail_model",
26 "checkpoint_steps": 500,
27 "logging_steps": 50,
28 "eval_steps": 500,
29 "hf_repo_id": "jainsatyam26/bertclassfier",
30 "hf_token": "***REDACTED***",
31 "deploy_every_minutes": 30,
32 "deploy_every_steps": 400,
33 "auto_deploy": true,
34 "private_repo": false,
35 "auto_resume": true,
36 "resume_from_hf": true,
37 "use_wandb": true,
38 "wandb_project": "safety-classifier",
39 "fp16": false,
40 "bf16": true,
41 "dataloader_num_workers": 4,
42 "seed": 42
43}