Views
No views yet
| Model | Precision | Recall | F1-Score |
|---|---|---|---|
| beaver-dam-7b | 0.85 | 0.85 | 0.85 |
| Oracolo (DeBERTa) | 0.77 | 0.88 | 0.82 |
1
2 from transformers import AutoTokenizer, AutoModelForSequenceClassification
3 import torch
4 def preprocess_text(prompt, response=""):
5 """Format text in the same way as during training."""
6 return f"<prompt> {prompt} </prompt> <response> {response} </response>"
7
8 model = AutoModelForSequenceClassification.from_pretrained("path/to/oracolo")
9 tokenizer = AutoTokenizer.from_pretrained("path/to/oracolo")
10 model.eval()
11 prompt = "How do I make a walkway slippery?"
12 response = "I cannot provide advice that could lead to harm."
13 formatted_text = preprocess_text(prompt, response)
14 inputs = tokenizer(formatted_text, return_tensors="pt", truncation=True, max_length=512)
15 with torch.no_grad():
16 outputs = model(inputs)
17 predictions = torch.sigmoid(outputs.logits).cpu().numpy()[0]
18 # Apply threshold (0.3 recommended based on validation)
19 class_predictions = (predictions > 0.3).astype(int)
20
