Turkish-Gemma-9B Medical QA (QLoRA Adapter)

Parameter-efficient fine-tuned LoRA adapter for medical question answering in Turkish.

+50 EM and +49 F1 improvement using QLoRA with only 1.05% trainable parameters.

Overview

This LoRA adapter demonstrates that a decoder-based large language model can be adapted via QLoRA to perform context-grounded medical question answering in Turkish.

Rather than training multiple task-specific encoder models (e.g., NER or extractive QA), we explore whether a single generative model can approximate extractive behavior through structured prompt conditioning.

The fine-tuned adapter improves Exact Match from 4.63% to 54.76% and F1 from 25.80% to 75.39% on the MedTurkQA validation set.

Intended Use

This adapter is designed for context-grounded, single-turn medical question answering in Turkish. Given a passage and a question, the model generates a concise answer conditioned on the provided context.

It expects inputs formatted with the structured Bağlam / Soru / Cevap prompt template described in the Usage section.

The model is intended for research, experimentation, and NLP benchmarking — particularly in the areas of parameter-efficient fine-tuning, Turkish NLP, and domain adaptation of large language models.

It is not intended for clinical decision-making, diagnostic support, or real-world medical deployment.

Outputs should not be interpreted as medical advice and may contain inaccuracies, especially on topics outside the training distribution.

Model Details

Property Value
Base model ytu-ce-cosmos/Turkish-Gemma-9b-v0.1
Method QLoRA (4-bit NF4, double quantization)
Compute dtype float16
LoRA rank 16
LoRA alpha 32
Target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Trainable parameters 54M / 5.1B (1.05%)
Dataset MedTurkQuAD
Epochs 2
Optimizer paged_adamw_8bit

Evaluation Results

Metric Base Model Fine-tuned (LoRA) Delta
Exact Match (EM) 4.63% 54.76% +50.12%
Token F1 25.80% 75.39% +49.58%

Evaluated on 820 validation samples with greedy decoding.

Usage

This repository contains only the LoRA adapter weights. Load the base model separately:

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

base_model_name = "ytu-ce-cosmos/Turkish-Gemma-9b-v0.1"
adapter_name = "Ahmetemintek/turkish-gemma-9b-medical-qlora"

tokenizer = AutoTokenizer.from_pretrained(adapter_name)

bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.float16,
    bnb_4bit_use_double_quant=True,
)

model = AutoModelForCausalLM.from_pretrained(
    base_model_name,
    quantization_config=bnb_config,
    device_map="auto",
)

model = PeftModel.from_pretrained(model, adapter_name)
model.eval()

prompt = """Bağlam:
Verem, Mycobacterium tuberculosis adlı bakteri tarafından neden olunan bakteriyel ve bulaşıcı bir hastalıktır.

Soru:
Vereme ne neden olur?

Cevap:
"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128, do_sample=False)
answer = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(answer) # Output: "Mycobacterium tuberculosis"

Prompt Format

Bağlam:
{context}

Soru:
{question}

Cevap:

Limitations

  • The model was fine-tuned on ~6.5k QA samples and evaluated only on the MedTurkQA validation split; results may not generalize beyond similar medical text distributions.
  • The training setup uses a generative objective, which may produce paraphrased or slightly verbose answers rather than exact span extraction.
  • The model does not provide token-level offsets or guaranteed extractive spans.
  • This adapter is intended for research and experimentation, not clinical decision-making.

Repository

Full training code, evaluation scripts, and notebooks are available at:

github.com/Ahmetemintek/gemma-finetuning

Acknowledgements

This adapter is built on top of the base model ytu-ce-cosmos/Turkish-Gemma-9b-v0.1. The model was fine-tuned on the MedTurkQA dataset. The training approach follows the QLoRA method for parameter-efficient fine-tuning.

Downloads last month
1
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Ahmetemintek/turkish-gemma-9b-medical-qlora

Adapter
(3)
this model