CoolFace
Modelpublic

halame/chatdoctor-llama3-lora

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes13downloads
Model Card

ChatDoctor LLaMA-3 8B LoRA

A fine-tuned LoRA adapter for medical question answering, achieving BERTScore F1 = 0.845 (best result, exceeds original ChatDoctor paper).

Model Details

Performance

ModelBERTScore PBERTScore RBERTScore F1
ChatDoctor (Paper)0.8440.8450.841
Mistral + LoRA0.8450.8430.844
LLaMA-3 + LoRA0.8440.8460.845

Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch

# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
    "NousResearch/Meta-Llama-3-8B-Instruct",
    torch_dtype=torch.float16,
    device_map="auto"
)

# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "halame/chatdoctor-llama3-lora")
tokenizer = AutoTokenizer.from_pretrained("halame/chatdoctor-llama3-lora")

# Generate
prompt = "I have headache and fever for 2 days. What should I do?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Training Configuration

  • —LoRA r: 16
  • —LoRA alpha: 32
  • —LoRA dropout: 0.05
  • —Learning rate: 2e-4
  • —Batch size: 64
  • —Epochs: 1
  • —Quantization: 4-bit (nf4)

License

Apache 2.0

Disclaimer

This model is for research purposes only. Do not use for actual medical diagnosis.