CoolFace
Modelpublic

julienp79/occitan-gemma-4-e2b-it-rslora-sfttrainer

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes184downloads
Model Card

Occitan Gemma 4 E2B IT - rs-LoRA (SFTTrainer) v2

This model is a fine-tuned version of unsloth/gemma-4-e2b-it-unsloth-bnb-4bit on Occitan language text data using rs-LoRA (Rank-Stabilized LoRA) with the SFTTrainer from the TRL library.

v2 improvements over v1: Larger rank (32 vs 16), lower learning rate with cosine schedule and warmup, weight decay, and more training steps — resulting in significantly lower loss.

Model Description

  • —Base Model: Gemma 4 E2B IT (Instruction-Tuned)
  • —Fine-tuning Method: rs-LoRA (Rank-Stabilized Low-Rank Adaptation)
  • —Training Framework: TRL SFTTrainer
  • —Language: Occitan (Lengadocian dialect)
  • —Model Type: Causal Language Model

Training Details

Hyperparameters (v2)

ParameterValue
LoRA Rank (r)32
LoRA Alpha32
Training Steps2535
Block Size384 tokens
Learning Rate1e-4
LR Schedulercosine
Warmup Steps200
Weight Decay0.01
Epochs5
Gradient Accumulation8
Optimizerpagedadamw8bit
Target Modulesqproj, kproj, vproj, oproj, gateproj, upproj, down_proj
Dropout0
Biasnone

Changes from v1

Parameterv1v2
Rank1632
Steps12702535
Learning Rate2e-41e-4
Schedulerlinearcosine
Warmup0200
Weight Decay00.01
Gradient Accum.168
OptimizerAdamWpaged_adamw_8bit

Training Loss Progression

StepLoss
101.571
1000.539
5000.415
10000.373
15000.322
20000.275
25300.247

Loss decreases steadily throughout training with a smooth cosine decay schedule, converging to ~0.25.

Repository Structure

├── adapter/                    # LoRA adapter weights (for loading with base model)
│   ├── adapter_config.json
│   ├── adapter_model.safetensors
│   ├── chat_template.jinja
│   ├── tokenizer.json
│   └── tokenizer_config.json
├── gguf/                       # GGUF quantized models (for llama.cpp)
│   ├── occitan-gemma-4-e2b-it-rslora-merged-Q4_K_M.gguf  (3.43 GB)
│   ├── occitan-gemma-4-e2b-it-rslora-merged-Q5_K_M.gguf  (3.63 GB)
│   ├── occitan-gemma-4-e2b-it-rslora-merged-Q8_0.gguf    (4.97 GB)
│   └── occitan-gemma-4-e2b-it-rslora-merged-f16.gguf    (9.31 GB)
├── config.json               # Model configuration
├── model.safetensors        # Merged 16-bit model (10.2 GB)
├── tokenizer.json
└── README.md

Usage

Option 1: Use the Merged Model (Recommended)

Load the full merged model directly:

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained(
    "julienp79/occitan-gemma-4-e2b-it-rslora-sfttrainer",
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(
    "julienp79/occitan-gemma-4-e2b-it-rslora-sfttrainer"
)

prompt = "Conta m'en una istueta brèva en occitan"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Option 2: Use with Base Model + LoRA Adapter

python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model = AutoModelForCausalLM.from_pretrained(
    "unsloth/gemma-4-e2b-it-unsloth-bnb-4bit",
    load_in_4bit=True
)
tokenizer = AutoTokenizer.from_pretrained(
    "unsloth/gemma-4-e2b-it-unsloth-bnb-4bit"
)

model = PeftModel.from_pretrained(
    base_model,
    "julienp79/occitan-gemma-4-e2b-it-rslora-sfttrainer",
    subfolder="adapter"
)

Option 3: GGUF with llama.cpp

bash
./llama-server -m occitan-gemma-4-e2b-it-rslora-merged-Q4_K_M.gguf -c 512 --port 8081
Quantization Options
FileSizeDescription
Q4KM3.43 GBRecommended: Best quality/size tradeoff
Q5KM3.63 GBHigher quality, slightly larger
Q8_04.97 GBNear-lossless quality
f169.31 GBFull 16-bit precision (lossless)

Generated Text Examples

Prompt: Lo marin

Generated continuation:

òm auriá vist.
Lo marin òm auriá vist.
Mas la marè n'es tota luènha.
Al mens per far venir l'aiga,
Cal anar a la plaja,
E la marè n'es tota luènha.
La marè n'es tota luènha
Per la far venir,
Per la far venir.
Vèni, marin, vèni,
Porta-

Quality Notes

The model generates high-quality Lengadocian Occitan text with:

  • —✅ Correct Lengadocian vocabulary (marin, auriá, marè, luènha, plaja)
  • —✅ Proper grammar (conditional, imperfect subjunctive)
  • —✅ No French/Catalan interference
  • —✅ Natural narrative style

Training Data

Trained on a corpus of Occitan text in the Lengadocian dialect, including:

  • —Traditional literature
  • —Contemporary texts
  • —Wikipedia articles
  • —Cultural documents

Limitations

  • —The model is specialized for Occitan text generation
  • —Chat template support may vary depending on inference framework
  • —For best results with instruction-following, use the text completion endpoint rather than chat endpoint in some frameworks (e.g., current llama.cpp)

Citation

If you use this model, please cite:

bibtex
@misc{occitan-gemma-4-e2b-it-rslora-sfttrainer-v2,
  author = {Julien},
  title = {Occitan Gemma 4 E2B IT - rs-LoRA SFTTrainer v2},
  year = {2026},
  publisher = {HuggingFace},
  url = {https://huggingface.co/julienp79/occitan-gemma-4-e2b-it-rslora-sfttrainer}
}