Downloads · 30 days
7
11% of all-time downloads
Ahmetemintek/turkish-gemma-9b-medical-qlora
turkish-gemma-9b-medical-qlora is a machine learning model from Ahmetemintek. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
Parameter-efficient fine-tuned LoRA adapter for medical question answering in Turkish.
Downloads · 30 days
7
11% of all-time downloads
All-time downloads
62
Public
Repo size
251 MB
Likes
0
Public
Click a slice to open those files.
.safetensors216 MB · 86%
From the Hugging Face model README
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.
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.
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.
| 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 |
| 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.
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"
Bağlam:
{context}
Soru:
{question}
Cevap:
Full training code, evaluation scripts, and notebooks are available at:
github.com/Ahmetemintek/gemma-finetuning
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.