初始化项目,由ModelHub XC社区提供模型
Model: sascha-frank-ai-research/tsft-rag-qwen2.5-0.5b-instruct Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
202
LICENSE
Normal file
202
LICENSE
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2024 Alibaba Cloud
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
338
README.md
Normal file
338
README.md
Normal file
@@ -0,0 +1,338 @@
|
||||
---
|
||||
license: apache-2.0
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
base_model: Qwen/Qwen2.5-0.5B-Instruct
|
||||
base_model_relation: finetune
|
||||
language:
|
||||
- de
|
||||
- en
|
||||
tags:
|
||||
- rag
|
||||
- retrieval-augmented-generation
|
||||
- task-specific-fine-tuning
|
||||
- full-fine-tuning
|
||||
- qwen2.5
|
||||
- text-generation
|
||||
- structured-output
|
||||
- abstention
|
||||
- research
|
||||
- tsft-rag
|
||||
- model-card-v1
|
||||
---
|
||||
|
||||
# TSFT-RAG Qwen2.5-0.5B-Instruct
|
||||
|
||||
**Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation**
|
||||
|
||||
TSFT-RAG Qwen2.5-0.5B-Instruct is a full-parameter fine-tuned derivative of
|
||||
[Qwen/Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct).
|
||||
|
||||
Part of the [TSFT-RAG model family](https://huggingface.co/sascha-frank-ai-research) 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](https://huggingface.co/sascha-frank-ai-research/tsft-rag-qwen2.5-1.5b-instruct) | 1.5B | Released |
|
||||
| [Qwen2.5-7B-Instruct](https://huggingface.co/sascha-frank-ai-research/tsft-rag-qwen2.5-7b-instruct) | 7B | Released |
|
||||
| [Qwen2.5-14B-Instruct](https://huggingface.co/sascha-frank-ai-research/tsft-rag-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-0.5B-Instruct |
|
||||
| Architecture | Qwen2ForCausalLM |
|
||||
| Parameters | approximately 0.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 **17,266 seconds** (about **4 h 48 min**),
|
||||
with a final reported training loss of **1.3059**.
|
||||
|
||||
## 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.2456 | 0.3546 | +0.1091 |
|
||||
| Hard-negative handling | 0.0000 | 0.2938 | +0.2938 |
|
||||
| Grounded QA | 0.4406 | 0.3811 | -0.0595 |
|
||||
| Analysis: main topic | 0.3683 | 0.3812 | +0.0129 |
|
||||
| Analysis: key message | 0.4068 | 0.4774 | +0.0705 |
|
||||
| Analysis: main arguments | 0.2992 | 0.3153 | +0.0162 |
|
||||
|
||||
The strongest change is in hard-negative handling: the base model failed all 708
|
||||
hard-negative cases under the benchmark criterion, while the fine-tuned model
|
||||
successfully rejected 208 of them.
|
||||
|
||||
These results should be interpreted as task-specific benchmark outcomes rather than
|
||||
general-purpose capability claims. The model improves substantially on some trained
|
||||
behaviours while showing a trade-off on grounded-QA performance.
|
||||
|
||||
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-0.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:
|
||||
|
||||
1. the behavioural instruction;
|
||||
2. the retrieved context;
|
||||
3. the user question;
|
||||
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.
|
||||
- The 0.5B parameter scale 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 reduction in grounded-QA score indicates a real trade-off 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-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.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.
|
||||
|
||||
## Citation
|
||||
|
||||
A formal paper citation will be added after publication of the accompanying paper.
|
||||
|
||||
Until then, please cite the software repository:
|
||||
|
||||
```bibtex
|
||||
@software{frank_tsft_rag_2026,
|
||||
author = {Sascha Frank},
|
||||
title = {Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation},
|
||||
year = {2026},
|
||||
url = {https://github.com/frankmst/rag-task-specific-full-finetuning}
|
||||
}
|
||||
```
|
||||
|
||||
## 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-0.5B-Instruct
|
||||
- Project website: https://sascha-frank.com
|
||||
- Paper: forthcoming
|
||||
54
chat_template.jinja
Normal file
54
chat_template.jinja
Normal file
@@ -0,0 +1,54 @@
|
||||
{%- if tools %}
|
||||
{{- '<|im_start|>system\n' }}
|
||||
{%- if messages[0]['role'] == 'system' %}
|
||||
{{- messages[0]['content'] }}
|
||||
{%- else %}
|
||||
{{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
|
||||
{%- endif %}
|
||||
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
||||
{%- for tool in tools %}
|
||||
{{- "\n" }}
|
||||
{{- tool | tojson }}
|
||||
{%- endfor %}
|
||||
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
||||
{%- else %}
|
||||
{%- if messages[0]['role'] == 'system' %}
|
||||
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
||||
{%- else %}
|
||||
{{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- for message in messages %}
|
||||
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
||||
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
|
||||
{%- elif message.role == "assistant" %}
|
||||
{{- '<|im_start|>' + message.role }}
|
||||
{%- if message.content %}
|
||||
{{- '\n' + message.content }}
|
||||
{%- endif %}
|
||||
{%- for tool_call in message.tool_calls %}
|
||||
{%- if tool_call.function is defined %}
|
||||
{%- set tool_call = tool_call.function %}
|
||||
{%- endif %}
|
||||
{{- '\n<tool_call>\n{"name": "' }}
|
||||
{{- tool_call.name }}
|
||||
{{- '", "arguments": ' }}
|
||||
{{- tool_call.arguments | tojson }}
|
||||
{{- '}\n</tool_call>' }}
|
||||
{%- endfor %}
|
||||
{{- '<|im_end|>\n' }}
|
||||
{%- elif message.role == "tool" %}
|
||||
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
||||
{{- '<|im_start|>user' }}
|
||||
{%- endif %}
|
||||
{{- '\n<tool_response>\n' }}
|
||||
{{- message.content }}
|
||||
{{- '\n</tool_response>' }}
|
||||
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
||||
{{- '<|im_end|>\n' }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- if add_generation_prompt %}
|
||||
{{- '<|im_start|>assistant\n' }}
|
||||
{%- endif %}
|
||||
58
config.json
Normal file
58
config.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"architectures": [
|
||||
"Qwen2ForCausalLM"
|
||||
],
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": null,
|
||||
"dtype": "bfloat16",
|
||||
"eos_token_id": 151645,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 896,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 4864,
|
||||
"layer_types": [
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention",
|
||||
"full_attention"
|
||||
],
|
||||
"max_position_embeddings": 32768,
|
||||
"max_window_layers": 21,
|
||||
"model_type": "qwen2",
|
||||
"num_attention_heads": 14,
|
||||
"num_hidden_layers": 24,
|
||||
"num_key_value_heads": 2,
|
||||
"pad_token_id": 151654,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_parameters": {
|
||||
"rope_theta": 1000000.0,
|
||||
"rope_type": "default"
|
||||
},
|
||||
"sliding_window": null,
|
||||
"tie_word_embeddings": true,
|
||||
"transformers_version": "5.7.0",
|
||||
"unsloth_fixed": true,
|
||||
"use_cache": false,
|
||||
"use_sliding_window": false,
|
||||
"vocab_size": 151936
|
||||
}
|
||||
14
generation_config.json
Normal file
14
generation_config.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"do_sample": true,
|
||||
"eos_token_id": [
|
||||
151645,
|
||||
151643
|
||||
],
|
||||
"max_length": 32768,
|
||||
"pad_token_id": 151654,
|
||||
"repetition_penalty": 1.1,
|
||||
"temperature": 0.7,
|
||||
"top_k": 20,
|
||||
"top_p": 0.8,
|
||||
"transformers_version": "5.7.0"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:def8feaa283762433fb2a87c24384429cd61909a17f2f82d9147086e9b92aba8
|
||||
size 988097824
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
|
||||
size 11421892
|
||||
16
tokenizer_config.json
Normal file
16
tokenizer_config.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"add_prefix_space": false,
|
||||
"backend": "tokenizers",
|
||||
"bos_token": null,
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "<|im_end|>",
|
||||
"errors": "replace",
|
||||
"is_local": false,
|
||||
"local_files_only": false,
|
||||
"model_max_length": 32768,
|
||||
"pad_token": "<|vision_pad|>",
|
||||
"padding_side": "right",
|
||||
"split_special_tokens": false,
|
||||
"tokenizer_class": "Qwen2Tokenizer",
|
||||
"unk_token": null
|
||||
}
|
||||
7
train_metrics.json
Normal file
7
train_metrics.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"train_runtime": 17266.2855,
|
||||
"train_samples_per_second": 2.697,
|
||||
"train_steps_per_second": 0.169,
|
||||
"total_flos": 2.4369303204170496e+16,
|
||||
"train_loss": 1.3058644687437824
|
||||
}
|
||||
Reference in New Issue
Block a user