Downloads · 30 days
6
16% of all-time downloads
poojith-manideep/biogpt-large-medicine-instruction-lora
biogpt-large-medicine-instruction-lora is a text generation model from poojith-manideep. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
This repository contains a LoRA adapter instruction-tuned from microsoft/BioGPT-Large using medicine patient-information leaflet data.
Downloads · 30 days
6
16% of all-time downloads
All-time downloads
38
Public
Repo size
19.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors19.7 MB · 92%
From the Hugging Face model README
This repository contains a LoRA adapter instruction-tuned from
microsoft/BioGPT-Large using medicine patient-information leaflet data.
This is a PEFT adapter, not a standalone full model. It must be loaded together
with microsoft/BioGPT-Large.
q_proj, v_projThe complete instruction dataset contained 50 examples created from 10 cleaned medicine patient-information leaflets.
The adapter was trained with the following format:
Instruction:
<question>
Response:
Example:
Instruction:
What is Paracetamol Tablets used for according to the leaflet?
Response:
Plain questions without this wrapper may produce unreliable results.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model_id = "microsoft/BioGPT-Large"
adapter_id = "YOUR_USERNAME/biogpt-large-medicine-instruction-lora"
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
dtype=torch.float32,
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
instruction = (
"What is Paracetamol Tablets used for according to the leaflet?"
)
prompt = f"Instruction:\n{instruction}\n\nResponse:\n"
inputs = tokenizer(prompt, return_tensors="pt")
with torch.inference_mode():
output_ids = model.generate(
**inputs,
max_new_tokens=100,
do_sample=False,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
new_tokens = output_ids[0, inputs["input_ids"].shape[1]:]
answer = tokenizer.decode(new_tokens, skip_special_tokens=True)
print(answer)
Use float16 and move the model to CUDA when running on a compatible GPU.
This adapter is an educational assignment demonstrating instruction tuning on medicine leaflet content.
microsoft/BioGPT-Large