Downloads · 30 days
14
1% of all-time downloads
simonlevine/clinical-longformer
clinical-longformer is a fill-mask model from simonlevine. Use it when you need the model to fill a missing word. It is set up for transformers.
- You'll need to instantiate a special RoBERTa class. Though technically a "Longformer", the elongated RoBERTa model will still need to be pulled in as such. - To do so, use the following classes:
Downloads · 30 days
14
1% of all-time downloads
All-time downloads
1.9K
Public
Repo size
2.3 GB
Likes
0
Public
Click a slice to open those files.
.bin595 MB · 54%
From the Hugging Face model README
class RobertaLongSelfAttention(LongformerSelfAttention):
def forward(
self,
hidden_states,
attention_mask=None,
head_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
output_attentions=False,
):
return super().forward(hidden_states, attention_mask=attention_mask, output_attentions=output_attentions)
class RobertaLongForMaskedLM(RobertaForMaskedLM):
def __init__(self, config):
super().__init__(config)
for i, layer in enumerate(self.roberta.encoder.layer):
# replace the `modeling_bert.BertSelfAttention` object with `LongformerSelfAttention`
layer.attention.self = RobertaLongSelfAttention(config, layer_id=i)
RobertaLongForMaskedLM.from_pretrained('simonlevine/bioclinical-roberta-long')RobertaForMaskedLM with a different task-specific RoBERTa from Huggingface, such as RobertaForSequenceClassification.