Downloads · 30 days
15
2% of all-time downloads
sascha-frank-ai-research/tsft-rag-qwen2.5-7b-instruct
tsft-rag-qwen2.5-7b-instruct is a text generation model from sascha-frank-ai-research. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation
Downloads · 30 days
15
2% of all-time downloads
All-time downloads
655
Public
Parameters
7.6B
15.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors15.2 GB · 100%
From the Hugging Face model README
Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation
TSFT-RAG Qwen2.5-7B-Instruct is a full-parameter fine-tuned derivative of Qwen/Qwen2.5-7B-Instruct.
Part of the TSFT-RAG model family for Retrieval-Augmented Generation across Gemma, Qwen and Llama architectures.
The objective is to investigate how supervised full fine-tuning changes the behaviour of modern language models when used as Retrieval-Augmented Generation (RAG) systems.
| Model | Parameters | Status |
|---|---|---|
| Qwen2.5-0.5B-Instruct | 0.5B | Released |
| Qwen2.5-1.5B-Instruct | 1.5B | Released |
| Qwen2.5-7B-Instruct | 7B | Released |
| Qwen2.5-14B-Instruct | 14B | Released |
The model was trained to improve several behaviours that are important in practical RAG systems:
The strongest observed gains are in hard-negative handling, structured-output validity, and citation-related behaviour. Performance does not improve uniformly across all metrics; grounded-QA and some analysis metrics show small declines in the reported evaluation.
| Property | Value |
|---|---|
| Model family | TSFT-RAG |
| Base model | Qwen/Qwen2.5-7B-Instruct |
| Architecture | Qwen2ForCausalLM |
| Parameters | approximately 7B |
| Training method | full-parameter supervised fine-tuning |
| Primary language of the training corpus | German |
| Context length supported by the configuration | 32,768 tokens |
| Training sequence length | 1,024 tokens |
| Weight dtype | bfloat16 |
| Framework | Transformers |
| License | Apache-2.0 |
This model is intended for research and experimental use in RAG-oriented workflows.
Suitable use cases include:
The model should be used with retrieved evidence or other explicitly supplied context. It is not intended to serve as a standalone factual knowledge source.
The model was trained on a fixed, task-specific German-language corpus designed for RAG-oriented instruction following.
The training examples cover:
The complete raw training corpus is not distributed with this checkpoint. The accompanying repository documents the data-processing, training, and evaluation pipeline.
This checkpoint was produced using full-parameter supervised fine-tuning rather than LoRA, QLoRA, or another adapter-based method.
| Training argument | Value |
|---|---|
| Epochs | 3 |
| Learning rate | 1e-6 |
| Per-device train batch size | 4 |
| Per-device evaluation batch size | 4 |
| Gradient accumulation steps | 4 |
| Effective batch size per process | 16 |
| Optimizer | AdamW (PyTorch) |
| Scheduler | cosine |
| Warmup ratio | 0.08 |
| Weight decay | 0.01 |
| Maximum gradient norm | 1.0 |
| Precision | bfloat16 |
| FP16 | disabled |
| Maximum sequence length | 1,024 |
| Packing | disabled |
| Seed | 42 |
The recorded training runtime was approximately 5,656 seconds (about 1 h 34 min), with a final reported training loss of 0.8019.
The fine-tuned model and the unchanged base model were evaluated on the same held-out test set of 1,940 instances.
| Metric | Base model | TSFT-RAG | Difference |
|---|---|---|---|
| Aggregate score | 0.4016 | 0.5617 | +0.1601 |
| Hard-negative handling | 0.0791 | 0.5523 | +0.4732 |
| Grounded QA | 0.5505 | 0.5256 | -0.0249 |
| Analysis: main topic | 0.6158 | 0.6241 | +0.0083 |
| Analysis: key message | 0.6122 | 0.5726 | -0.0396 |
| Analysis: main arguments | 0.5823 | 0.5584 | -0.0239 |
| JSON validity | 0.5739 | 0.9069 | +0.3330 |
| Citation precision | 0.0000 | 0.8300 | +0.8300 |
| Citation recall | 0.0000 | 0.8300 | +0.8300 |
The largest improvement is in hard-negative handling. The unchanged base model correctly rejected 56 of 708 hard-negative cases, while the fine-tuned model correctly rejected 391 of 708.
The aggregate score, hard-negative handling, JSON validity, citation precision, and citation recall improve substantially. Grounded QA, key-message analysis, and main-argument analysis show modest declines, while main-topic analysis improves slightly.
These results should be interpreted as task-specific benchmark outcomes rather than general-purpose capability claims.
Further evaluation details, scripts, and analysis are available in the accompanying repository and paper.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "sascha-frank-ai-research/tsft-rag-qwen2.5-7b-instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{
"role": "system",
"content": (
"Du bist ein sachlicher RAG-Assistent. "
"Beantworte die Frage präzise nur auf Grundlage des Kontexts. "
"Wenn der Kontext die Antwort nicht belegt, sage dies ausdrücklich."
),
},
{
"role": "user",
"content": (
"Kontext:\n"
"Ein Retrieval-Modul liefert relevante Dokumentpassagen an das Sprachmodell.\n\n"
"Frage:\n"
"Welche Komponente stellt dem Sprachmodell die Dokumentpassagen bereit?"
),
},
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.inference_mode():
output = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
)
generated_tokens = output[0, inputs["input_ids"].shape[1]:]
print(
tokenizer.decode(
generated_tokens,
skip_special_tokens=True,
)
)
The model was trained with Qwen's chat template and should be used through
tokenizer.apply_chat_template(...).
For RAG use, prompts should clearly separate:
For deterministic evaluation, use greedy decoding or another fixed decoding setup.
The model should not be used for high-stakes medical, legal, financial, safety-critical, or administrative decisions without independent validation and human oversight.
Retrieved documents may contain inaccurate, biased, confidential, or outdated information. Such content can be reproduced or amplified by the model.
Users are responsible for:
This checkpoint is one model from a controlled cross-family study of task-specific full fine-tuning for RAG. The study compares base and fine-tuned configurations from the Gemma, Llama, and Qwen model families across parameter scales from approximately 0.5B to 14B.
Code, training scripts, evaluation scripts, and documentation:
https://github.com/frankmst/rag-task-specific-full-finetuning
This model is derived from Qwen/Qwen2.5-7B-Instruct, which is distributed under the Apache License 2.0.
This derivative checkpoint is also released under the Apache License 2.0. Users should review the license file included in this repository and the licensing information of the base model.
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.
@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}
}
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
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