Downloads · 30 days
0
kotlarmilos/gemma-3-1b-reasoning
gemma-3-1b-reasoning is a text generation model from kotlarmilos. Use it when you need the model to write or continue text. It is set up for tunix. The card lists the license as gemma.
A LoRA adapter that improves math reasoning in Gemma 3 1B-IT, trained with a three stage pipeline, SFT then SFT then GRPO, using Tunix on TPU v5e.
Downloads · 30 days
0
Access
Public
Updated Jul 9, 2026
Repo size
101 MB
Likes
0
Public
Click a slice to open those files.
.safetensors50.3 MB · 100%
From the Hugging Face model README
A LoRA adapter that improves math reasoning in Gemma 3 1B-IT, trained with a three stage pipeline, SFT then SFT then GRPO, using Tunix on TPU v5e.
This is the second step in my applied post-training track. In the first step, Phi-4 on dotnet/runtime, I changed what a small model knows by fitting it to a domain. Here I change how a model thinks. The supervised stages install a reasoning format and content, and the reinforcement stage rewards correct answers under a checker rather than a judge model. The next step, Gemma 4 GlucoLens, takes this same post-training instinct into a domain where the output is a structured rollout and the model must refuse when it is unsure.
Writeup on Kaggle, gemma-3-1b-reasoning.
Builds the reasoning foundation using structured math and science datasets.
Expands to code, summarization, and creative writing while retaining math performance through weighted sampling.
Reinforcement learning using Group Relative Policy Optimization. The reward function verifies answer correctness against GSM8K gold labels, so no judge model is needed.
| Parameter | Value |
|---|---|
| Rank | 32 |
| Alpha | 32.0 |
| Target modules | q_einsum, kv_einsum, gate_proj, down_proj, up_proj, attn_vec_einsum |
This adapter was trained with Tunix and Qwix in JAX. To load and use it:
from tunix.models.gemma3 import params, model
from tunix.generate import sampler as sampler_lib
import qwix
base = params.create_model_from_checkpoint(
params.GEMMA3_1B_IT,
model.ModelConfig.gemma3_1b_it()
)
lora_model = qwix.apply_lora_to_model(
base,
qwix.LoraProvider(
module_path=".*q_einsum|.*kv_einsum|.*gate_proj|.*down_proj|.*up_proj|.*attn_vec_einsum",
rank=32, alpha=32.0,
),
rngs=nnx.Rngs(0),
**base.get_model_input(),
)
from safetensors.numpy import load_file
adapter = load_file("adapter_model.safetensors")
# Merge adapter weights into lora_model state
tokenizer = params.create_tokenizer()
sampler = sampler_lib.Sampler(
transformer=lora_model, tokenizer=tokenizer,
cache_config=sampler_lib.CacheConfig(
cache_size=1536,
num_layers=lora_model.config.num_layers,
num_kv_heads=lora_model.config.num_kv_heads,
head_dim=lora_model.config.head_dim,
),
)
prompt = "<start_of_turn>user\nWhat is 25 * 13? Think step by step.<end_of_turn>\n<start_of_turn>model\n"
out = sampler(
input_strings=[prompt],
max_generation_steps=512,
temperature=0.7, top_k=50, top_p=0.95,
echo=False, eos_tokens=[106],
)
print(out.text[0])
@misc{kotlar2025gemma3reasoning,
title={Gemma 3 1B-IT Reasoning LoRA},
author={Kotlar, Milos},
year={2025},
url={https://github.com/kotlarmilos/gemma-3-1b-reasoning}
}