CoolFace
Modelpublic

sascha-frank-ai-research/tsft-rag-qwen2.5-14b-instruct

sourceHugging Faceapache-2.0updated 1mo agoView on Hugging Face
0likes182downloads
Model Card

TSFT-RAG Qwen2.5-14B-Instruct

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

TSFT-RAG Qwen2.5-14B-Instruct is a full-parameter fine-tuned derivative of Qwen/Qwen2.5-14B-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.


TSFT-RAG Model Series

ModelParametersStatus
Qwen2.5-0.5B-Instruct0.5BReleased
Qwen2.5-1.5B-Instruct1.5BReleased
Qwen2.5-7B-Instruct7BReleased
Qwen2.5-14B-Instruct14BReleased

The model was trained to improve several behaviours that are important in practical RAG systems:

  • —answering from supplied context;
  • —abstaining when the context does not support an answer;
  • —following task-specific output requirements;
  • —producing structured JSON output;
  • —generating source-aware and citation-oriented responses.

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.

Model Details

PropertyValue
Model familyTSFT-RAG
Base modelQwen/Qwen2.5-14B-Instruct
ArchitectureQwen2ForCausalLM
Parametersapproximately 14B
Training methodfull-parameter supervised fine-tuning
Primary language of the training corpusGerman
Context length supported by the configuration32,768 tokens
Training sequence length1,024 tokens
Weight dtypebfloat16
FrameworkTransformers
LicenseApache-2.0

Intended Use

This model is intended for research and experimental use in RAG-oriented workflows.

Suitable use cases include:

  • —context-grounded question answering;
  • —evaluation of abstention behaviour;
  • —generation of structured RAG responses;
  • —source-aware answer generation;
  • —comparison of base and fully fine-tuned language models;
  • —local or server-based RAG experiments.

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.

Training Data

The model was trained on a fixed, task-specific German-language corpus designed for RAG-oriented instruction following.

The training examples cover:

  • —answerable context-grounded questions;
  • —hard-negative and unanswerable questions;
  • —multiple assistant roles and response styles;
  • —analysis tasks for main topic, key message, and main arguments;
  • —JSON and short-answer output formats;
  • —citation-aware responses.

The complete raw training corpus is not distributed with this checkpoint. The accompanying repository documents the data-processing, training, and evaluation pipeline.

Training Procedure

This checkpoint was produced using full-parameter supervised fine-tuning rather than LoRA, QLoRA, or another adapter-based method.

Training argumentValue
Epochs3
Learning rate1e-6
Per-device train batch size1
Per-device evaluation batch size1
Gradient accumulation steps16
Effective batch size per process16
OptimizerAdamW (PyTorch)
Schedulercosine
Warmup ratio0.08
Weight decay0.01
Maximum gradient norm1.0
Precisionbfloat16
FP16disabled
Maximum sequence length1,024
Packingdisabled
Seed42

The recorded training runtime was approximately 12,716 seconds (about 3 h 31 min), with a final reported training loss of 0.7839.

Evaluation

The fine-tuned model and the unchanged base model were evaluated on the same held-out test set of 1,940 instances.

MetricBase modelTSFT-RAGDifference
Aggregate score0.38210.4902+0.1082
Hard-negative handling0.02970.3531+0.3234
Grounded QA0.59070.5591-0.0316
Analysis: main topic0.64010.6394-0.0007
Analysis: key message0.58480.5629-0.0219
Analysis: main arguments0.50630.5058-0.0005
JSON validity0.83970.8376-0.0021
Citation precision0.00000.2178+0.2178
Citation recall0.00000.2178+0.2178

The largest improvement is in hard-negative handling. The unchanged base model correctly rejected 21 of 708 hard-negative cases, while the fine-tuned model correctly rejected 250 of 708.

The aggregate score, hard-negative handling, and citation behaviour improve substantially. Grounded QA, JSON validity and several analysis metrics change only slightly, with modest trade-offs visible in the benchmark.

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.

Usage

python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "sascha-frank-ai-research/tsft-rag-qwen2.5-14b-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,
    )
)

Prompting Notes

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:

  1. 1.the behavioural instruction;
  2. 2.the retrieved context;
  3. 3.the user question;
  4. 4.any required output format.

For deterministic evaluation, use greedy decoding or another fixed decoding setup.

Limitations

  • —The model may produce incorrect, incomplete, or unsupported answers.
  • —Fine-tuning does not guarantee faithful use of retrieved evidence.
  • —Retrieval quality remains a major determinant of answer quality.
  • —The model may fail to abstain even when evidence is insufficient.
  • —Citation-like output does not guarantee that a cited passage truly supports a claim.
  • —Performance outside the evaluated RAG task formats has not been systematically established.
  • —The training corpus is primarily German, so behaviour may differ in other languages.
  • —The model inherits limitations and biases from the Qwen2.5 base model and from the task-specific training data.
  • —The observed metric trade-offs should be considered when selecting the model for deployment.

The model should not be used for high-stakes medical, legal, financial, safety-critical, or administrative decisions without independent validation and human oversight.

Ethical Considerations

Retrieved documents may contain inaccurate, biased, confidential, or outdated information. Such content can be reproduced or amplified by the model.

Users are responsible for:

  • —validating retrieval sources;
  • —protecting confidential material;
  • —testing model behaviour in the intended domain;
  • —monitoring unsupported or misleading output;
  • —complying with applicable law, policy, and licensing requirements.

Relationship to the Research Project

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

Base Model and License

This model is derived from Qwen/Qwen2.5-14B-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.

📄 Associated Publication

This model was developed and evaluated in the following study:

Frank, S., & Singh, R. (2026).

Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation: A Controlled Cross-Family Empirical Study of Open-Weight Large Language Models.

SSRN (recommended citation): https://ssrn.com/abstract=7312838

Archived version (Zenodo): Zenodo. DOI: 10.5281/zenodo.21638352

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

bibtex
@article{Frank2026TSFTRAG,
  author  = {Frank, Sascha and Singh, Rawel},
  title   = {Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation:
              A Controlled Cross-Family Empirical Study of Open-Weight Large Language Models},
  journal = {SSRN Electronic Journal},
  year    = {2026},
  doi     = {10.2139/ssrn.7312838},
  url     = {https://papers.ssrn.com/sol3/papers.cfm?abstract_id=7312838}
}

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

Links

  • —Project repository: https://github.com/frankmst/rag-task-specific-full-finetuning
  • —Base model: https://huggingface.co/Qwen/Qwen2.5-14B-Instruct
  • —Project website: https://sascha-frank.com
  • —Paper: forthcoming