Official implementation accompanying the paper
Task-Specific Full Fine-Tuning Across Open Language Model Families for Retrieval-Augmented Generation
This repository contains the complete training and evaluation pipeline used in our cross-family study of task-specific full fine-tuning for Retrieval-Augmented Generation (RAG).
The project investigates how supervised full fine-tuning affects RAG-oriented behaviour across multiple open-weight language model families while keeping the complete training corpus, evaluation protocol, prompts and metrics identical.
The experiments include:
- Gemma 3
- Llama 3.2
- Qwen 2.5
covering models from approximately 0.5B to 14B parameters.
Unlike many benchmark studies, every model was trained on exactly the same task-specific corpus, enabling direct comparison of adaptation behaviour across architectures.
rag-task-specific-full-finetuning/
├── ragft/ # Shared helper library
│ ├── chat.py
│ ├── dataset.py
│ └── seed.py
│
├── training/
│ ├── gemma/
│ ├── llama/
│ └── qwen/
│
├── evaluation/
│
├── data_pipeline/
│
├── docs/
│
├── figures/
- Full fine-tuning (no LoRA)
- Unified training pipeline
- Shared dataset generation
- Shared chat template handling
- Shared reproducibility utilities
- Cross-family evaluation
- JSON validation
- Citation evaluation
- Hard-negative benchmark
- Structured RAG evaluation
The repository provides fine-tuned models from three open-weight model families. Each model card contains download instructions, usage examples, licensing information, and a reference to the accompanying publication.
- Llama 3.2 1B
- Llama 3.2 3B
- Qwen2.5 0.5B
- Qwen2.5 1.5B
- Qwen2.5 3B
- Qwen2.5 7B
- Qwen2.5 14B
Clone the repository
git clone https://github.com/frankmst/rag-task-specific-full-finetuning.git
cd rag-task-specific-full-finetuningInstall dependencies
pip install -r requirements.txtThe experiments were conducted on multiple systems (local workstations and cloud GPUs). The provided requirements describe the software stack used during development and experimentation. Minor version differences may exist between individual experimental runs.
The experiments were conducted on NVIDIA GPUs ranging from consumer-class hardware (RTX 3060) to high-memory accelerators (RTX PRO 6000, H200), depending on model size.
Training scripts are provided for all evaluated models, although reproducing the largest configurations requires substantial GPU memory.
Example:
python training/qwen/train_qwen2_5_7b.pyEvery training script uses the common helper library contained in ragft/.
The training corpus is produced using the pipeline in
data_pipeline/
including
- document merging
- document enrichment
- dataset generation
- auditing
- markdown splitting
Example:
python evaluation/evaluate_model.pyAdditional comparison scripts:
compare_many_models.py
compare_model_variants.py
The repository has been structured to maximize reproducibility.
Shared functionality has been centralized into reusable modules:
ragft.chatragft.datasetragft.seed
This avoids implementation drift between different model families and ensures that all experiments use identical preprocessing and training logic wherever possible.
Aggregate benchmark results and statistical analyses are described in the accompanying publication.
This repository contains the complete training and evaluation pipeline used to generate these results.
The methodology, experiments, and evaluation are described in the accompanying publication:
Frank, S., & Singh, R. (2026). Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation: A Multi-Family Evaluation Across Open-Weight Language Models (Version v1). Zenodo. https://doi.org/10.5281/zenodo.21638352
BibTeX:
@misc{Frank2026TSFTRAG,
author = {Frank, Sascha and Singh, Rawel},
title = {Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation:
A Multi-Family Evaluation Across Open-Weight Language Models},
year = {2026},
version = {v1},
publisher = {Zenodo},
doi = {10.5281/zenodo.21638352},
url = {https://doi.org/10.5281/zenodo.21638352}
}See LICENSE.
We thank the developers and maintainers of the open-source ecosystem, including the teams behind
- PyTorch
- Transformers
- TRL
- Accelerate
- Datasets
- Unsloth
whose work made this research possible.
