Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load the model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("your-username/infrnce-bert-log-classifier")
6model = AutoModelForSequenceClassification.from_pretrained("your-username/infrnce-bert-log-classifier")
7
8# Example usage
9log_text = "Your OpenStack log entry here"
10inputs = tokenizer(log_text, return_tensors="pt", truncation=True, padding=True, max_length=512)
11
12with torch.no_grad():
13 outputs = model(**inputs)
14 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
15 predicted_class_id = predictions.argmax().item()
16
17print(f"Predicted class: {model.config.id2label[predicted_class_id]}")