CoolFace
Modelpublic

sascha-frank-ai-research/tsft-rag-gemma-3-4b-it

sourceHugging Facegemmaupdated 2mo agoView on Hugging Face
0likes112downloads
Model Card

TSFT-RAG Gemma-3-4B-IT

Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation

Part of the TSFT-RAG model family for Retrieval-Augmented Generation across Gemma, Qwen and Llama architectures.

This repository contains TSFT-RAG Gemma-3-4B-IT, a full-parameter fine-tuned derivative of Google's Gemma-3-4B-IT developed within the TSFT-RAG research project. The objective is to investigate how task-specific full fine-tuning improves Retrieval-Augmented Generation (RAG), grounded question answering, unsupported-question detection and structured information extraction.


TSFT-RAG Model Series

ModelParametersStatus
Gemma-3-1B-IT1BReleased
Gemma-3-4B-IT4BReleased
Gemma-3-12B-IT12BReleased

Abstract

Large instruction-tuned language models perform well in general dialogue but are not specifically optimized for Retrieval-Augmented Generation. TSFT-RAG investigates whether full supervised fine-tuning can specialize foundation models for RAG-oriented tasks without modifying the underlying architecture. This model represents the 4B-parameter member of the TSFT-RAG Gemma series.


Research Background

Reliable RAG systems require more than fluent text generation. They must:

  • —answer strictly from retrieved evidence,
  • —reject unsupported questions,
  • —produce structured outputs,
  • —remain deterministic and reproducible.

The TSFT-RAG project evaluates these capabilities across Gemma, Qwen and Llama model families using identical datasets and evaluation procedures.


Model Details

PropertyValue
Base modelgoogle/gemma-3-4b-it
Training implementationunsloth/gemma-3-4b-it
ArchitectureGemma3ForConditionalGeneration
Parameters\~4 Billion
Hidden size2560
Transformer layers34
Context window131,072 tokens
Training length1,024 tokens
Precisionbfloat16
Fine-tuningFull parameter

Training Dataset

The TSFT-RAG dataset contains supervised examples for:

  • —Grounded Question Answering
  • —Unsupported Question Detection
  • —Topic Extraction
  • —Key Message Extraction
  • —Argument Extraction
  • —Structured JSON Generation

The same dataset and benchmark are used across all TSFT-RAG models to enable reproducible comparisons.


Training Procedure

HyperparameterValue
Epochs3
Learning Rate5e-7
Batch Size4
Gradient Accumulation4
OptimizerAdamW
SchedulerCosine
Warmup Ratio0.08
Weight Decay0.01
Max Gradient Norm1.0
Sequence Length1024
BF16Yes
Seed42

Training runtime: 61.8 minutes

Final training loss: 1.3081


Evaluation Results

MetricBaseTSFT-RAGImprovement
Aggregate Score0.4120.610+0.198
Hard Negative QA0.1270.694+0.566
Grounded QA0.5670.532-0.035
Topic Extraction0.6240.615-0.009
Key Message0.5990.584-0.016
Argument Extraction0.5040.518+0.014
JSON Validity0.8560.959+0.102
Citation Precision0.0000.637+0.637
Citation Recall0.0000.637+0.637

Discussion

Compared with the 1B model, the 4B variant achieves a noticeably better balance between reliable abstention, grounded reasoning and structured generation. The most significant improvements are observed for unsupported-question detection, JSON validity and citation behaviour, while maintaining nearly the same performance on grounded question answering and analytical extraction tasks.

Rather than maximizing a single benchmark metric, TSFT-RAG aims to optimize the overall behaviour of language models within Retrieval-Augmented Generation pipelines.


Intended Use

Recommended for:

  • —Retrieval-Augmented Generation
  • —Enterprise knowledge assistants
  • —University information systems
  • —Research assistants
  • —Structured information extraction

Not intended as a general-purpose conversational model.


Example Usage

python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained(
    "sascha-frank-ai-research/tsft-rag-gemma-3-4b-it"
)

model = AutoModelForCausalLM.from_pretrained(
    "sascha-frank-ai-research/tsft-rag-gemma-3-4b-it"
)

Reproducibility

Training was performed using the Hugging Face Transformers ecosystem together with the Unsloth implementation for full-parameter supervised fine-tuning. All relevant hyperparameters, tokenizer configuration and evaluation summaries are included in this repository.


Limitations

  • —Optimized specifically for RAG workflows.
  • —General conversational performance was not the primary optimization objective.
  • —Evaluated primarily on German-language benchmark datasets.
  • —No multimodal benchmark has been conducted.

Ethical Considerations

This model should be used together with appropriate source attribution and human oversight in high-impact applications. It should not replace expert judgement in legal, medical or safety-critical domains.


License

This repository contains a modified derivative of Google's Gemma model.

Please refer to the accompanying LICENSE, NOTICE and MODIFICATIONS.md files.


Associated Publication

This model was developed and evaluated as part of the following research:

Frank, S., & Singh, R. (2026). Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation: A Multi-Family Evaluation Across Open-Weight Language Models.

Zenodo. DOI: 10.5281/zenodo.21638352

If you use this model in academic work, please cite the publication above.

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},
  month        = jul,
  version      = {v1},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.21638352},
  url          = {https://doi.org/10.5281/zenodo.21638352},
  note         = {Preprint}
}

Project

The complete TSFT-RAG research project, including training scripts, evaluation pipeline, benchmark methodology and documentation, is available at:

Project repository https://github.com/frankmst/rag-task-specific-full-finetuning

TSFT-RAG model family https://huggingface.co/sascha-frank-ai-research


Author

Sascha Frank

Independent AI Researcher

ORCID https://orcid.org/0000-0002-0588-0081

GitHub https://github.com/frankmst

Hugging Face https://huggingface.co/sascha-frank-ai-research