CoolFace
Modelpublic

GaborMadarasz/gemma-4-E2B-it-CV24_hun

sourceHugging Facegemmaupdated 2mo agoView on Hugging Face
0likes9downloads
Model Card

gemma-4-E2B-it-CV24_hun

Fine-tuned google/gemma-4-E2B-it for Hungarian automatic speech recognition (ASR) using LoRA adapters, trained with Unsloth.

Model Description

This model is a LoRA fine-tune of Gemma 4 E2B (2B parameter Mixture-of-Experts multimodal variant), adapted for Hungarian speech transcription using the multimodal chat format. The audio encoder and language model backbone are fine-tuned jointly via low-rank adaptation.

  • —Base model: google/gemma-4-E2B-it
  • —Architecture: Gemma 4 multimodal (text + audio)
  • —Fine-tuning method: LoRA (r=8, alpha=16) via Unsloth FastModel
  • —Saved format: Merged float16 weights (via push_to_hub_merged)

Eval results

MetricValue
CV Test WER0.2475 (24.75%)
CV Test CER0.0746 (7.46%)

Training Details

Dataset

  • —Training data: Mozilla Common Voice 24 Hungarian split (local preprocessed copy)
  • —Dataset size: ~44,350 audio-text pairs used for training
  • —Audio sampling rate: 16,000 Hz

LoRA Configuration

ParameterValue
r8
lora_alpha16
lora_dropout0
biasnone
use_rsloraFalse
Target modules (language)q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Target modules (audio)post, linear_start, linear_end, embedding_projection, ffw_layer_1, ffw_layer_2, output_proj
finetune_vision_layersFalse
finetune_language_layersTrue
finetune_attention_modulesTrue
finetune_mlp_modulesTrue

Training Hyperparameters

ParameterValue
per_device_train_batch_size2
gradient_accumulation_steps4
effective_batch_size8
num_train_epochs1
learning_rate8e-5
lr_scheduler_typecosine
warmup_ratio0.03
optimizeradamw_8bit
weight_decay0.001
max_seq_length1024
seed3407
load_in_4bitTrue (training-time quantization)

Training Hardware

Single RTX3060 12GB

5.5 GPU hours

Data Formatting

Each sample is formatted into a multimodal chat conversation:

<bos><|turn>system You are an assistant that transcribes speech accurately.<turn|> <|turn>user <|audio|>Please transcribe this audio.<turn|> <|turn>model [transcription]<turn|>

Usage

python
from unsloth import FastModel
from transformers import TextStreamer

model, processor = FastModel.from_pretrained(
    model_name="GaborMadarasz/gemma-4-E2B-it-CV24_hun",
    max_seq_length=1024,
    load_in_4bit=True,
)

def transcribe(audio_array):
    messages = [
        {
            "role": "system",
            "content": [{"type": "text", "text": "You are an assistant that transcribes speech accurately."}],
        },
        {
            "role": "user",
            "content": [
                {"type": "audio", "audio": audio_array},
                {"type": "text", "text": "Please transcribe this audio."}
            ]
        }
    ]
    model.generate(
        **processor.apply_chat_template(
            messages,
            add_generation_prompt=True,
            tokenize=True,
            return_dict=True,
            return_tensors="pt",
        ).to("cuda"),
        max_new_tokens=256,
        do_sample=False,
        streamer=TextStreamer(processor, skip_prompt=True),
    )
Note: Audio input must be resampled to 16,000 Hz before passing to the processor.

Limitations

  • —Optimized specifically for Hungarian speech; performance on other languages is not guaranteed.
  • —Trained on 1 epoch of Common Voice HU data; rare vocabulary, dialects, and heavy accents may degrade accuracy.
  • —The model was fine-tuned with load_in_4bit=True; the merged float16 weights are provided for full-precision inference.

Framework

  • —Unsloth — efficient LoRA fine-tuning
  • —TRL SFTTrainer + UnslothVisionDataCollator
  • —transformers==5.5.0