Views
No views yet
vinai/phobert-base-v2 on Vietnamese perioperative clinical notes for the AKI prediction task.vinai/phobert-base-v2[FIELD=LYDOVAOVIEN], [FIELD=BENHCHINH], [FIELD=CONTENT]).1from transformers import AutoModel, AutoTokenizer
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained('banhchungtuongot/phobert-aki-clinical-v4', trust_remote_code=True)
5model = AutoModel.from_pretrained('banhchungtuongot/phobert-aki-clinical-v4', trust_remote_code=True).eval()
6
7enc = tokenizer(['[FIELD=BENHCHINH] phẫu thuật tim'], return_tensors='pt', truncation=True)
8with torch.no_grad():
9 out = model(**enc)
10 mask = enc['attention_mask'].unsqueeze(-1).float()
11 embedding = (out.last_hidden_state * mask).sum(1) / mask.sum(1)