MaternaQA-es ships a ready-to-use QLoRA training script (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/NicolasHoyosDevss/MaternaQA-es/llms.txt
Use this file to discover all available pages before exploring further.
train_qlora_trl.py) that works with Gemma 4 E2B and MedGemma 1.5 4B IT. The recommended starting point is a smoke test that validates the full load → train → save cycle before committing to a full training run. The smoke test runs 10 steps with a tiny slice of the dataset so you can confirm that model loading, LoRA adapter creation, and checkpoint saving all work correctly on your hardware before investing hours of GPU time.
Requirements
Before launching any training, make sure the following are in place:
pip install -r requirements.txthas been run in your virtual environmenthuggingface-cli loginhas been executed, orexport HF_TOKEN=<token>is set in your shell- Gemma 4 and MedGemma gated model terms have been accepted at huggingface.co
- An NVIDIA GPU with ≥ 16 GB VRAM is available (QLoRA with bitsandbytes requires NVIDIA CUDA)
Smoke Test (~3 Minutes)
The smoke test limits training to 10 steps, 64 training examples, and 32 validation examples. It is designed to surface configuration errors — missing tokens, architecture mismatches, VRAM overflows — before a full run.What Happens During the Smoke Test
When you run the smoke test, the script performs the following steps in order:- Loads the base model in 4-bit NF4 quantization using bitsandbytes (double quantization enabled)
- Creates LoRA adapters with rank
r=16targeting all linear layers (target_modules="all-linear") - Converts the published conversational JSONL to
prompt/completionformat in memory so that loss is calculated only over the expected answer - Runs exactly 10 training steps with the TRL
SFTTrainer - Saves only the LoRA adapter weights and tokenizer to
--output-dir(the base model is not modified)
Choose a Dataset Variant
MaternaQA-es provides two dataset variants for supervised fine-tuning. Both cover the full 5,093-pair training split.- sft_grounded
- sft_closed_book
Each training example contains a source context (a clinical passage from one of the 63 curated PDFs) followed by the question. The model learns to answer by reasoning over the provided evidence.This is the recommended starting point. It produces evidence-grounded models that cite context at inference time and is the variant used in the benchmark experiments reported in the dataset publication.
Next Steps
Once the smoke test completes without errors, you are ready to run full training or generate predictions from a trained adapter.Full QLoRA Training
Run 2-epoch fine-tuning over all 5,093 training pairs. Covers all CLI flags, key hyperparameters, and the recommended experiment matrix.
Running Inference
Generate predictions on the held-out test split with base models or trained QLoRA adapters, then evaluate with Ragas metrics.
