Text Classification
Transformers
Safetensors
English
bert
adverse-drug-events
drug-safety
pharmacovigilance
biomedical
PubMedBERT
text-embeddings-inference
Instructions to use tatonettilab/onsides-bert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tatonettilab/onsides-bert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="tatonettilab/onsides-bert")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("tatonettilab/onsides-bert") model = AutoModelForSequenceClassification.from_pretrained("tatonettilab/onsides-bert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload OnSIDES production model (PubMedBERT fine-tuned for adverse drug event classification)
526f371 verified | import torch | |
| from torch import nn | |
| from transformers import BertModel, PreTrainedModel | |
| from .configuration_onsides import OnsidesConfig | |
| class OnsidesForClassification(PreTrainedModel): | |
| """PubMedBERT fine-tuned to classify adverse drug events in product labels. | |
| Two-class classifier: 0 = not_event, 1 = is_event. | |
| Output logits are passed through ReLU (matching the training setup). | |
| """ | |
| config_class = OnsidesConfig | |
| def __init__(self, config): | |
| super().__init__(config) | |
| self.bert = BertModel(config) | |
| self.dropout = nn.Dropout(config.classifier_dropout) | |
| self.linear = nn.Linear(config.hidden_size, config.num_labels) | |
| self.relu = nn.ReLU() | |
| self.post_init() | |
| def forward(self, input_ids, attention_mask=None, **kwargs): | |
| outputs = self.bert( | |
| input_ids=input_ids, attention_mask=attention_mask, return_dict=False | |
| ) | |
| pooled_output = outputs[1] | |
| return self.relu(self.linear(self.dropout(pooled_output))) | |