Downloads · 30 days
1
6% of all-time downloads
segestic/phi2_medical_seg
phi2_medical_seg is a text generation model from segestic. Use it when you need the model to write or continue text. The card lists the license as mit.
Phi2medseg is a fine-tuned version of the Phi-2 model, specifically optimized for medical applications. This model has been trained using the Trainer framework on several different datasets from the MedAlpaca collecti…
Downloads · 30 days
1
6% of all-time downloads
All-time downloads
18
Public
Repo size
105 MB
Likes
0
Public
Click a slice to open those files.
.safetensors105 MB · 99%
From the Hugging Face model README
Phi2_med_seg is a fine-tuned version of the Phi-2 model, specifically optimized for medical applications. This model has been trained using the Trainer framework on several different datasets from the MedAlpaca collection, which focuses on medical question answering and conversational AI. This model can answer information about different excplicit ideas in medicine
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
base_model_id = "microsoft/phi-2"
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id, # Phi2, same as before
device_map="auto",
trust_remote_code=True,
load_in_8bit=True,
torch_dtype=torch.float16,
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
eval_tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True, use_fast=False)
eval_tokenizer.pad_token = tokenizer.eos_token
from peft import PeftModel
adapter_model_id = "segestic/phi2_medical_seg"
ft_model = PeftModel.from_pretrained(base_model, adapter_model_id)
eval_prompt = "What is medicine?"
model_input = eval_tokenizer(eval_prompt, return_tensors="pt").to("cuda")
ft_model.eval()
with torch.no_grad():
print(eval_tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=100, repetition_penalty=1.11)[0], skip_special_tokens=True))
The fine-tuning process involved leveraging various medical datasets to enhance the model's ability to understand and generate relevant medical information. This approach aims to improve the model's performance in medical contexts, making it a valuable tool for healthcare professionals and researchers alike. By utilizing the Trainer framework, Phi2_med_seg benefits from advanced training techniques that help refine its responses and accuracy in medical scenarios.
Architecture: a Transformer-based model with next-word prediction objective
Context length: 2048 tokens