Instructions to use ImaginedTime/medical-sft-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ImaginedTime/medical-sft-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/llama-3-8b-bnb-4bit") model = PeftModel.from_pretrained(base_model, "ImaginedTime/medical-sft-lora") - Transformers
How to use ImaginedTime/medical-sft-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ImaginedTime/medical-sft-lora")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ImaginedTime/medical-sft-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ImaginedTime/medical-sft-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ImaginedTime/medical-sft-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ImaginedTime/medical-sft-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ImaginedTime/medical-sft-lora
- SGLang
How to use ImaginedTime/medical-sft-lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ImaginedTime/medical-sft-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ImaginedTime/medical-sft-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ImaginedTime/medical-sft-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ImaginedTime/medical-sft-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ImaginedTime/medical-sft-lora with Docker Model Runner:
docker model run hf.co/ImaginedTime/medical-sft-lora
medical-sft-lora
This model is a fine-tuned version of unsloth/llama-3-8b-bnb-4bit on the FreedomIntelligence/medical-o1-reasoning-SFT dataset, a specialized dataset designed for medical question-answering with chain-of-thought reasoning.
Model description
This model has been supervised fine-tuned using parameter-efficient fine-tuning (PEFT) with LoRA adapters on a medical question-answering dataset. It is intended to offer detailed, clinically reasoned answers to medical queries by following explicit chain-of-thought explanations, improving on the base LLMโs understanding of medical reasoning and diagnosis.
Intended uses & limitations
- Intended for research and educational purposes involving medical question-answering and reasoning.
- Useful for generating detailed step-by-step medical explanations and diagnoses.
- Not intended to replace professional medical advice, diagnosis, or treatment.
- Users should critically assess outputs and consult qualified healthcare professionals for decision-making.
Training and evaluation data
- Dataset: FreedomIntelligence/medical-o1-reasoning-SFT (English split).
- Dataset samples contain medical questions, chain-of-thought detailed reasoning, and final concise answers.
- The first 500 samples were used for supervised fine-tuning according to assignment requirements.
Training procedure
Fine-tuning was performed on the base model "unsloth/llama-3-8b-bnb-4bit", a 4-bit quantized LLM suitable for Colab GPU environments. The training used Hugging Face Transformers and PEFT libraries with the following steps:
- Prompt templates were engineered to enforce detailed clinical reasoning and stepwise explanations.
- Each training example combined a medical question, chain-of-thought reasoning, and final answer into the prompt-response pair.
- LoRA adapters were applied, targeting the
q_projandv_projtransformer modules.
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 1
- eval_batch_size: 8
- seed: 42
- gradient_accumulation_steps: 8
- total_train_batch_size: 8
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
- lr_scheduler_type: linear
- num_epochs: 3
- mixed_precision_training: Native AMP (fp16)
Training results
- Post-fine-tuning evaluation showed a marked improvement over the base model.
- The fine-tuned version generates more accurate medical reasoning with logical step-by-step explanations aligned with clinical knowledge.
- Outputs included clearer diagnoses and more relevant responses as compared to the base model.
Framework versions
- PEFT 0.17.1
- Transformers 4.55.4
- Pytorch 2.8.0+cu126
- Datasets 3.6.0
- Tokenizers 0.21.4
- Downloads last month
- 8
Model tree for ImaginedTime/medical-sft-lora
Base model
meta-llama/Meta-Llama-3-8B