初始化项目,由ModelHub XC社区提供模型
Model: sascha-frank-ai-research/tsft-rag-gemma-3-1b-it 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
|
||||||
206
LICENSE
Normal file
206
LICENSE
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
# Gemma Terms of Use
|
||||||
|
|
||||||
|
The terms below apply to Gemma models listed in the Appendix at bottom of this page. For Gemma 4 terms, see the [Gemma 4 license](https://ai.google.dev/gemma/apache_2).
|
||||||
|
|
||||||
|
Last modified: April 1, 2026
|
||||||
|
|
||||||
|
By using, reproducing, modifying, distributing, performing or displaying any
|
||||||
|
portion or element of Gemma, Model Derivatives including via any Hosted Service,
|
||||||
|
(each as defined below) (collectively, the "**Gemma Services**") or otherwise
|
||||||
|
accepting the terms of this Agreement, you agree to be bound by this Agreement.
|
||||||
|
|
||||||
|
## Section 1: DEFINITIONS
|
||||||
|
|
||||||
|
### 1.1 Definitions
|
||||||
|
|
||||||
|
(a) "**Agreement** " or "**Gemma Terms of Use**" means these terms and conditions
|
||||||
|
that govern the use, reproduction, Distribution or modification of the Gemma
|
||||||
|
Services and any terms and conditions incorporated by reference.
|
||||||
|
|
||||||
|
(b) "**Distribution** " or "**Distribute** " means any transmission, publication,
|
||||||
|
or other sharing of Gemma or Model Derivatives to a third party, including by
|
||||||
|
providing or making Gemma or its functionality available as a hosted service via
|
||||||
|
API, web access, or any other electronic or remote means ("**Hosted Service**").
|
||||||
|
|
||||||
|
(c) "**Gemma** " means the set of machine learning language models, trained model
|
||||||
|
weights and parameters identified in the [Appendix](https://ai.google.dev/gemma/terms#appendix),
|
||||||
|
regardless of the source that you obtained it from.
|
||||||
|
|
||||||
|
(d) "**Google**" means Google LLC.
|
||||||
|
|
||||||
|
(e) "**Model Derivatives**" means all (i) modifications to Gemma, (ii) works based
|
||||||
|
on Gemma, or (iii) any other machine learning model which is created by transfer
|
||||||
|
of patterns of the weights, parameters, operations, or Output of Gemma, to that
|
||||||
|
model in order to cause that model to perform similarly to Gemma, including
|
||||||
|
distillation methods that use intermediate data representations or methods based
|
||||||
|
on the generation of synthetic data Outputs by Gemma for training that model.
|
||||||
|
For clarity, Outputs are not deemed Model Derivatives.
|
||||||
|
|
||||||
|
(f) "**Output**" means the information content output of Gemma or a Model
|
||||||
|
Derivative that results from operating or otherwise using Gemma or the Model
|
||||||
|
Derivative, including via a Hosted Service.
|
||||||
|
|
||||||
|
### 1.2
|
||||||
|
|
||||||
|
As used in this Agreement, "**including** " means
|
||||||
|
"**including without limitation**".
|
||||||
|
|
||||||
|
## Section 2: ELIGIBILITY AND USAGE
|
||||||
|
|
||||||
|
### 2.1 Eligibility
|
||||||
|
|
||||||
|
You represent and warrant that you have the legal capacity to enter into this
|
||||||
|
Agreement (including being of sufficient age of consent). If you are accessing
|
||||||
|
or using any of the Gemma Services for or on behalf of a legal entity, (a) you
|
||||||
|
are entering into this Agreement on behalf of yourself and that legal entity,
|
||||||
|
(b) you represent and warrant that you have the authority to act on behalf of
|
||||||
|
and bind that entity to this Agreement and (c) references to "**you** " or
|
||||||
|
"**your**" in the remainder of this Agreement refers to both you (as an
|
||||||
|
individual) and that entity.
|
||||||
|
|
||||||
|
### 2.2 Use
|
||||||
|
|
||||||
|
You may use, reproduce, modify, Distribute, perform or display any of the Gemma
|
||||||
|
Services only in accordance with the terms of this Agreement, and must not
|
||||||
|
violate (or encourage or permit anyone else to violate) any term of this
|
||||||
|
Agreement.
|
||||||
|
|
||||||
|
## Section 3: DISTRIBUTION AND RESTRICTIONS
|
||||||
|
|
||||||
|
### 3.1 Distribution and Redistribution
|
||||||
|
|
||||||
|
You may reproduce or Distribute copies of Gemma or Model Derivatives if you meet
|
||||||
|
all of the following conditions:
|
||||||
|
|
||||||
|
1. You must include the use restrictions referenced in Section 3.2 as an enforceable provision in any agreement (e.g., license agreement, terms of use, etc.) governing the use and/or distribution of Gemma or Model Derivatives and you must provide notice to subsequent users you Distribute to that Gemma or Model Derivatives are subject to the use restrictions in Section 3.2.
|
||||||
|
2. You must provide all third party recipients of Gemma or Model Derivatives a copy of this Agreement.
|
||||||
|
3. You must cause any modified files to carry prominent notices stating that you modified the files.
|
||||||
|
4. All Distributions (other than through a Hosted Service) must be accompanied by a "**Notice** " text file that contains the following notice: "**Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms**".
|
||||||
|
|
||||||
|
You may add your own intellectual property statement to your modifications and,
|
||||||
|
except as set forth in this Section, may provide additional or different terms
|
||||||
|
and conditions for use, reproduction, or Distribution of your modifications, or
|
||||||
|
for any such Model Derivatives as a whole, provided your use, reproduction,
|
||||||
|
modification, Distribution, performance, and display of Gemma otherwise complies
|
||||||
|
with the terms and conditions of this Agreement. Any additional or different
|
||||||
|
terms and conditions you impose must not conflict with the terms of this
|
||||||
|
Agreement.
|
||||||
|
|
||||||
|
### 3.2 Use Restrictions
|
||||||
|
|
||||||
|
You must not use any of the Gemma Services:
|
||||||
|
|
||||||
|
1. for the restricted uses set forth in the Gemma Prohibited Use Policy at [ai.google.dev/gemma/prohibited_use_policy](https://ai.google.dev/gemma/prohibited_use_policy) ("**Prohibited Use Policy**"), which is hereby incorporated by reference into this Agreement; or
|
||||||
|
2. in violation of applicable laws and regulations.
|
||||||
|
|
||||||
|
To the maximum extent permitted by law, Google reserves the right to restrict
|
||||||
|
(remotely or otherwise) usage of any of the Gemma Services that Google
|
||||||
|
reasonably believes are in violation of this Agreement.
|
||||||
|
|
||||||
|
### 3.3 Generated Output
|
||||||
|
|
||||||
|
Google claims no rights in Outputs you generate using Gemma. You and your users
|
||||||
|
are solely responsible for Outputs and their subsequent uses.
|
||||||
|
|
||||||
|
## Section 4: ADDITIONAL PROVISIONS
|
||||||
|
|
||||||
|
### 4.1 Updates
|
||||||
|
|
||||||
|
Google may update Gemma from time to time.
|
||||||
|
|
||||||
|
### 4.2 Trademarks
|
||||||
|
|
||||||
|
Nothing in this Agreement grants you any rights to use Google's trademarks,
|
||||||
|
trade names, logos or to otherwise suggest endorsement or misrepresent the
|
||||||
|
relationship between you and Google. Google reserves any rights not expressly
|
||||||
|
granted herein.
|
||||||
|
|
||||||
|
### 4.3 DISCLAIMER OF WARRANTY
|
||||||
|
|
||||||
|
UNLESS REQUIRED BY APPLICABLE LAW, THE GEMMA SERVICES, AND OUTPUTS, ARE PROVIDED
|
||||||
|
ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING 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, REPRODUCING,
|
||||||
|
MODIFYING, PERFORMING, DISPLAYING OR DISTRIBUTING ANY OF THE GEMMA SERVICES
|
||||||
|
OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR USE OR DISTRIBUTION
|
||||||
|
OF ANY OF THE GEMMA SERVICES OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND
|
||||||
|
PERMISSIONS UNDER THIS AGREEMENT.
|
||||||
|
|
||||||
|
### 4.4 LIMITATION OF LIABILITY
|
||||||
|
|
||||||
|
TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO
|
||||||
|
LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY,
|
||||||
|
CONTRACT, OR OTHERWISE, UNLESS REQUIRED BY APPLICABLE LAW, SHALL GOOGLE OR ITS
|
||||||
|
AFFILIATES BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT,
|
||||||
|
SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR LOST
|
||||||
|
PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO, ANY OF THE GEMMA
|
||||||
|
SERVICES OR OUTPUTS EVEN IF GOOGLE OR ITS AFFILIATES HAVE BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
### 4.5 Term, Termination, and Survival
|
||||||
|
|
||||||
|
The term of this Agreement will commence upon your acceptance of this Agreement
|
||||||
|
(including acceptance by your use, modification, or Distribution, reproduction,
|
||||||
|
performance or display of any portion or element of the Gemma Services) and will
|
||||||
|
continue in full force and effect until terminated in accordance with the terms
|
||||||
|
of this Agreement. Google may terminate this Agreement if you are in breach of
|
||||||
|
any term of this Agreement. Upon termination of this Agreement, you must delete
|
||||||
|
and cease use and Distribution of all copies of Gemma and Model Derivatives in
|
||||||
|
your possession or control. Sections 1, 2.1, 3.3, 4.2 to 4.9 shall survive the
|
||||||
|
termination of this Agreement.
|
||||||
|
|
||||||
|
### 4.6 Governing Law and Jurisdiction
|
||||||
|
|
||||||
|
This Agreement will be governed by the laws of the State of California without
|
||||||
|
regard to choice of law principles. The UN Convention on Contracts for the
|
||||||
|
International Sale of Goods does not apply to this Agreement. The state and
|
||||||
|
federal courts of Santa Clara County, California shall have exclusive
|
||||||
|
jurisdiction of any dispute arising out of this Agreement.
|
||||||
|
|
||||||
|
### 4.7 Severability
|
||||||
|
|
||||||
|
If any provision of this Agreement is held to be invalid, illegal or
|
||||||
|
unenforceable, the remaining provisions shall be unaffected thereby and remain
|
||||||
|
valid as if such provision had not been set forth herein.
|
||||||
|
|
||||||
|
### 4.8 Entire Agreement
|
||||||
|
|
||||||
|
This Agreement states all the terms agreed between the parties and supersedes
|
||||||
|
all other agreements between the parties as of the date of acceptance relating
|
||||||
|
to its subject matter.
|
||||||
|
|
||||||
|
### 4.9 No Waiver
|
||||||
|
|
||||||
|
Google will not be treated as having waived any rights by not exercising (or
|
||||||
|
delaying the exercise of) any rights under this Agreement.
|
||||||
|
|
||||||
|
## Appendix
|
||||||
|
|
||||||
|
- [Gemma 1](https://ai.google.dev/gemma/docs/core/model_card)
|
||||||
|
- [Gemma 1.1](https://ai.google.dev/gemma/docs/core/model_card)
|
||||||
|
- [Gemma 2](https://ai.google.dev/gemma/docs/core/model_card_2)
|
||||||
|
- [Gemma 3](https://ai.google.dev/gemma/docs/core/model_card_3)
|
||||||
|
- [Gemma 3n](https://ai.google.dev/gemma/docs/3n)
|
||||||
|
- [FunctionGemma](https://ai.google.dev/gemma/docs/functiongemma)
|
||||||
|
- [EmbeddingGemma](https://ai.google.dev/gemma/docs/embeddinggemma)
|
||||||
|
- [PaliGemma](https://ai.google.dev/gemma/docs/paligemma/model-card)
|
||||||
|
- [PaliGemma 2](https://ai.google.dev/gemma/docs/paligemma/model-card-2)
|
||||||
|
- [ShieldGemma](https://ai.google.dev/gemma/docs/shieldgemma/model_card)
|
||||||
|
- [ShieldGemma 2](https://ai.google.dev/gemma/docs/shieldgemma/model_card_2)
|
||||||
|
- [CodeGemma](https://ai.google.dev/gemma/docs/codegemma/model_card)
|
||||||
|
- [CodeGemma 1.1](https://ai.google.dev/gemma/docs/codegemma/model_card)
|
||||||
|
- [Gemma 2 JPN](https://huggingface.co/google/gemma-2-2b-jpn-it)
|
||||||
|
- [DataGemma RIG](https://www.kaggle.com/models/google/datagemma-rig)
|
||||||
|
- [DataGemma RAG](https://www.kaggle.com/models/google/datagemma-rag)
|
||||||
|
- [RecurrentGemma](https://ai.google.dev/gemma/docs/recurrentgemma/model_card)
|
||||||
|
- [Gemma Scope](https://ai.google.dev/gemma/docs/gemma_scope)
|
||||||
|
- [Gemma-APS](https://ai.google.dev/gemma/docs/gemma-aps)
|
||||||
|
- [T5Gemma](https://www.kaggle.com/models/google/t5gemma)
|
||||||
|
- [VaultGemma](https://www.kaggle.com/models/google/vaultgemma)
|
||||||
|
- [FunctionGemma](https://www.kaggle.com/models/google/functiongemma)
|
||||||
|
- [T5Gemma 2](https://www.kaggle.com/models/google/t5gemma-2)
|
||||||
|
- [TranslateGemma](https://www.kaggle.com/models/google/translategemma)
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> **Note:** Previous versions of these Terms are [archived here](https://ai.google.dev/gemma/terms-archive).
|
||||||
49
MODIFICATIONS.md
Normal file
49
MODIFICATIONS.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Modifications
|
||||||
|
|
||||||
|
This repository contains a modified derivative of Google's Gemma model.
|
||||||
|
|
||||||
|
## Base Model
|
||||||
|
|
||||||
|
- google/gemma-3-1b-it
|
||||||
|
|
||||||
|
## Training Distribution
|
||||||
|
|
||||||
|
- unsloth/gemma-3-1b-it
|
||||||
|
|
||||||
|
## Modification Type
|
||||||
|
|
||||||
|
Full-parameter supervised fine-tuning (Full FT)
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
The model was adapted for Retrieval-Augmented Generation (RAG) as part of
|
||||||
|
the TSFT-RAG research project.
|
||||||
|
|
||||||
|
The fine-tuning objective emphasizes:
|
||||||
|
|
||||||
|
- context-grounded question answering
|
||||||
|
- explicit handling of unsupported questions
|
||||||
|
- structured JSON generation
|
||||||
|
- topic extraction
|
||||||
|
- key-message extraction
|
||||||
|
- argument extraction
|
||||||
|
- citation-aware responses
|
||||||
|
|
||||||
|
## Technical Changes
|
||||||
|
|
||||||
|
The following components were modified:
|
||||||
|
|
||||||
|
- model weights
|
||||||
|
|
||||||
|
The following components remain derived from the original Gemma release:
|
||||||
|
|
||||||
|
- tokenizer
|
||||||
|
- tokenizer configuration
|
||||||
|
- model architecture
|
||||||
|
- vocabulary
|
||||||
|
- chat template
|
||||||
|
|
||||||
|
No architectural changes were made to the original Gemma model.
|
||||||
|
|
||||||
|
The resulting model remains fully compatible with the Hugging Face
|
||||||
|
Transformers ecosystem.
|
||||||
21
NOTICE
Normal file
21
NOTICE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Gemma Notice
|
||||||
|
|
||||||
|
This repository contains a modified derivative of Google's Gemma model.
|
||||||
|
|
||||||
|
Original base model:
|
||||||
|
google/gemma-3-1b-it
|
||||||
|
|
||||||
|
Training implementation:
|
||||||
|
unsloth/gemma-3-1b-it
|
||||||
|
|
||||||
|
This model was modified through full-parameter supervised fine-tuning as
|
||||||
|
part of the TSFT-RAG (Task-Specific Full Fine-Tuning for Retrieval-Augmented
|
||||||
|
Generation) research project.
|
||||||
|
|
||||||
|
Use of this model is subject to the Gemma Terms of Use:
|
||||||
|
|
||||||
|
https://ai.google.dev/gemma/terms
|
||||||
|
|
||||||
|
Copyright © Google LLC for the original Gemma model.
|
||||||
|
|
||||||
|
Modifications © 2026 Sascha Frank.
|
||||||
188
README.md
Normal file
188
README.md
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
---
|
||||||
|
base_model: google/gemma-3-1b-it
|
||||||
|
base_model_relation: finetune
|
||||||
|
language:
|
||||||
|
- de
|
||||||
|
- en
|
||||||
|
library_name: transformers
|
||||||
|
license: gemma
|
||||||
|
pipeline_tag: text-generation
|
||||||
|
tags:
|
||||||
|
- gemma
|
||||||
|
- gemma-3
|
||||||
|
- rag
|
||||||
|
- retrieval-augmented-generation
|
||||||
|
- task-specific-fine-tuning
|
||||||
|
- full-fine-tuning
|
||||||
|
- structured-output
|
||||||
|
- research
|
||||||
|
- tsft-rag
|
||||||
|
- model-card-v1
|
||||||
|
---
|
||||||
|
|
||||||
|
# TSFT-RAG Gemma-3-1B-IT
|
||||||
|
|
||||||
|
|
||||||
|
> **Task-Specific Full Fine-Tuning for Retrieval-Augmented Generation**
|
||||||
|
|
||||||
|
Part of the [TSFT-RAG model family](https://huggingface.co/sascha-frank-ai-research) for Retrieval-Augmented Generation across Gemma, Qwen and Llama architectures.
|
||||||
|
|
||||||
|
This repository contains **TSFT-RAG Gemma-3-1B-IT**, a full-parameter
|
||||||
|
fine-tuned derivative of Google's Gemma-3-1B-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
|
||||||
|
|
||||||
|
| Model | Parameters | Status |
|
||||||
|
|--------|-----------:|--------|
|
||||||
|
| **Gemma-3-1B-IT** | **1B** | **Released** |
|
||||||
|
| [Gemma-3-4B-IT](https://huggingface.co/sascha-frank-ai-research/tsft-rag-gemma-3-4b-it) | 4B | Released |
|
||||||
|
|[Gemma-3-12B-IT](https://huggingface.co/sascha-frank-ai-research/tsft-rag-gemma-3-12b-it) | 12B | Released |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Abstract
|
||||||
|
|
||||||
|
TSFT-RAG Gemma-3-1B-IT is a full-parameter fine-tuned derivative of
|
||||||
|
Google's Gemma-3-1B-IT model developed for Retrieval-Augmented
|
||||||
|
Generation (RAG). The objective of the TSFT-RAG project is to
|
||||||
|
investigate whether relatively small language models can be specialized
|
||||||
|
for reliable context-grounded answering, explicit abstention, structured
|
||||||
|
output generation and information extraction through full-parameter
|
||||||
|
supervised fine-tuning.
|
||||||
|
|
||||||
|
## Research Background
|
||||||
|
|
||||||
|
Retrieval-Augmented Generation requires different optimization targets
|
||||||
|
than general-purpose conversational assistants. Besides answering
|
||||||
|
questions from retrieved evidence, practical RAG systems must reliably
|
||||||
|
refuse unsupported questions, produce structured outputs and follow
|
||||||
|
deterministic task instructions.
|
||||||
|
|
||||||
|
## Model Details
|
||||||
|
|
||||||
|
Property | Value
|
||||||
|
--------------------------| -----------------------
|
||||||
|
Model family |TSFT-RAG
|
||||||
|
Base model |google/gemma-3-1b-it
|
||||||
|
Training implementation |unsloth/gemma-3-1b-it
|
||||||
|
Architecture |Gemma3ForCausalLM
|
||||||
|
Parameters |\~1B
|
||||||
|
Context length |32,768 tokens
|
||||||
|
Training sequence length |1,024 tokens
|
||||||
|
Precision |bfloat16
|
||||||
|
|
||||||
|
## Training Procedure
|
||||||
|
|
||||||
|
Parameter | Value
|
||||||
|
----------------------- |-------------------
|
||||||
|
Epochs | 3
|
||||||
|
Learning rate | 1e-6
|
||||||
|
Batch size | 1
|
||||||
|
Gradient accumulation | 16
|
||||||
|
Optimizer | Paged AdamW 8-bit
|
||||||
|
Scheduler | Cosine
|
||||||
|
Warmup ratio | 0.08
|
||||||
|
Weight decay | 0.01
|
||||||
|
Max gradient norm | 1.0
|
||||||
|
Packing | disabled
|
||||||
|
Seed | 42
|
||||||
|
|
||||||
|
Training runtime: **7 h 52 min**
|
||||||
|
|
||||||
|
Final training loss: **1.1361**
|
||||||
|
|
||||||
|
## Evaluation
|
||||||
|
|
||||||
|
The benchmark contains 1,940 held-out German RAG evaluation instances
|
||||||
|
covering grounded QA, unsupported questions, topic extraction,
|
||||||
|
key-message extraction, argument extraction, structured JSON generation
|
||||||
|
and citation-aware responses.
|
||||||
|
|
||||||
|
Metric | Base | TSFT-RAG | Difference
|
||||||
|
-------------------------- |------- |---------- |------------
|
||||||
|
Aggregate score | 0.328 | 0.605 | +0.278
|
||||||
|
Hard-negative handling | 0.020 | 0.815 | +0.795
|
||||||
|
Grounded QA | 0.509 | 0.395 | -0.114
|
||||||
|
Analysis: main topic | 0.550 | 0.546 | -0.004
|
||||||
|
Analysis: key message | 0.538 | 0.493 | -0.046
|
||||||
|
Analysis: main arguments | 0.404 | 0.546 | +0.142
|
||||||
|
|
||||||
|
### Discussion
|
||||||
|
|
||||||
|
The largest improvement is observed in unsupported-question handling.
|
||||||
|
The fine-tuned model rejects unsupported questions substantially more
|
||||||
|
reliably than the original base model while improving argument
|
||||||
|
extraction. As expected for task-specific specialization, these
|
||||||
|
improvements are accompanied by moderate reductions in grounded QA and
|
||||||
|
key-message extraction. This reflects the intended optimization
|
||||||
|
objective rather than a general capability increase.
|
||||||
|
|
||||||
|
## Intended Use
|
||||||
|
|
||||||
|
- Local RAG systems
|
||||||
|
- Enterprise knowledge assistants
|
||||||
|
- University question answering
|
||||||
|
- Structured information extraction
|
||||||
|
- Research on task-specific fine-tuning
|
||||||
|
|
||||||
|
## Reproducibility
|
||||||
|
|
||||||
|
The model was trained using the Unsloth implementation of Gemma with
|
||||||
|
full-parameter supervised fine-tuning and the Hugging Face Transformers
|
||||||
|
ecosystem.
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
Performance outside the evaluated task formats has not been
|
||||||
|
systematically studied. The model inherits limitations of the original
|
||||||
|
Gemma base model and may generate incorrect or unsupported information.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This repository contains a modified derivative of Google's Gemma model.
|
||||||
|
Use is subject to the Gemma Terms of Use. See LICENSE, NOTICE and
|
||||||
|
MODIFICATIONS.md.
|
||||||
|
|
||||||
|
## Citation
|
||||||
|
|
||||||
|
A formal paper citation will be added after publication. Until then,
|
||||||
|
please cite the accompanying software repository.
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
- https://github.com/frankmst/rag-task-specific-full-finetuning
|
||||||
|
- https://sascha-frank.com
|
||||||
47
chat_template.jinja
Normal file
47
chat_template.jinja
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{{ bos_token }}
|
||||||
|
{%- if messages[0]['role'] == 'system' -%}
|
||||||
|
{%- if messages[0]['content'] is string -%}
|
||||||
|
{%- set first_user_prefix = messages[0]['content'] + '
|
||||||
|
|
||||||
|
' -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- set first_user_prefix = messages[0]['content'][0]['text'] + '
|
||||||
|
|
||||||
|
' -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- set loop_messages = messages[1:] -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- set first_user_prefix = "" -%}
|
||||||
|
{%- set loop_messages = messages -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- for message in loop_messages -%}
|
||||||
|
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
|
||||||
|
{{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if (message['role'] == 'assistant') -%}
|
||||||
|
{%- set role = "model" -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- set role = message['role'] -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{{ '<start_of_turn>' + role + '
|
||||||
|
' + (first_user_prefix if loop.first else "") }}
|
||||||
|
{%- if message['content'] is string -%}
|
||||||
|
{{ message['content'] | trim }}
|
||||||
|
{%- elif message['content'] is iterable -%}
|
||||||
|
{%- for item in message['content'] -%}
|
||||||
|
{%- if item['type'] == 'image' -%}
|
||||||
|
{{ '<start_of_image>' }}
|
||||||
|
{%- elif item['type'] == 'text' -%}
|
||||||
|
{{ item['text'] | trim }}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- else -%}
|
||||||
|
{{ raise_exception("Invalid content type") }}
|
||||||
|
{%- endif -%}
|
||||||
|
{{ '<end_of_turn>
|
||||||
|
' }}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- if add_generation_prompt -%}
|
||||||
|
{{'<start_of_turn>model
|
||||||
|
'}}
|
||||||
|
{%- endif -%}
|
||||||
73
config.json
Normal file
73
config.json
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"_sliding_window_pattern": 6,
|
||||||
|
"architectures": [
|
||||||
|
"Gemma3ForCausalLM"
|
||||||
|
],
|
||||||
|
"attention_bias": false,
|
||||||
|
"attention_dropout": 0.0,
|
||||||
|
"attn_logit_softcapping": null,
|
||||||
|
"bos_token_id": 2,
|
||||||
|
"cache_implementation": "hybrid",
|
||||||
|
"dtype": "bfloat16",
|
||||||
|
"eos_token_id": 106,
|
||||||
|
"final_logit_softcapping": null,
|
||||||
|
"head_dim": 256,
|
||||||
|
"hidden_activation": "gelu_pytorch_tanh",
|
||||||
|
"hidden_size": 1152,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"intermediate_size": 6912,
|
||||||
|
"layer_types": [
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"full_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"full_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"full_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"full_attention",
|
||||||
|
"sliding_attention",
|
||||||
|
"sliding_attention"
|
||||||
|
],
|
||||||
|
"max_position_embeddings": 32768,
|
||||||
|
"model_type": "gemma3_text",
|
||||||
|
"num_attention_heads": 4,
|
||||||
|
"num_hidden_layers": 26,
|
||||||
|
"num_key_value_heads": 1,
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"query_pre_attn_scalar": 256,
|
||||||
|
"rms_norm_eps": 1e-06,
|
||||||
|
"rope_parameters": {
|
||||||
|
"full_attention": {
|
||||||
|
"rope_theta": 1000000,
|
||||||
|
"rope_type": "default"
|
||||||
|
},
|
||||||
|
"sliding_attention": {
|
||||||
|
"rope_theta": 10000,
|
||||||
|
"rope_type": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sliding_window": 512,
|
||||||
|
"sliding_window_pattern": 6,
|
||||||
|
"tie_word_embeddings": true,
|
||||||
|
"transformers_version": "5.7.0",
|
||||||
|
"unsloth_fixed": true,
|
||||||
|
"use_bidirectional_attention": false,
|
||||||
|
"use_cache": false,
|
||||||
|
"vocab_size": 262144
|
||||||
|
}
|
||||||
14
generation_config.json
Normal file
14
generation_config.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"bos_token_id": 2,
|
||||||
|
"cache_implementation": "hybrid",
|
||||||
|
"do_sample": true,
|
||||||
|
"eos_token_id": [
|
||||||
|
1,
|
||||||
|
106
|
||||||
|
],
|
||||||
|
"max_length": 32768,
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"top_k": 64,
|
||||||
|
"top_p": 0.95,
|
||||||
|
"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:4582f5cdc94b33c7e798fac3242deacbdd1e3de231538fa673c7540439c7e268
|
||||||
|
size 1999811208
|
||||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:daab2354f8a74e70d70b4d1f804939b68a8c9624dd06cb7858e52dd8970e9726
|
||||||
|
size 33384567
|
||||||
3
tokenizer.model
Normal file
3
tokenizer.model
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
|
||||||
|
size 4689074
|
||||||
26
tokenizer_config.json
Normal file
26
tokenizer_config.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"backend": "tokenizers",
|
||||||
|
"boi_token": "<start_of_image>",
|
||||||
|
"bos_token": "<bos>",
|
||||||
|
"clean_up_tokenization_spaces": false,
|
||||||
|
"eoi_token": "<end_of_image>",
|
||||||
|
"eos_token": "<end_of_turn>",
|
||||||
|
"image_token": "<image_soft_token>",
|
||||||
|
"is_local": false,
|
||||||
|
"local_files_only": false,
|
||||||
|
"mask_token": "<mask>",
|
||||||
|
"model_max_length": 32768,
|
||||||
|
"model_specific_special_tokens": {
|
||||||
|
"boi_token": "<start_of_image>",
|
||||||
|
"eoi_token": "<end_of_image>",
|
||||||
|
"image_token": "<image_soft_token>"
|
||||||
|
},
|
||||||
|
"pad_token": "<pad>",
|
||||||
|
"padding_side": "left",
|
||||||
|
"processor_class": "Gemma3Processor",
|
||||||
|
"sp_model_kwargs": null,
|
||||||
|
"spaces_between_special_tokens": false,
|
||||||
|
"tokenizer_class": "GemmaTokenizer",
|
||||||
|
"unk_token": "<unk>",
|
||||||
|
"use_default_system_prompt": false
|
||||||
|
}
|
||||||
7
train_metrics.json
Normal file
7
train_metrics.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"train_runtime": 28324.5541,
|
||||||
|
"train_samples_per_second": 1.644,
|
||||||
|
"train_steps_per_second": 0.103,
|
||||||
|
"total_flos": 4.281834382994995e+16,
|
||||||
|
"train_loss": 1.136103675899905
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user