Views
No views yet
1import torch
2import pickle
3from transformers import AutoTokenizer, AutoModel
4
5# Load the model
6with open('multitask_bert_model.pkl', 'rb') as f:
7 model = pickle.load(f)
8
9# Load tokenizer (adjust model name as needed)
10tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
11
12# Example usage
13text = "Apple stock rises 5% after strong quarterly earnings report"
14inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=512)
15
16# Get predictions (adjust based on your model's output format)
17with torch.no_grad():
18 outputs = model(**inputs)
19 # Process outputs for topic and sentiment predictionsmultitask_bert_model.pkl: Base modelmultitask_bert_model_weight.pth: Weighted versionmultitask_bert_model_imbalanced.pth: Version trained on imbalanced data| Task | Metric | Score |
|---|---|---|
| Topic Classification | Accuracy | 0.76 |
| Sentiment Analysis | Accuracy | 0.87 |