Downloads · 30 days
9
5% of all-time downloads
Ghufran27/medical-llama2-7b
medical-llama2-7b is a text generation model from Ghufran27. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as llama2.
--- license: llama2 tags: - medical - llm - fine-tuned - llama-2 - medical-qa - instruction-tuned ---
Downloads · 30 days
9
5% of all-time downloads
All-time downloads
176
Public
Parameters
6.7B
13.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors13.5 GB · 100%
From the Hugging Face model README
license: llama2 tags:
Medical Llama-2-7b is an instruction-tuned language model optimized for medical question-answering, built upon NousResearch/Llama-2-7b-chat-hf. Developed to address the growing need for accessible, domain-specific AI in healthcare, this model leverages Low-Rank Adaptation (LoRA) to fine-tune a 7-billion-parameter Llama-2 base model on a custom medical dataset (cleaned_medical.jsonl). The dataset comprises high-quality question-answer pairs sourced from medical literature and cleaned to ensure accuracy and relevance, focusing on topics like disease diagnosis, treatment protocols, and medical terminology.
The model employs 4-bit quantization (NF4) with float16 precision to enable efficient training and inference on resource-constrained environments, such as Kaggle GPUs. Custom prompt engineering, using [INST] tags and a system instruction, restricts responses to medical queries, enhancing reliability for healthcare applications. This makes the model ideal for medical education, clinical research support, and preliminary patient query resolution, while adhering to open-source principles for transparency and reproducibility.
Designed for the Open Medical-LLM Leaderboard, Medical Llama-2-7b aims to contribute to the advancement of open-source medical AI by providing a robust, specialized model for evaluating and benchmarking medical knowledge.
NousResearch/Llama-2-7b-chat-hf (7 billion parameters)cleaned_medical.jsonl), containing medical question-answer pairs formatted with [INST] tagsr): 8lora_alpha): 16lora_dropout): 0.05q_proj, v_projCAUSAL_LMBitsAndBytesConfig:
torch.float16[INST] <<SYS>> ... <</SYS>> ... [/INST]model-00001-of-00003.safetensors, etc.)To load and use the model for medical question-answering:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"Ghufran27/medical-llama2-7b",
torch_dtype=torch.float16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Ghufran27/medical-llama2-7b")
# Prepare input
text = "[INST] What is the treatment for hypertension? [/INST]"
inputs = tokenizer(text, return_tensors="pt").to("cuda")
# Generate response
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))