Skip to content

About

Domain-Specific LLM Fine Tuning

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Domain-Specific LLM Fine Tuning

This repository demonstrates the fine-tuning of Qwen-1.5B using QLoRA on the PubMedQA dataset. The project focuses on enhancing the model's reasoning capabilities and instruction-following accuracy in the specialized medical domain under constrained computational resources.

Key Constraints & Design Choices

This project was designed under the following constraints:

  • Single-GPU environment with limited VRAM(8GB)
  • No access to full fine-tuning or large batch training
  • Requirement for reproducible, leakage-free evaluation

To address these constraints, the following design choices were made:

  • QLoRA (4-bit NF4 quantization) to enable fine-tuning of a 1.5B model on limited hardware
  • LoRA adapters applied to attention and MLP projections to balance capacity and stability

Dataset & Prompt Engineering

The PubMedQA (pqa_labeled) dataset was used for supervised fine-tuning. Each example consists of a biomedical question, multiple context sentences, and a ternary decision label: yes / no / maybe.

A chat-based instruction format was adopted to align with the Qwen-Instruct model. Special care was taken to ensure that ground-truth answers were excluded during evaluation to prevent label leakage.

Training Configuration

  • Base model: Qwen2.5-1.5B-Instruct
  • Quantization: 4-bit NF4 (bitsandbytes)
  • LoRA rank: 16
  • LoRA alpha: 32
  • Batch size (effective): 16 (via gradient accumulation)
  • Max sequence length: 2048
  • Optimizer: AdamW
  • Training steps: 400

Evaluation Methodology

Evaluation was performed on a held-out test split that was never observed during training.

Unlike loss-based evaluation, model performance was measured using end-to-end generation:

  1. The model was prompted without the ground-truth answer
  2. A single-token decision (yes / no / maybe) was generated
  3. Predictions were compared directly against gold labels

Both the base model and the fine-tuned model were evaluated under identical 4-bit quantization settings to ensure a fair comparison.

Performance Analysis

1. Training Convergence

The following chart shows the training loss over steps, indicating a stable convergence.

Training Loss

2. Accuracy Comparison

The fine-tuned model shows a significant improvement in clinical decision accuracy compared to the base model.

Accuracy Comparison

This represents a +13% absolute improvement under a strict, leakage-free evaluation protocol.

Future Work

  • Explore logit-based evaluation for more precise uncertainty modeling
  • Extend the approach to retrieval-augmented medical QA

References

  • PubMedQA Dataset: Jin, Q., Dhingra, B., Liu, Z., Cohen, W., & Lu, X. (2019). PubMedQA: A Dataset for Biomedical Research Question Answering. In Proceedings of EMNLP-IJCNLP 2019. https://pubmedqa.github.io/
  • Qwen2.5-1.5B-Instruct: Alibaba Cloud Qwen Team

About

Domain-Specific LLM Fine Tuning

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages