Instructions to use sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct") model = AutoModelForCausalLM.from_pretrained("sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct
- SGLang
How to use sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct with Docker Model Runner:
docker model run hf.co/sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct
TSFT-RAG Qwen2.5-1.5B-Instruct
Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation
TSFT-RAG Qwen2.5-1.5B-Instruct is a full-parameter fine-tuned derivative of Qwen/Qwen2.5-1.5B-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
| 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:
- 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 main observed gains are in hard-negative handling, structured-output validity, and citation-related behaviour. Performance does not improve uniformly across all metrics; in particular, the measured grounded-QA score is lower than that of the unchanged base model in the reported evaluation.
Model Details
| Property | Value |
|---|---|
| Model family | TSFT-RAG |
| Base model | Qwen/Qwen2.5-1.5B-Instruct |
| Architecture | Qwen2ForCausalLM |
| Parameters | approximately 1.5B |
| Training method | full-parameter supervised fine-tuning |
| Primary language of the training corpus | German |
| Context length supported by the configuration | 32,768 tokens |
| Weight dtype | bfloat16 |
| Framework | Transformers |
| License | Apache-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 small language models;
- local or resource-constrained 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 argument | Value |
|---|---|
| Epochs | 3 |
| Learning rate | 1e-6 |
| Per-device train batch size | 1 |
| Per-device evaluation batch size | 1 |
| Gradient accumulation steps | 16 |
| Effective batch size per process | 16 |
| Optimizer | paged AdamW 8-bit |
| Scheduler | cosine |
| Warmup ratio | 0.08 |
| Weight decay | 0.01 |
| Maximum gradient norm | 1.0 |
| Precision | bfloat16 |
| FP16 | disabled |
| Packing | disabled |
| Seed | 42 |
The recorded training runtime was approximately 21,789 seconds (about 6 h 3 min), with a final reported training loss of 1.0738.
Evaluation
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.3321 | 0.4308 | +0.0987 |
| Hard-negative handling | 0.0056 | 0.3418 | +0.3362 |
| Grounded QA | 0.5289 | 0.4803 | -0.0486 |
| Analysis: main topic | 0.5593 | 0.5518 | -0.0075 |
| Analysis: key message | 0.5210 | 0.4810 | -0.0400 |
| Analysis: main arguments | 0.4549 | 0.3998 | -0.0551 |
| JSON validity | 0.7477 | 0.8862 | +0.1386 |
| Citation precision | 0.0000 | 0.6502 | +0.6502 |
| Citation recall | 0.0000 | 0.6502 | +0.6502 |
The strongest change is in hard-negative handling: the unchanged base model correctly rejected 4 of the 708 hard-negative cases under the benchmark criterion, while the fine-tuned model correctly rejected 242. JSON validity and citation-related scores also increased substantially.
These results should be interpreted as task-specific benchmark outcomes rather than general-purpose capability claims. The model improves substantially in abstention, JSON validity, and citation-related behaviour, while grounded-QA and the three analysis-task scores decrease relative to the unchanged base model.
Further evaluation details, scripts, and analysis are available in the accompanying repository and paper.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-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:
- the behavioural instruction;
- the retrieved context;
- the user question;
- 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.
- The 1.5B parameter scale still limits reasoning depth and general robustness.
- 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 reductions in grounded-QA and analysis-task scores indicate real trade-offs and should not be ignored 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-1.5B-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 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}
}
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-1.5B-Instruct
- Project website: https://sascha-frank.com
- Paper: forthcoming
- Downloads last month
- 188