Text Generation
PEFT
Safetensors
English
pharmacovigilance
drug-safety
medical
lora
gemma
gemma-4
amd
mi300x
rocm
tcs-amd-hackathon
conversational
Eval Results (legacy)
Instructions to use team-gemmra/gemmra with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use team-gemmra/gemmra with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-31b-it") model = PeftModel.from_pretrained(base_model, "team-gemmra/gemmra") - Notebooks
- Google Colab
- Kaggle
Initial release: Gemmra SFT LoRA adapter for pharmacovigilance
Browse files- .gitattributes +1 -0
- .ipynb_checkpoints/adapter_config-checkpoint.json +52 -0
- README.md +258 -0
- adapter_config.json +52 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +354 -0
- processor_config.json +75 -0
- tokenizer.json +3 -0
- tokenizer_config.json +290 -0
- training_meta.json +8 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
.ipynb_checkpoints/adapter_config-checkpoint.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": {
|
| 6 |
+
"base_model_class": "Gemma4ForConditionalGeneration",
|
| 7 |
+
"parent_library": "transformers.models.gemma4.modeling_gemma4",
|
| 8 |
+
"unsloth_fixed": true
|
| 9 |
+
},
|
| 10 |
+
"base_model_name_or_path": "unsloth/gemma-4-31B-it",
|
| 11 |
+
"bias": "none",
|
| 12 |
+
"corda_config": null,
|
| 13 |
+
"ensure_weight_tying": false,
|
| 14 |
+
"eva_config": null,
|
| 15 |
+
"exclude_modules": null,
|
| 16 |
+
"fan_in_fan_out": false,
|
| 17 |
+
"inference_mode": true,
|
| 18 |
+
"init_lora_weights": true,
|
| 19 |
+
"layer_replication": null,
|
| 20 |
+
"layers_pattern": null,
|
| 21 |
+
"layers_to_transform": null,
|
| 22 |
+
"loftq_config": {},
|
| 23 |
+
"lora_alpha": 128,
|
| 24 |
+
"lora_bias": false,
|
| 25 |
+
"lora_dropout": 0,
|
| 26 |
+
"lora_ga_config": null,
|
| 27 |
+
"megatron_config": null,
|
| 28 |
+
"megatron_core": "megatron.core",
|
| 29 |
+
"modules_to_save": null,
|
| 30 |
+
"peft_type": "LORA",
|
| 31 |
+
"peft_version": "0.19.1",
|
| 32 |
+
"qalora_group_size": 16,
|
| 33 |
+
"r": 64,
|
| 34 |
+
"rank_pattern": {},
|
| 35 |
+
"revision": null,
|
| 36 |
+
"target_modules": [
|
| 37 |
+
"up_proj",
|
| 38 |
+
"o_proj",
|
| 39 |
+
"k_proj",
|
| 40 |
+
"gate_proj",
|
| 41 |
+
"v_proj",
|
| 42 |
+
"q_proj",
|
| 43 |
+
"down_proj"
|
| 44 |
+
],
|
| 45 |
+
"target_parameters": null,
|
| 46 |
+
"task_type": "CAUSAL_LM",
|
| 47 |
+
"trainable_token_indices": null,
|
| 48 |
+
"use_bdlora": null,
|
| 49 |
+
"use_dora": false,
|
| 50 |
+
"use_qalora": false,
|
| 51 |
+
"use_rslora": false
|
| 52 |
+
}
|
README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: peft
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
base_model: google/gemma-4-31b-it
|
| 5 |
+
tags:
|
| 6 |
+
- pharmacovigilance
|
| 7 |
+
- drug-safety
|
| 8 |
+
- medical
|
| 9 |
+
- peft
|
| 10 |
+
- lora
|
| 11 |
+
- text-generation
|
| 12 |
+
- gemma
|
| 13 |
+
- gemma-4
|
| 14 |
+
- amd
|
| 15 |
+
- mi300x
|
| 16 |
+
- rocm
|
| 17 |
+
- tcs-amd-hackathon
|
| 18 |
+
datasets:
|
| 19 |
+
- custom
|
| 20 |
+
language:
|
| 21 |
+
- en
|
| 22 |
+
pipeline_tag: text-generation
|
| 23 |
+
model-index:
|
| 24 |
+
- name: gemmra
|
| 25 |
+
results:
|
| 26 |
+
- task:
|
| 27 |
+
type: text-generation
|
| 28 |
+
name: Pharmacovigilance Assessment
|
| 29 |
+
metrics:
|
| 30 |
+
- type: accuracy
|
| 31 |
+
value: 0.862
|
| 32 |
+
name: Composite Score (Weighted)
|
| 33 |
+
- type: accuracy
|
| 34 |
+
value: 0.995
|
| 35 |
+
name: T1 Seriousness (F1 Score)
|
| 36 |
+
- type: accuracy
|
| 37 |
+
value: 0.667
|
| 38 |
+
name: T2 MedDRA Coding (Weighted)
|
| 39 |
+
- type: accuracy
|
| 40 |
+
value: 0.801
|
| 41 |
+
name: T3 Labelling (F1 Score)
|
| 42 |
+
- type: accuracy
|
| 43 |
+
value: 0.986
|
| 44 |
+
name: T4 Causality (Weighted)
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
# Gemmra — Pharmacovigilance LoRA Adapter for Gemma 4 31B
|
| 48 |
+
|
| 49 |
+
**Gemmra** is a LoRA adapter that transforms Google's Gemma 4 31B-IT into a specialized pharmacovigilance assessment system. It automates four critical drug safety tasks that typically take 30 minutes per case manually — completing them in under 10 seconds with auditable reasoning traces.
|
| 50 |
+
|
| 51 |
+
Built for the **TCS & AMD AI Hackathon 2026** on AMD Instinct MI300X (192 GB HBM3).
|
| 52 |
+
|
| 53 |
+
> ⚠️ **Research Use Only.** This model is for research and educational purposes. It does not provide professional medical or regulatory advice. Do not use for clinical decision-making without expert oversight.
|
| 54 |
+
|
| 55 |
+
## Key Results
|
| 56 |
+
|
| 57 |
+
| Task | Metric | Score | Eval Samples |
|
| 58 |
+
|------|--------|:-----:|:------------:|
|
| 59 |
+
| T1: Seriousness Classification | F1 Score | **99.5%** | 1,027 |
|
| 60 |
+
| T2: MedDRA PT Coding | Weighted (Exact→Synonym→Fuzzy→SOC) | **66.7%** | 759 |
|
| 61 |
+
| T3: Drug Labelling Status | F1 Score | **80.1%** | 980 |
|
| 62 |
+
| T4: WHO-UMC Causality | Weighted (Exact + Partial) | **98.6%** | 794 |
|
| 63 |
+
| **Composite** | **Average (T1+T2+T3+T4)** | **86.2%** | **3,560** |
|
| 64 |
+
| Format Compliance | Structured Output Parsing | **100%** | 3,560 |
|
| 65 |
+
|
| 66 |
+
### Base Model Comparison
|
| 67 |
+
|
| 68 |
+
Evaluated on the same eval samples (base model used hand-crafted format prompts for fair comparison).
|
| 69 |
+
|
| 70 |
+
| Metric | Base Gemma 4 31B | Gemmra (SFT) | Δ |
|
| 71 |
+
|--------|:---:|:---:|:---:|
|
| 72 |
+
| T1 Seriousness (F1) | 97.7% | **99.5%** | +1.8pp |
|
| 73 |
+
| T2 MedDRA (Weighted) | 31.1% | **66.7%** | +35.6pp |
|
| 74 |
+
| T3 Labelling (F1) | 78.2% | **80.1%** | +1.9pp |
|
| 75 |
+
| T4 Causality (Weighted) | 84.5% | **98.6%** | +14.1pp |
|
| 76 |
+
| Composite | 72.9% | **86.2%** | +13.3pp |
|
| 77 |
+
|
| 78 |
+
## Model Details
|
| 79 |
+
|
| 80 |
+
- **Base Model:** [google/gemma-4-31b-it](https://huggingface.co/google/gemma-4-31b-it)
|
| 81 |
+
- **Method:** LoRA SFT (bf16, r=64) (WiSE-FT weight interpolation explored for reasoning recovery)
|
| 82 |
+
- **Training Hardware:** AMD Instinct MI300X (192 GB HBM3)
|
| 83 |
+
- **Precision:** bf16 (zero quantization — MI300X VRAM enables full precision)
|
| 84 |
+
- **Training Time:** ~1.9 hours
|
| 85 |
+
- **VRAM Usage:** 95 GB (training) / 61 GB (inference)
|
| 86 |
+
|
| 87 |
+
### LoRA Configuration
|
| 88 |
+
|
| 89 |
+
| Parameter | Value |
|
| 90 |
+
|-----------|-------|
|
| 91 |
+
| Rank (r) | 64 |
|
| 92 |
+
| Alpha (lora_alpha) | 128 |
|
| 93 |
+
| Dropout | 0.0 |
|
| 94 |
+
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
|
| 95 |
+
| Task Type | CAUSAL_LM |
|
| 96 |
+
| Trainable Parameters | ~0.5% of 31B |
|
| 97 |
+
|
| 98 |
+
### WiSE-FT (Weight Interpolation Exploration)
|
| 99 |
+
|
| 100 |
+
While pure SFT (α=1.0) is the primary model deployed due to its superior accuracy across 3 out of 4 tasks and 100% format compliance, we also explored **WiSE-FT** as a research variant to recover reasoning depth. Scaling the LoRA adapter weights by α=0.9 blends SFT format compliance with base model reasoning depth. This recovers the base model's native clinical reasoning (providing 400+ words of structured thinking) at a small cost of ~4% composite accuracy.
|
| 101 |
+
|
| 102 |
+
```
|
| 103 |
+
θ_final = α × θ_SFT + (1 - α) × θ_base (via LoRA adapter weight scaling)
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
## Training Data
|
| 107 |
+
|
| 108 |
+
| Source | Purpose | Volume |
|
| 109 |
+
|--------|---------|--------|
|
| 110 |
+
| [FDA FAERS](https://www.fda.gov/drugs/fda-adverse-event-reporting-system-faers) | Adverse event case reports (29 quarters, 2019Q1–2026Q1) | 12M+ cases |
|
| 111 |
+
| [BioDEX](https://github.com/KarelDO/BioDEX) | Biomedical literature → MedDRA PT mapping | T2 pairs |
|
| 112 |
+
| [OnSIDES](https://github.com/tatonetti-lab/onsides) | Drug label side effects → labelling ground truth | T3 pairs |
|
| 113 |
+
|
| 114 |
+
- **Training pairs:** 32,355 instruction-completion pairs
|
| 115 |
+
- **Eval samples:** 3,560 (content-hash decontaminated, MeditronFO-inspired splitting)
|
| 116 |
+
- **Diversity:** 93–99% unique completions via Combinatorial Diversity Engine
|
| 117 |
+
|
| 118 |
+
### Data Challenges Solved
|
| 119 |
+
1. **MedDRA is proprietary** — engineered PT training from BioDEX open literature
|
| 120 |
+
2. **FDA redacts doctor narratives** — built structured prompts from remaining FAERS fields
|
| 121 |
+
3. **BioDEX truncation** — abstracts cut at 500 chars hid ground truth from 92% of T2 data; fixing this single line gave 2.1× improvement
|
| 122 |
+
4. **Train/eval leakage** — content-hash splitting ensures zero contamination
|
| 123 |
+
|
| 124 |
+
## Usage
|
| 125 |
+
|
| 126 |
+
### Loading the Adapter
|
| 127 |
+
|
| 128 |
+
```python
|
| 129 |
+
import torch
|
| 130 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 131 |
+
from peft import PeftModel
|
| 132 |
+
|
| 133 |
+
# Load base model (requires ~62 GB VRAM in bf16)
|
| 134 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 135 |
+
"google/gemma-4-31b-it",
|
| 136 |
+
torch_dtype=torch.bfloat16,
|
| 137 |
+
device_map="auto",
|
| 138 |
+
)
|
| 139 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-31b-it")
|
| 140 |
+
|
| 141 |
+
# Load Gemmra LoRA adapter
|
| 142 |
+
model = PeftModel.from_pretrained(base_model, "Amaltrkmr/gemmra")
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
### Running Inference
|
| 146 |
+
|
| 147 |
+
```python
|
| 148 |
+
messages = [
|
| 149 |
+
{"role": "system", "content": "You are a pharmacovigilance expert. Assess whether this adverse event case is SERIOUS per ICH E2A criteria (Death, Life-threatening, Hospitalization, Disability, Congenital anomaly). Think step by step, then provide your structured assessment."},
|
| 150 |
+
{"role": "user", "content": """Patient: 69-year-old female
|
| 151 |
+
Drug: ACTEMRA (tocilizumab)
|
| 152 |
+
Adverse events: Cardiac arrest, Pulmonary embolism, Acute kidney injury, Haemodialysis, Platelet count decreased
|
| 153 |
+
Outcome: Patient did not survive"""}
|
| 154 |
+
]
|
| 155 |
+
|
| 156 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 157 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 158 |
+
|
| 159 |
+
with torch.no_grad():
|
| 160 |
+
outputs = model.generate(**inputs, max_new_tokens=1024, temperature=0.1, do_sample=True)
|
| 161 |
+
|
| 162 |
+
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 163 |
+
print(response)
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
**Expected Output:**
|
| 167 |
+
```
|
| 168 |
+
SERIOUS: YES
|
| 169 |
+
Criteria met: DE (Death), LT (Life-threatening), HO (Hospitalization), DS (Disability)
|
| 170 |
+
Rationale: The clinical outcome meets multiple seriousness categories, confirming serious classification.
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
### Using with Unsloth (Faster)
|
| 174 |
+
|
| 175 |
+
```python
|
| 176 |
+
from unsloth import FastLanguageModel
|
| 177 |
+
import torch
|
| 178 |
+
|
| 179 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 180 |
+
model_name="google/gemma-4-31b-it",
|
| 181 |
+
max_seq_length=8192,
|
| 182 |
+
load_in_4bit=False,
|
| 183 |
+
dtype=torch.bfloat16,
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
from peft import PeftModel
|
| 187 |
+
model = PeftModel.from_pretrained(model, "Amaltrkmr/gemmra")
|
| 188 |
+
FastLanguageModel.for_inference(model)
|
| 189 |
+
```
|
| 190 |
+
|
| 191 |
+
## Four Pharmacovigilance Tasks
|
| 192 |
+
|
| 193 |
+
| Task | Input | Output | Regulatory Framework |
|
| 194 |
+
|------|-------|--------|---------------------|
|
| 195 |
+
| T1: Seriousness | Patient demographics, AEs, outcomes | SERIOUS: YES/NO + criteria (DE/LT/HO/DS/CA) | ICH E2A |
|
| 196 |
+
| T2: MedDRA Coding | Adverse event narrative | MedDRA Preferred Term | MedDRA hierarchy |
|
| 197 |
+
| T3: Labelling | Drug name + adverse event | LABELLED: YES/NO + evidence | Drug product labels |
|
| 198 |
+
| T4: Causality | Full case context | WHO-UMC category + 6-dim evidence | WHO-UMC criteria |
|
| 199 |
+
|
| 200 |
+
## Training Pipeline
|
| 201 |
+
|
| 202 |
+
```
|
| 203 |
+
FAERS + BioDEX + OnSIDES
|
| 204 |
+
↓
|
| 205 |
+
Combinatorial Diversity Engine → 32,355 pairs
|
| 206 |
+
↓
|
| 207 |
+
SFT (bf16 LoRA r=64 on MI300X, ~1.9 hrs) → Primary Adapter ✅
|
| 208 |
+
↓
|
| 209 |
+
WiSE-FT exploration (α=0.9) → Explored reasoning variant
|
| 210 |
+
↓
|
| 211 |
+
GRPO validation → +0.003 composite improvement → validated SFT ceiling
|
| 212 |
+
↓
|
| 213 |
+
Evaluation (3,560 decontaminated samples)
|
| 214 |
+
↓
|
| 215 |
+
This Adapter ✅
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
## Hardware Requirements
|
| 219 |
+
|
| 220 |
+
| Setup | VRAM Required | Notes |
|
| 221 |
+
|-------|:---:|-------|
|
| 222 |
+
| bf16 inference | ~62 GB | AMD MI300X (192 GB) ✅, 2× A100 80 GB ✅ |
|
| 223 |
+
| 4-bit inference | ~18 GB | Single A100/RTX 4090 |
|
| 224 |
+
| bf16 training (LoRA r=64) | ~95 GB | AMD MI300X only — impossible on single NVIDIA GPU |
|
| 225 |
+
|
| 226 |
+
## AMD MI300X Advantage
|
| 227 |
+
|
| 228 |
+
Training this model at bf16 precision with LoRA r=64 across all 7 linear layer types requires 95 GB VRAM. This is physically impossible on any single NVIDIA GPU (A100/H100 max at 80 GB). AMD MI300X's 192 GB HBM3 is the enabling technology — zero quantization means higher quality gradients and a better final model.
|
| 229 |
+
|
| 230 |
+
## Limitations
|
| 231 |
+
|
| 232 |
+
- **MedDRA vocabulary:** Trained on BioDEX-derived PTs (~5,000 terms), not the full proprietary MedDRA dictionary (80,000+ PTs). T2 accuracy will improve with dictionary augmentation.
|
| 233 |
+
- **Data source:** FDA FAERS data has known limitations — doctor narratives are redacted, outcome codes can be inconsistent.
|
| 234 |
+
- **Not a medical device:** Outputs require expert review before regulatory submission.
|
| 235 |
+
- **English only:** Trained exclusively on English-language adverse event reports.
|
| 236 |
+
|
| 237 |
+
## Citation
|
| 238 |
+
|
| 239 |
+
```bibtex
|
| 240 |
+
@misc{gemmra2026,
|
| 241 |
+
title={Gemmra: Multi-Task Pharmacovigilance Assessment with Fine-Tuned Gemma 4 on AMD MI300X},
|
| 242 |
+
author={Amal T R and Bhaskar Jha},
|
| 243 |
+
year={2026},
|
| 244 |
+
howpublished={TCS \& AMD AI Hackathon 2026},
|
| 245 |
+
url={https://github.com/bhaskarjha-dev/gemmra}
|
| 246 |
+
}
|
| 247 |
+
```
|
| 248 |
+
|
| 249 |
+
## Contributors
|
| 250 |
+
|
| 251 |
+
- **[Amal T R](https://huggingface.co/Amaltrkmr)** — Model training, evaluation, data pipeline, WiSE-FT research
|
| 252 |
+
- **[Bhaskar Jha](https://huggingface.co/bhaskarjha-dev)** — Architecture, data engineering, website, presentation, system design
|
| 253 |
+
|
| 254 |
+
## Links
|
| 255 |
+
|
| 256 |
+
- 🌐 **Website:** [gemmra.bhaskarjha.dev](https://gemmra.bhaskarjha.dev)
|
| 257 |
+
- 💻 **GitHub:** [bhaskarjha-dev/gemmra](https://github.com/bhaskarjha-dev/gemmra) (upstream: [amaltr/gemmra](https://github.com/amaltr/gemmra))
|
| 258 |
+
- 🏆 **Hackathon:** TCS & AMD AI Hackathon 2026 — Track: Fine-Tuning (FINETUNING_005)
|
adapter_config.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": {
|
| 6 |
+
"base_model_class": "Gemma4ForConditionalGeneration",
|
| 7 |
+
"parent_library": "transformers.models.gemma4.modeling_gemma4",
|
| 8 |
+
"unsloth_fixed": true
|
| 9 |
+
},
|
| 10 |
+
"base_model_name_or_path": "google/gemma-4-31b-it",
|
| 11 |
+
"bias": "none",
|
| 12 |
+
"corda_config": null,
|
| 13 |
+
"ensure_weight_tying": false,
|
| 14 |
+
"eva_config": null,
|
| 15 |
+
"exclude_modules": null,
|
| 16 |
+
"fan_in_fan_out": false,
|
| 17 |
+
"inference_mode": true,
|
| 18 |
+
"init_lora_weights": true,
|
| 19 |
+
"layer_replication": null,
|
| 20 |
+
"layers_pattern": null,
|
| 21 |
+
"layers_to_transform": null,
|
| 22 |
+
"loftq_config": {},
|
| 23 |
+
"lora_alpha": 128,
|
| 24 |
+
"lora_bias": false,
|
| 25 |
+
"lora_dropout": 0,
|
| 26 |
+
"lora_ga_config": null,
|
| 27 |
+
"megatron_config": null,
|
| 28 |
+
"megatron_core": "megatron.core",
|
| 29 |
+
"modules_to_save": null,
|
| 30 |
+
"peft_type": "LORA",
|
| 31 |
+
"peft_version": "0.19.1",
|
| 32 |
+
"qalora_group_size": 16,
|
| 33 |
+
"r": 64,
|
| 34 |
+
"rank_pattern": {},
|
| 35 |
+
"revision": null,
|
| 36 |
+
"target_modules": [
|
| 37 |
+
"up_proj",
|
| 38 |
+
"o_proj",
|
| 39 |
+
"k_proj",
|
| 40 |
+
"gate_proj",
|
| 41 |
+
"v_proj",
|
| 42 |
+
"q_proj",
|
| 43 |
+
"down_proj"
|
| 44 |
+
],
|
| 45 |
+
"target_parameters": null,
|
| 46 |
+
"task_type": "CAUSAL_LM",
|
| 47 |
+
"trainable_token_indices": null,
|
| 48 |
+
"use_bdlora": null,
|
| 49 |
+
"use_dora": false,
|
| 50 |
+
"use_qalora": false,
|
| 51 |
+
"use_rslora": false
|
| 52 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3c68d1ff21a35ca0cdd1f2276410b90bb1a60f9431648fa77fcf7aa481bb2bce
|
| 3 |
+
size 2135894176
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- macro format_parameters(properties, required, filter_keys=false) -%}
|
| 2 |
+
{%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
|
| 3 |
+
{%- set ns = namespace(found_first=false) -%}
|
| 4 |
+
{%- for key, value in properties | dictsort -%}
|
| 5 |
+
{%- set add_comma = false -%}
|
| 6 |
+
{%- if not filter_keys or key not in standard_keys -%}
|
| 7 |
+
{%- if ns.found_first %},{% endif -%}
|
| 8 |
+
{%- set ns.found_first = true -%}
|
| 9 |
+
{{ key }}:{
|
| 10 |
+
{%- if value['description'] -%}
|
| 11 |
+
description:<|"|>{{ value['description'] }}<|"|>
|
| 12 |
+
{%- set add_comma = true -%}
|
| 13 |
+
{%- endif -%}
|
| 14 |
+
{%- if value['type'] | upper == 'STRING' -%}
|
| 15 |
+
{%- if value['enum'] -%}
|
| 16 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 17 |
+
enum:{{ format_argument(value['enum']) }}
|
| 18 |
+
{%- endif -%}
|
| 19 |
+
{%- elif value['type'] | upper == 'ARRAY' -%}
|
| 20 |
+
{%- if value['items'] is mapping and value['items'] -%}
|
| 21 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 22 |
+
items:{
|
| 23 |
+
{%- set ns_items = namespace(found_first=false) -%}
|
| 24 |
+
{%- for item_key, item_value in value['items'] | dictsort -%}
|
| 25 |
+
{%- if item_value is not none -%}
|
| 26 |
+
{%- if ns_items.found_first %},{% endif -%}
|
| 27 |
+
{%- set ns_items.found_first = true -%}
|
| 28 |
+
{%- if item_key == 'properties' -%}
|
| 29 |
+
properties:{
|
| 30 |
+
{%- if item_value is mapping -%}
|
| 31 |
+
{{- format_parameters(item_value, value['items']['required'] | default([])) -}}
|
| 32 |
+
{%- endif -%}
|
| 33 |
+
}
|
| 34 |
+
{%- elif item_key == 'required' -%}
|
| 35 |
+
required:[
|
| 36 |
+
{%- for req_item in item_value -%}
|
| 37 |
+
<|"|>{{- req_item -}}<|"|>
|
| 38 |
+
{%- if not loop.last %},{% endif -%}
|
| 39 |
+
{%- endfor -%}
|
| 40 |
+
]
|
| 41 |
+
{%- elif item_key == 'type' -%}
|
| 42 |
+
{%- if item_value is string -%}
|
| 43 |
+
type:{{ format_argument(item_value | upper) }}
|
| 44 |
+
{%- else -%}
|
| 45 |
+
type:{{ format_argument(item_value | map('upper') | list) }}
|
| 46 |
+
{%- endif -%}
|
| 47 |
+
{%- else -%}
|
| 48 |
+
{{ item_key }}:{{ format_argument(item_value) }}
|
| 49 |
+
{%- endif -%}
|
| 50 |
+
{%- endif -%}
|
| 51 |
+
{%- endfor -%}
|
| 52 |
+
}
|
| 53 |
+
{%- endif -%}
|
| 54 |
+
{%- endif -%}
|
| 55 |
+
{%- if value['nullable'] %}
|
| 56 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 57 |
+
nullable:true
|
| 58 |
+
{%- endif -%}
|
| 59 |
+
{%- if value['type'] | upper == 'OBJECT' -%}
|
| 60 |
+
{%- if value['properties'] is defined and value['properties'] is mapping -%}
|
| 61 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 62 |
+
properties:{
|
| 63 |
+
{{- format_parameters(value['properties'], value['required'] | default([])) -}}
|
| 64 |
+
}
|
| 65 |
+
{%- elif value is mapping -%}
|
| 66 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 67 |
+
properties:{
|
| 68 |
+
{{- format_parameters(value, value['required'] | default([]), filter_keys=true) -}}
|
| 69 |
+
}
|
| 70 |
+
{%- endif -%}
|
| 71 |
+
{%- if value['required'] -%}
|
| 72 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 73 |
+
required:[
|
| 74 |
+
{%- for item in value['required'] | default([]) -%}
|
| 75 |
+
<|"|>{{- item -}}<|"|>
|
| 76 |
+
{%- if not loop.last %},{% endif -%}
|
| 77 |
+
{%- endfor -%}
|
| 78 |
+
]
|
| 79 |
+
{%- endif -%}
|
| 80 |
+
{%- endif -%}
|
| 81 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 82 |
+
type:<|"|>{{ value['type'] | upper }}<|"|>}
|
| 83 |
+
{%- endif -%}
|
| 84 |
+
{%- endfor -%}
|
| 85 |
+
{%- endmacro -%}
|
| 86 |
+
{%- macro format_function_declaration(tool_data) -%}
|
| 87 |
+
declaration:{{- tool_data['function']['name'] -}}{description:<|"|>{{- tool_data['function']['description'] -}}<|"|>
|
| 88 |
+
{%- set params = tool_data['function']['parameters'] -%}
|
| 89 |
+
{%- if params -%}
|
| 90 |
+
,parameters:{
|
| 91 |
+
{%- if params['properties'] -%}
|
| 92 |
+
properties:{ {{- format_parameters(params['properties'], params['required']) -}} },
|
| 93 |
+
{%- endif -%}
|
| 94 |
+
{%- if params['required'] -%}
|
| 95 |
+
required:[
|
| 96 |
+
{%- for item in params['required'] -%}
|
| 97 |
+
<|"|>{{- item -}}<|"|>
|
| 98 |
+
{{- ',' if not loop.last -}}
|
| 99 |
+
{%- endfor -%}
|
| 100 |
+
],
|
| 101 |
+
{%- endif -%}
|
| 102 |
+
{%- if params['type'] -%}
|
| 103 |
+
type:<|"|>{{- params['type'] | upper -}}<|"|>}
|
| 104 |
+
{%- endif -%}
|
| 105 |
+
{%- endif -%}
|
| 106 |
+
{%- if 'response' in tool_data['function'] -%}
|
| 107 |
+
{%- set response_declaration = tool_data['function']['response'] -%}
|
| 108 |
+
,response:{
|
| 109 |
+
{%- if response_declaration['description'] -%}
|
| 110 |
+
description:<|"|>{{- response_declaration['description'] -}}<|"|>,
|
| 111 |
+
{%- endif -%}
|
| 112 |
+
{%- if response_declaration['type'] | upper == 'OBJECT' -%}
|
| 113 |
+
type:<|"|>{{- response_declaration['type'] | upper -}}<|"|>}
|
| 114 |
+
{%- endif -%}
|
| 115 |
+
{%- endif -%}
|
| 116 |
+
}
|
| 117 |
+
{%- endmacro -%}
|
| 118 |
+
{%- macro format_argument(argument, escape_keys=True) -%}
|
| 119 |
+
{%- if argument is string -%}
|
| 120 |
+
{{- '<|"|>' + argument + '<|"|>' -}}
|
| 121 |
+
{%- elif argument is boolean -%}
|
| 122 |
+
{{- 'true' if argument else 'false' -}}
|
| 123 |
+
{%- elif argument is mapping -%}
|
| 124 |
+
{{- '{' -}}
|
| 125 |
+
{%- set ns = namespace(found_first=false) -%}
|
| 126 |
+
{%- for key, value in argument | dictsort -%}
|
| 127 |
+
{%- if ns.found_first %},{% endif -%}
|
| 128 |
+
{%- set ns.found_first = true -%}
|
| 129 |
+
{%- if escape_keys -%}
|
| 130 |
+
{{- '<|"|>' + key + '<|"|>' -}}
|
| 131 |
+
{%- else -%}
|
| 132 |
+
{{- key -}}
|
| 133 |
+
{%- endif -%}
|
| 134 |
+
:{{- format_argument(value, escape_keys=escape_keys) -}}
|
| 135 |
+
{%- endfor -%}
|
| 136 |
+
{{- '}' -}}
|
| 137 |
+
{%- elif argument is sequence -%}
|
| 138 |
+
{{- '[' -}}
|
| 139 |
+
{%- for item in argument -%}
|
| 140 |
+
{{- format_argument(item, escape_keys=escape_keys) -}}
|
| 141 |
+
{%- if not loop.last %},{% endif -%}
|
| 142 |
+
{%- endfor -%}
|
| 143 |
+
{{- ']' -}}
|
| 144 |
+
{%- else -%}
|
| 145 |
+
{{- argument -}}
|
| 146 |
+
{%- endif -%}
|
| 147 |
+
{%- endmacro -%}
|
| 148 |
+
{%- macro strip_thinking(text) -%}
|
| 149 |
+
{%- set ns = namespace(result='') -%}
|
| 150 |
+
{%- for part in text.split('<channel|>') -%}
|
| 151 |
+
{%- if '<|channel>' in part -%}
|
| 152 |
+
{%- set ns.result = ns.result + part.split('<|channel>')[0] -%}
|
| 153 |
+
{%- else -%}
|
| 154 |
+
{%- set ns.result = ns.result + part -%}
|
| 155 |
+
{%- endif -%}
|
| 156 |
+
{%- endfor -%}
|
| 157 |
+
{{- ns.result | trim -}}
|
| 158 |
+
{%- endmacro -%}
|
| 159 |
+
|
| 160 |
+
{%- macro format_tool_response_block(tool_name, response) -%}
|
| 161 |
+
{{- '<|tool_response>' -}}
|
| 162 |
+
{%- if response is mapping -%}
|
| 163 |
+
{{- 'response:' + tool_name + '{' -}}
|
| 164 |
+
{%- for key, value in response | dictsort -%}
|
| 165 |
+
{{- key -}}:{{- format_argument(value, escape_keys=False) -}}
|
| 166 |
+
{%- if not loop.last %},{% endif -%}
|
| 167 |
+
{%- endfor -%}
|
| 168 |
+
{{- '}' -}}
|
| 169 |
+
{%- else -%}
|
| 170 |
+
{{- 'response:' + tool_name + '{value:' + format_argument(response, escape_keys=False) + '}' -}}
|
| 171 |
+
{%- endif -%}
|
| 172 |
+
{{- '<tool_response|>' -}}
|
| 173 |
+
{%- endmacro -%}
|
| 174 |
+
|
| 175 |
+
{%- set ns = namespace(prev_message_type=None) -%}
|
| 176 |
+
{%- set loop_messages = messages -%}
|
| 177 |
+
{{- bos_token -}}
|
| 178 |
+
{#- Handle System/Tool Definitions Block -#}
|
| 179 |
+
{%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}
|
| 180 |
+
{{- '<|turn>system\n' -}}
|
| 181 |
+
{#- Inject Thinking token at the very top of the FIRST system turn -#}
|
| 182 |
+
{%- if enable_thinking is defined and enable_thinking -%}
|
| 183 |
+
{{- '<|think|>\n' -}}
|
| 184 |
+
{%- set ns.prev_message_type = 'think' -%}
|
| 185 |
+
{%- endif -%}
|
| 186 |
+
{%- if messages[0]['role'] in ['system', 'developer'] -%}
|
| 187 |
+
{%- if messages[0]['content'] is string -%}
|
| 188 |
+
{{- messages[0]['content'] | trim -}}
|
| 189 |
+
{%- elif messages[0]['content'] is sequence -%}
|
| 190 |
+
{%- for item in messages[0]['content'] -%}
|
| 191 |
+
{{- item['text'] | trim + ' '-}}
|
| 192 |
+
{%- endfor -%}
|
| 193 |
+
{%- endif -%}
|
| 194 |
+
{%- set loop_messages = messages[1:] -%}
|
| 195 |
+
{%- endif -%}
|
| 196 |
+
{%- if tools -%}
|
| 197 |
+
{%- for tool in tools %}
|
| 198 |
+
{{- '<|tool>' -}}
|
| 199 |
+
{{- format_function_declaration(tool) | trim -}}
|
| 200 |
+
{{- '<tool|>' -}}
|
| 201 |
+
{%- endfor %}
|
| 202 |
+
{%- set ns.prev_message_type = 'tool' -%}
|
| 203 |
+
{%- endif -%}
|
| 204 |
+
{{- '<turn|>\n' -}}
|
| 205 |
+
{%- endif %}
|
| 206 |
+
|
| 207 |
+
{#- Pre-scan: find last user message index for reasoning guard -#}
|
| 208 |
+
{%- set ns_turn = namespace(last_user_idx=-1) -%}
|
| 209 |
+
{%- for i in range(loop_messages | length) -%}
|
| 210 |
+
{%- if loop_messages[i]['role'] == 'user' -%}
|
| 211 |
+
{%- set ns_turn.last_user_idx = i -%}
|
| 212 |
+
{%- endif -%}
|
| 213 |
+
{%- endfor -%}
|
| 214 |
+
|
| 215 |
+
{#- Loop through messages -#}
|
| 216 |
+
{%- for message in loop_messages -%}
|
| 217 |
+
{%- if message['role'] != 'tool' -%}
|
| 218 |
+
{%- set ns.prev_message_type = None -%}
|
| 219 |
+
{%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
|
| 220 |
+
{#- Detect continuation: suppress duplicate <|turn>model when previous non-tool message was also assistant -#}
|
| 221 |
+
{%- set prev_nt = namespace(role=None, found=false) -%}
|
| 222 |
+
{%- if loop.index0 > 0 -%}
|
| 223 |
+
{%- for j in range(loop.index0 - 1, -1, -1) -%}
|
| 224 |
+
{%- if not prev_nt.found -%}
|
| 225 |
+
{%- if loop_messages[j]['role'] != 'tool' -%}
|
| 226 |
+
{%- set prev_nt.role = loop_messages[j]['role'] -%}
|
| 227 |
+
{%- set prev_nt.found = true -%}
|
| 228 |
+
{%- endif -%}
|
| 229 |
+
{%- endif -%}
|
| 230 |
+
{%- endfor -%}
|
| 231 |
+
{%- endif -%}
|
| 232 |
+
{%- set continue_same_model_turn = (role == 'model' and prev_nt.role == 'assistant') -%}
|
| 233 |
+
{%- if not continue_same_model_turn -%}
|
| 234 |
+
{{- '<|turn>' + role + '\n' }}
|
| 235 |
+
{%- endif -%}
|
| 236 |
+
|
| 237 |
+
{#- Render reasoning/reasoning_content as thinking channel -#}
|
| 238 |
+
{%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
|
| 239 |
+
{%- if thinking_text and loop.index0 > ns_turn.last_user_idx and message.get('tool_calls') -%}
|
| 240 |
+
{{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
|
| 241 |
+
{%- endif -%}
|
| 242 |
+
|
| 243 |
+
{%- if message['tool_calls'] -%}
|
| 244 |
+
{%- for tool_call in message['tool_calls'] -%}
|
| 245 |
+
{%- set function = tool_call['function'] -%}
|
| 246 |
+
{{- '<|tool_call>call:' + function['name'] + '{' -}}
|
| 247 |
+
{%- if function['arguments'] is mapping -%}
|
| 248 |
+
{%- set ns_args = namespace(found_first=false) -%}
|
| 249 |
+
{%- for key, value in function['arguments'] | dictsort -%}
|
| 250 |
+
{%- if ns_args.found_first %},{% endif -%}
|
| 251 |
+
{%- set ns_args.found_first = true -%}
|
| 252 |
+
{{- key -}}:{{- format_argument(value, escape_keys=False) -}}
|
| 253 |
+
{%- endfor -%}
|
| 254 |
+
{%- elif function['arguments'] is string -%}
|
| 255 |
+
{{- function['arguments'] -}}
|
| 256 |
+
{%- endif -%}
|
| 257 |
+
{{- '}<tool_call|>' -}}
|
| 258 |
+
{%- endfor -%}
|
| 259 |
+
{%- set ns.prev_message_type = 'tool_call' -%}
|
| 260 |
+
{%- endif -%}
|
| 261 |
+
|
| 262 |
+
{%- set ns_tr_out = namespace(flag=false) -%}
|
| 263 |
+
{%- if message.get('tool_responses') -%}
|
| 264 |
+
{#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}
|
| 265 |
+
{%- for tool_response in message['tool_responses'] -%}
|
| 266 |
+
{{- format_tool_response_block(tool_response['name'] | default('unknown'), tool_response['response']) -}}
|
| 267 |
+
{%- set ns_tr_out.flag = true -%}
|
| 268 |
+
{%- set ns.prev_message_type = 'tool_response' -%}
|
| 269 |
+
{%- endfor -%}
|
| 270 |
+
{%- elif message.get('tool_calls') -%}
|
| 271 |
+
{#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}
|
| 272 |
+
{%- set ns_tool_scan = namespace(stopped=false) -%}
|
| 273 |
+
{%- for k in range(loop.index0 + 1, loop_messages | length) -%}
|
| 274 |
+
{%- if ns_tool_scan.stopped -%}
|
| 275 |
+
{%- elif loop_messages[k]['role'] != 'tool' -%}
|
| 276 |
+
{%- set ns_tool_scan.stopped = true -%}
|
| 277 |
+
{%- else -%}
|
| 278 |
+
{%- set follow = loop_messages[k] -%}
|
| 279 |
+
{#- Resolve tool_call_id to function name -#}
|
| 280 |
+
{%- set ns_tname = namespace(name=follow.get('name') | default('unknown')) -%}
|
| 281 |
+
{%- for tc in message['tool_calls'] -%}
|
| 282 |
+
{%- if tc.get('id') == follow.get('tool_call_id') -%}
|
| 283 |
+
{%- set ns_tname.name = tc['function']['name'] -%}
|
| 284 |
+
{%- endif -%}
|
| 285 |
+
{%- endfor -%}
|
| 286 |
+
{#- Handle content as string or content-parts array -#}
|
| 287 |
+
{%- set tool_body = follow.get('content') -%}
|
| 288 |
+
{%- if tool_body is string -%}
|
| 289 |
+
{{- format_tool_response_block(ns_tname.name, tool_body) -}}
|
| 290 |
+
{%- elif tool_body is sequence and tool_body is not string -%}
|
| 291 |
+
{%- set ns_txt = namespace(s='') -%}
|
| 292 |
+
{%- for part in tool_body -%}
|
| 293 |
+
{%- if part.get('type') == 'text' -%}
|
| 294 |
+
{%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}
|
| 295 |
+
{%- endif -%}
|
| 296 |
+
{%- endfor -%}
|
| 297 |
+
{{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}
|
| 298 |
+
{%- else -%}
|
| 299 |
+
{{- format_tool_response_block(ns_tname.name, tool_body) -}}
|
| 300 |
+
{%- endif -%}
|
| 301 |
+
{%- set ns_tr_out.flag = true -%}
|
| 302 |
+
{%- set ns.prev_message_type = 'tool_response' -%}
|
| 303 |
+
{%- endif -%}
|
| 304 |
+
{%- endfor -%}
|
| 305 |
+
{%- endif -%}
|
| 306 |
+
|
| 307 |
+
{%- set captured_content -%}
|
| 308 |
+
{%- if message['content'] is string -%}
|
| 309 |
+
{%- if role == 'model' -%}
|
| 310 |
+
{{- strip_thinking(message['content']) -}}
|
| 311 |
+
{%- else -%}
|
| 312 |
+
{{- message['content'] | trim -}}
|
| 313 |
+
{%- endif -%}
|
| 314 |
+
{%- elif message['content'] is sequence -%}
|
| 315 |
+
{%- for item in message['content'] -%}
|
| 316 |
+
{%- if item['type'] == 'text' -%}
|
| 317 |
+
{%- if role == 'model' -%}
|
| 318 |
+
{{- strip_thinking(item['text']) -}}
|
| 319 |
+
{%- else -%}
|
| 320 |
+
{{- item['text'] | trim -}}
|
| 321 |
+
{%- endif -%}
|
| 322 |
+
{%- elif item['type'] == 'image' -%}
|
| 323 |
+
{{- '<|image|>' -}}
|
| 324 |
+
{%- set ns.prev_message_type = 'image' -%}
|
| 325 |
+
{%- elif item['type'] == 'audio' -%}
|
| 326 |
+
{{- '<|audio|>' -}}
|
| 327 |
+
{%- set ns.prev_message_type = 'audio' -%}
|
| 328 |
+
{%- elif item['type'] == 'video' -%}
|
| 329 |
+
{{- '<|video|>' -}}
|
| 330 |
+
{%- set ns.prev_message_type = 'video' -%}
|
| 331 |
+
{%- endif -%}
|
| 332 |
+
{%- endfor -%}
|
| 333 |
+
{%- endif -%}
|
| 334 |
+
{%- endset -%}
|
| 335 |
+
|
| 336 |
+
{{- captured_content -}}
|
| 337 |
+
{%- set has_content = captured_content | trim | length > 0 -%}
|
| 338 |
+
|
| 339 |
+
{%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
|
| 340 |
+
{{- '<|tool_response>' -}}
|
| 341 |
+
{%- elif not (ns_tr_out.flag and not has_content) -%}
|
| 342 |
+
{{- '<turn|>\n' -}}
|
| 343 |
+
{%- endif -%}
|
| 344 |
+
{%- endif -%}
|
| 345 |
+
{%- endfor -%}
|
| 346 |
+
|
| 347 |
+
{%- if add_generation_prompt -%}
|
| 348 |
+
{%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}
|
| 349 |
+
{{- '<|turn>model\n' -}}
|
| 350 |
+
{%- if not enable_thinking | default(false) -%}
|
| 351 |
+
{{- '<|channel>thought\n<channel|>' -}}
|
| 352 |
+
{%- endif -%}
|
| 353 |
+
{%- endif -%}
|
| 354 |
+
{%- endif -%}
|
processor_config.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_ms_per_token": 40,
|
| 3 |
+
"audio_seq_length": 750,
|
| 4 |
+
"feature_extractor": {
|
| 5 |
+
"dither": 0.0,
|
| 6 |
+
"feature_extractor_type": "Gemma4AudioFeatureExtractor",
|
| 7 |
+
"feature_size": 128,
|
| 8 |
+
"fft_length": 512,
|
| 9 |
+
"fft_overdrive": false,
|
| 10 |
+
"frame_length": 320,
|
| 11 |
+
"hop_length": 160,
|
| 12 |
+
"input_scale_factor": 1.0,
|
| 13 |
+
"max_frequency": 8000.0,
|
| 14 |
+
"mel_floor": 0.001,
|
| 15 |
+
"min_frequency": 0.0,
|
| 16 |
+
"padding_side": "right",
|
| 17 |
+
"padding_value": 0.0,
|
| 18 |
+
"per_bin_mean": null,
|
| 19 |
+
"per_bin_stddev": null,
|
| 20 |
+
"preemphasis": 0.0,
|
| 21 |
+
"preemphasis_htk_flavor": true,
|
| 22 |
+
"return_attention_mask": true,
|
| 23 |
+
"sampling_rate": 16000
|
| 24 |
+
},
|
| 25 |
+
"image_processor": {
|
| 26 |
+
"do_convert_rgb": true,
|
| 27 |
+
"do_normalize": false,
|
| 28 |
+
"do_rescale": true,
|
| 29 |
+
"do_resize": true,
|
| 30 |
+
"image_mean": [
|
| 31 |
+
0.0,
|
| 32 |
+
0.0,
|
| 33 |
+
0.0
|
| 34 |
+
],
|
| 35 |
+
"image_processor_type": "Gemma4ImageProcessor",
|
| 36 |
+
"image_seq_length": 280,
|
| 37 |
+
"image_std": [
|
| 38 |
+
1.0,
|
| 39 |
+
1.0,
|
| 40 |
+
1.0
|
| 41 |
+
],
|
| 42 |
+
"max_soft_tokens": 280,
|
| 43 |
+
"patch_size": 16,
|
| 44 |
+
"pooling_kernel_size": 3,
|
| 45 |
+
"resample": 3,
|
| 46 |
+
"rescale_factor": 0.00392156862745098
|
| 47 |
+
},
|
| 48 |
+
"image_seq_length": 280,
|
| 49 |
+
"processor_class": "Gemma4Processor",
|
| 50 |
+
"video_processor": {
|
| 51 |
+
"do_convert_rgb": true,
|
| 52 |
+
"do_normalize": true,
|
| 53 |
+
"do_rescale": true,
|
| 54 |
+
"do_resize": true,
|
| 55 |
+
"do_sample_frames": true,
|
| 56 |
+
"image_mean": [
|
| 57 |
+
0.0,
|
| 58 |
+
0.0,
|
| 59 |
+
0.0
|
| 60 |
+
],
|
| 61 |
+
"image_std": [
|
| 62 |
+
1.0,
|
| 63 |
+
1.0,
|
| 64 |
+
1.0
|
| 65 |
+
],
|
| 66 |
+
"max_soft_tokens": 70,
|
| 67 |
+
"num_frames": 32,
|
| 68 |
+
"patch_size": 16,
|
| 69 |
+
"pooling_kernel_size": 3,
|
| 70 |
+
"resample": 3,
|
| 71 |
+
"rescale_factor": 0.00392156862745098,
|
| 72 |
+
"return_metadata": false,
|
| 73 |
+
"video_processor_type": "Gemma4VideoProcessor"
|
| 74 |
+
}
|
| 75 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f
|
| 3 |
+
size 32169626
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_token": "<|audio|>",
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"boa_token": "<|audio>",
|
| 5 |
+
"boi_token": "<|image>",
|
| 6 |
+
"bos_token": "<bos>",
|
| 7 |
+
"eoa_token": "<audio|>",
|
| 8 |
+
"eoc_token": "<channel|>",
|
| 9 |
+
"eoi_token": "<image|>",
|
| 10 |
+
"eos_token": "<turn|>",
|
| 11 |
+
"eot_token": "<turn|>",
|
| 12 |
+
"escape_token": "<|\"|>",
|
| 13 |
+
"etc_token": "<tool_call|>",
|
| 14 |
+
"etd_token": "<tool|>",
|
| 15 |
+
"etr_token": "<tool_response|>",
|
| 16 |
+
"extra_special_tokens": [
|
| 17 |
+
"<|video|>"
|
| 18 |
+
],
|
| 19 |
+
"image_token": "<|image|>",
|
| 20 |
+
"is_local": false,
|
| 21 |
+
"local_files_only": false,
|
| 22 |
+
"mask_token": "<mask>",
|
| 23 |
+
"model_max_length": 262144,
|
| 24 |
+
"model_specific_special_tokens": {
|
| 25 |
+
"audio_token": "<|audio|>",
|
| 26 |
+
"boa_token": "<|audio>",
|
| 27 |
+
"boi_token": "<|image>",
|
| 28 |
+
"eoa_token": "<audio|>",
|
| 29 |
+
"eoc_token": "<channel|>",
|
| 30 |
+
"eoi_token": "<image|>",
|
| 31 |
+
"eot_token": "<turn|>",
|
| 32 |
+
"escape_token": "<|\"|>",
|
| 33 |
+
"etc_token": "<tool_call|>",
|
| 34 |
+
"etd_token": "<tool|>",
|
| 35 |
+
"etr_token": "<tool_response|>",
|
| 36 |
+
"image_token": "<|image|>",
|
| 37 |
+
"soc_token": "<|channel>",
|
| 38 |
+
"sot_token": "<|turn>",
|
| 39 |
+
"stc_token": "<|tool_call>",
|
| 40 |
+
"std_token": "<|tool>",
|
| 41 |
+
"str_token": "<|tool_response>",
|
| 42 |
+
"think_token": "<|think|>"
|
| 43 |
+
},
|
| 44 |
+
"pad_token": "<pad>",
|
| 45 |
+
"padding_side": "right",
|
| 46 |
+
"processor_class": "Gemma4Processor",
|
| 47 |
+
"response_schema": {
|
| 48 |
+
"properties": {
|
| 49 |
+
"content": {
|
| 50 |
+
"type": "string"
|
| 51 |
+
},
|
| 52 |
+
"role": {
|
| 53 |
+
"const": "assistant"
|
| 54 |
+
},
|
| 55 |
+
"thinking": {
|
| 56 |
+
"type": "string"
|
| 57 |
+
},
|
| 58 |
+
"tool_calls": {
|
| 59 |
+
"items": {
|
| 60 |
+
"properties": {
|
| 61 |
+
"function": {
|
| 62 |
+
"properties": {
|
| 63 |
+
"arguments": {
|
| 64 |
+
"additionalProperties": {},
|
| 65 |
+
"type": "object",
|
| 66 |
+
"x-parser": "gemma4-tool-call"
|
| 67 |
+
},
|
| 68 |
+
"name": {
|
| 69 |
+
"type": "string"
|
| 70 |
+
}
|
| 71 |
+
},
|
| 72 |
+
"type": "object",
|
| 73 |
+
"x-regex": "call\\:(?P<name>\\w+)(?P<arguments>\\{.*\\})"
|
| 74 |
+
},
|
| 75 |
+
"type": {
|
| 76 |
+
"const": "function"
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"type": "object"
|
| 80 |
+
},
|
| 81 |
+
"type": "array",
|
| 82 |
+
"x-regex-iterator": "<\\|tool_call>(.*?)<tool_call\\|>"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"type": "object",
|
| 86 |
+
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 87 |
+
},
|
| 88 |
+
"soc_token": "<|channel>",
|
| 89 |
+
"sot_token": "<|turn>",
|
| 90 |
+
"stc_token": "<|tool_call>",
|
| 91 |
+
"std_token": "<|tool>",
|
| 92 |
+
"str_token": "<|tool_response>",
|
| 93 |
+
"think_token": "<|think|>",
|
| 94 |
+
"tokenizer_class": "GemmaTokenizer",
|
| 95 |
+
"unk_token": "<unk>",
|
| 96 |
+
"added_tokens_decoder": {
|
| 97 |
+
"0": {
|
| 98 |
+
"content": "<pad>",
|
| 99 |
+
"single_word": false,
|
| 100 |
+
"lstrip": false,
|
| 101 |
+
"rstrip": false,
|
| 102 |
+
"normalized": false,
|
| 103 |
+
"special": true
|
| 104 |
+
},
|
| 105 |
+
"1": {
|
| 106 |
+
"content": "<eos>",
|
| 107 |
+
"single_word": false,
|
| 108 |
+
"lstrip": false,
|
| 109 |
+
"rstrip": false,
|
| 110 |
+
"normalized": false,
|
| 111 |
+
"special": true
|
| 112 |
+
},
|
| 113 |
+
"2": {
|
| 114 |
+
"content": "<bos>",
|
| 115 |
+
"single_word": false,
|
| 116 |
+
"lstrip": false,
|
| 117 |
+
"rstrip": false,
|
| 118 |
+
"normalized": false,
|
| 119 |
+
"special": true
|
| 120 |
+
},
|
| 121 |
+
"3": {
|
| 122 |
+
"content": "<unk>",
|
| 123 |
+
"single_word": false,
|
| 124 |
+
"lstrip": false,
|
| 125 |
+
"rstrip": false,
|
| 126 |
+
"normalized": false,
|
| 127 |
+
"special": true
|
| 128 |
+
},
|
| 129 |
+
"4": {
|
| 130 |
+
"content": "<mask>",
|
| 131 |
+
"single_word": false,
|
| 132 |
+
"lstrip": false,
|
| 133 |
+
"rstrip": false,
|
| 134 |
+
"normalized": false,
|
| 135 |
+
"special": true
|
| 136 |
+
},
|
| 137 |
+
"46": {
|
| 138 |
+
"content": "<|tool>",
|
| 139 |
+
"single_word": false,
|
| 140 |
+
"lstrip": false,
|
| 141 |
+
"rstrip": false,
|
| 142 |
+
"normalized": false,
|
| 143 |
+
"special": true
|
| 144 |
+
},
|
| 145 |
+
"47": {
|
| 146 |
+
"content": "<tool|>",
|
| 147 |
+
"single_word": false,
|
| 148 |
+
"lstrip": false,
|
| 149 |
+
"rstrip": false,
|
| 150 |
+
"normalized": false,
|
| 151 |
+
"special": true
|
| 152 |
+
},
|
| 153 |
+
"48": {
|
| 154 |
+
"content": "<|tool_call>",
|
| 155 |
+
"single_word": false,
|
| 156 |
+
"lstrip": false,
|
| 157 |
+
"rstrip": false,
|
| 158 |
+
"normalized": false,
|
| 159 |
+
"special": true
|
| 160 |
+
},
|
| 161 |
+
"49": {
|
| 162 |
+
"content": "<tool_call|>",
|
| 163 |
+
"single_word": false,
|
| 164 |
+
"lstrip": false,
|
| 165 |
+
"rstrip": false,
|
| 166 |
+
"normalized": false,
|
| 167 |
+
"special": true
|
| 168 |
+
},
|
| 169 |
+
"50": {
|
| 170 |
+
"content": "<|tool_response>",
|
| 171 |
+
"single_word": false,
|
| 172 |
+
"lstrip": false,
|
| 173 |
+
"rstrip": false,
|
| 174 |
+
"normalized": false,
|
| 175 |
+
"special": true
|
| 176 |
+
},
|
| 177 |
+
"51": {
|
| 178 |
+
"content": "<tool_response|>",
|
| 179 |
+
"single_word": false,
|
| 180 |
+
"lstrip": false,
|
| 181 |
+
"rstrip": false,
|
| 182 |
+
"normalized": false,
|
| 183 |
+
"special": true
|
| 184 |
+
},
|
| 185 |
+
"52": {
|
| 186 |
+
"content": "<|\"|>",
|
| 187 |
+
"single_word": false,
|
| 188 |
+
"lstrip": false,
|
| 189 |
+
"rstrip": false,
|
| 190 |
+
"normalized": false,
|
| 191 |
+
"special": true
|
| 192 |
+
},
|
| 193 |
+
"98": {
|
| 194 |
+
"content": "<|think|>",
|
| 195 |
+
"single_word": false,
|
| 196 |
+
"lstrip": false,
|
| 197 |
+
"rstrip": false,
|
| 198 |
+
"normalized": false,
|
| 199 |
+
"special": true
|
| 200 |
+
},
|
| 201 |
+
"100": {
|
| 202 |
+
"content": "<|channel>",
|
| 203 |
+
"single_word": false,
|
| 204 |
+
"lstrip": false,
|
| 205 |
+
"rstrip": false,
|
| 206 |
+
"normalized": false,
|
| 207 |
+
"special": true
|
| 208 |
+
},
|
| 209 |
+
"101": {
|
| 210 |
+
"content": "<channel|>",
|
| 211 |
+
"single_word": false,
|
| 212 |
+
"lstrip": false,
|
| 213 |
+
"rstrip": false,
|
| 214 |
+
"normalized": false,
|
| 215 |
+
"special": true
|
| 216 |
+
},
|
| 217 |
+
"105": {
|
| 218 |
+
"content": "<|turn>",
|
| 219 |
+
"single_word": false,
|
| 220 |
+
"lstrip": false,
|
| 221 |
+
"rstrip": false,
|
| 222 |
+
"normalized": false,
|
| 223 |
+
"special": true
|
| 224 |
+
},
|
| 225 |
+
"106": {
|
| 226 |
+
"content": "<turn|>",
|
| 227 |
+
"single_word": false,
|
| 228 |
+
"lstrip": false,
|
| 229 |
+
"rstrip": false,
|
| 230 |
+
"normalized": false,
|
| 231 |
+
"special": true
|
| 232 |
+
},
|
| 233 |
+
"255999": {
|
| 234 |
+
"content": "<|image>",
|
| 235 |
+
"single_word": false,
|
| 236 |
+
"lstrip": false,
|
| 237 |
+
"rstrip": false,
|
| 238 |
+
"normalized": false,
|
| 239 |
+
"special": true
|
| 240 |
+
},
|
| 241 |
+
"256000": {
|
| 242 |
+
"content": "<|audio>",
|
| 243 |
+
"single_word": false,
|
| 244 |
+
"lstrip": false,
|
| 245 |
+
"rstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"special": true
|
| 248 |
+
},
|
| 249 |
+
"258880": {
|
| 250 |
+
"content": "<|image|>",
|
| 251 |
+
"single_word": false,
|
| 252 |
+
"lstrip": false,
|
| 253 |
+
"rstrip": false,
|
| 254 |
+
"normalized": false,
|
| 255 |
+
"special": true
|
| 256 |
+
},
|
| 257 |
+
"258881": {
|
| 258 |
+
"content": "<|audio|>",
|
| 259 |
+
"single_word": false,
|
| 260 |
+
"lstrip": false,
|
| 261 |
+
"rstrip": false,
|
| 262 |
+
"normalized": false,
|
| 263 |
+
"special": true
|
| 264 |
+
},
|
| 265 |
+
"258882": {
|
| 266 |
+
"content": "<image|>",
|
| 267 |
+
"single_word": false,
|
| 268 |
+
"lstrip": false,
|
| 269 |
+
"rstrip": false,
|
| 270 |
+
"normalized": false,
|
| 271 |
+
"special": true
|
| 272 |
+
},
|
| 273 |
+
"258883": {
|
| 274 |
+
"content": "<audio|>",
|
| 275 |
+
"single_word": false,
|
| 276 |
+
"lstrip": false,
|
| 277 |
+
"rstrip": false,
|
| 278 |
+
"normalized": false,
|
| 279 |
+
"special": true
|
| 280 |
+
},
|
| 281 |
+
"258884": {
|
| 282 |
+
"content": "<|video|>",
|
| 283 |
+
"single_word": false,
|
| 284 |
+
"lstrip": false,
|
| 285 |
+
"rstrip": false,
|
| 286 |
+
"normalized": false,
|
| 287 |
+
"special": true
|
| 288 |
+
}
|
| 289 |
+
}
|
| 290 |
+
}
|
training_meta.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model": "google/gemma-4-31b-it",
|
| 3 |
+
"stage": "SFT",
|
| 4 |
+
"lora_r": 64,
|
| 5 |
+
"lora_alpha": 128,
|
| 6 |
+
"learning_rate": 5e-05,
|
| 7 |
+
"epochs": 1
|
| 8 |
+
}
|