Instructions to use bootscoder/Llama-3-Medical-8B-SFT-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use bootscoder/Llama-3-Medical-8B-SFT-LoRA with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("/home/haoxuan004/LLaMA-8B-DeepSpeed/output/pretrained-full") model = PeftModel.from_pretrained(base_model, "bootscoder/Llama-3-Medical-8B-SFT-LoRA") - Transformers
How to use bootscoder/Llama-3-Medical-8B-SFT-LoRA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bootscoder/Llama-3-Medical-8B-SFT-LoRA")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("bootscoder/Llama-3-Medical-8B-SFT-LoRA", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use bootscoder/Llama-3-Medical-8B-SFT-LoRA with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bootscoder/Llama-3-Medical-8B-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": "bootscoder/Llama-3-Medical-8B-SFT-LoRA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bootscoder/Llama-3-Medical-8B-SFT-LoRA
- SGLang
How to use bootscoder/Llama-3-Medical-8B-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 "bootscoder/Llama-3-Medical-8B-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": "bootscoder/Llama-3-Medical-8B-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 "bootscoder/Llama-3-Medical-8B-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": "bootscoder/Llama-3-Medical-8B-SFT-LoRA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bootscoder/Llama-3-Medical-8B-SFT-LoRA with Docker Model Runner:
docker model run hf.co/bootscoder/Llama-3-Medical-8B-SFT-LoRA
Llama-3-Medical-8B-SFT-LoRA
This is a LoRA adapter for Meta-Llama-3-8B, fine-tuned on medical domain data using Supervised Fine-Tuning (SFT).
Model Details
- Base Model: Meta-Llama-3-8B
- Training Method: QLoRA (Quantized Low-Rank Adaptation)
- Training Framework: TRL + DeepSpeed + PEFT
- Domain: Medical
- Languages: English and Chinese
- License: Llama 3 License
Training Details
This LoRA adapter was trained using:
- Method: Supervised Fine-Tuning (SFT) with QLoRA
- Framework: Hugging Face TRL, PEFT, DeepSpeed
- Data: Medical domain datasets including medical Q&A, clinical notes, and medical knowledge
- LoRA Rank: Check
adapter_config.jsonfor details - Training Precision: Mixed precision (bf16/fp16)
Usage
To use this LoRA adapter, you need to:
- Install required packages:
pip install transformers peft torch
- Load the model with LoRA adapter:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model
base_model = "meta-llama/Meta-Llama-3-8B"
model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(base_model)
# Load LoRA adapter
model = PeftModel.from_pretrained(model, "bootscoder/Llama-3-Medical-8B-SFT-LoRA")
# Generate text
inputs = tokenizer("What is diabetes?", return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- Or merge LoRA with base model:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model = "meta-llama/Meta-Llama-3-8B"
model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype="auto")
model = PeftModel.from_pretrained(model, "bootscoder/Llama-3-Medical-8B-SFT-LoRA")
# Merge and save
merged_model = model.merge_and_unload()
merged_model.save_pretrained("./merged_model")
Intended Use
This model is intended for:
- Medical question answering
- Medical text generation
- Research and educational purposes in healthcare domain
Limitations
- This model is for research purposes only
- Should not be used for clinical decision-making without professional medical oversight
- May generate inaccurate or hallucinated medical information
- Requires careful validation before any real-world application
Training Infrastructure
- Hardware: NVIDIA GPUs with DeepSpeed optimization
- Software: PyTorch, Transformers, PEFT 0.17.1, TRL, DeepSpeed
Citation
If you use this model, please cite:
@misc{llama3-medical-8b-sft-lora,
author = {bootscoder},
title = {Llama-3-Medical-8B-SFT-LoRA},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/bootscoder/Llama-3-Medical-8B-SFT-LoRA}
}
Disclaimer
This model is provided as-is for research and educational purposes. The outputs should not be used as medical advice. Always consult with qualified healthcare professionals for medical decisions.
- Downloads last month
- 1
Model tree for bootscoder/Llama-3-Medical-8B-SFT-LoRA
Base model
meta-llama/Meta-Llama-3-8B