Text Classification
Transformers
PyTorch
Safetensors
German
roberta
radiology
medical-imaging
chest-ct
multi-label-classification
radbert
german
ctrate
custom_code
text-embeddings-inference
Instructions to use suitch/radbert-german-ctrate-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use suitch/radbert-german-ctrate-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="suitch/radbert-german-ctrate-classifier", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("suitch/radbert-german-ctrate-classifier", trust_remote_code=True) model = AutoModelForSequenceClassification.from_pretrained("suitch/radbert-german-ctrate-classifier", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
| import torch | |
| import torch.nn as nn | |
| from transformers import RobertaModel, RobertaConfig, PreTrainedModel | |
| class RadBertForSequenceClassification(PreTrainedModel): | |
| config_class = RobertaConfig | |
| base_model_prefix = "model" | |
| def __init__(self, config): | |
| super().__init__(config) | |
| num_labels = getattr(config, "num_labels", 2) | |
| self.model = RobertaModel(config) | |
| self.classifier = nn.Linear(config.hidden_size, num_labels) | |
| self.post_init() | |
| def forward( | |
| self, | |
| input_ids=None, | |
| attention_mask=None, | |
| token_type_ids=None, | |
| **kwargs, | |
| ): | |
| outputs = self.model( | |
| input_ids=input_ids, | |
| attention_mask=attention_mask, | |
| token_type_ids=token_type_ids, | |
| **kwargs, | |
| ) | |
| pooled_output = outputs.pooler_output | |
| if pooled_output is None: | |
| pooled_output = outputs.last_hidden_state[:, 0] | |
| return self.classifier(pooled_output) |