Views
No views yet
1from peft import AutoPeftModelForCausalLM, AutoPeftModelForSequenceClassification
2from transformers import AutoTokenizer
3
4model_name = "NTaylor/bio-mobilebert-mimic-mp-lora"
5
6# load using AutoPeftModelForSequenceClassification
7model = AutoPeftModelForSequenceClassification.from_pretrained(lora_id)
8
9# use base llama tokenizer
10tokenizer = AutoTokenizer.from_pretrained("nlpie/bio-mobilebert")
11
12# example input
13text = "Clinical note..."
14inputs = tokenizer(text, return_tensors="pt")
15outputs = reloaded_model(**inputs)
16# extract prediction from outputs based on argmax of logits
17pred = torch.argmax(outputs.logits, axis = -1)
18print(f"Prediction is: {pred}") # binary classification: 1 for mortality@misc{taylor2024efficiency,
title={Efficiency at Scale: Investigating the Performance of Diminutive Language Models in Clinical Tasks},
author={Niall Taylor and Upamanyu Ghose and Omid Rohanian and Mohammadmahdi Nouriborji and Andrey Kormilitzin and David Clifton and Alejo Nevado-Holgado},
year={2024},
eprint={2402.10597},
archivePrefix={arXiv},
primaryClass={cs.CL}
}