Views
No views yet
1import torch
2from transformers import BertTokenizer, BertForSequenceClassification
3
4tokenizer = BertTokenizer.from_pretrained("shahxeebhassan/bert_base_ai_content_detector")
5model = BertForSequenceClassification.from_pretrained("shahxeebhassan/bert_base_ai_content_detector")
6
7inputs = tokenizer("Distance learning will not benefit students because the students are not able to develop as good of a relationship with their teachers.", return_tensors="pt")
8
9with torch.no_grad():
10 outputs = model(**inputs)
11 logits = outputs.logits
12
13probabilities = torch.softmax(logits, dim=1).cpu().numpy()
14
15predicted_label = probabilities.argmax(axis=1)
16
17print(f"Predicted label for the input text: {predicted_label[0]}")