--- base_model: unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit library_name: peft language: - bm pipeline_tag: automatic-speech-recognition tags: - gemma3n - lora - peft - unsloth - audio - bambara --- # gemma-3n-bm-asr-01 A LoRA adapter for Gemma 3n E4B-it that adapts the speech path for Bambara, trained with [Unsloth](https://github.com/unslothai/unsloth) and TRL. Adapter weights only. Load onto `unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit` — a 4-bit NF4 checkpoint, and the adapter belongs on that same quantised base. ## Config | | | | --- | --- | | Rank `r` | 16 | | `lora_alpha` | 32 | | `use_rslora` | `false` — effective scale `alpha / r` = 2.0 | | `lora_dropout` | 0 | Adapted: the decoder's attention and MLP projections, the 12 audio conformer blocks, and the audio→text embedding projector. ## Usage ```python import torch from transformers import AutoProcessor, Gemma3nForConditionalGeneration from peft import PeftModel base = Gemma3nForConditionalGeneration.from_pretrained( "unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit", dtype=torch.bfloat16, device_map="auto", attn_implementation="sdpa", ) model = PeftModel.from_pretrained(base, "djelia/gemma-3n-bm-asr-01") model.eval() processor = AutoProcessor.from_pretrained("djelia/gemma-3n-bm-asr-01", padding_side="left") messages = [{ "role": "user", "content": [ {"type": "audio", "path": "sample.wav"}, {"type": "text", "text": "Transcribe this audio."}, ], }] inputs = processor.apply_chat_template( messages, tokenize=True, return_dict=True, return_tensors="pt", add_generation_prompt=True, ).to(model.device) out = model.generate(**inputs, max_new_tokens=256, do_sample=False) print(processor.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)) ``` ## Notes The processor resamples the audio itself. Gemma 3n's audio encoder emits about 6 tokens per second, so long recordings consume context quickly. `bitsandbytes` and `accelerate` are required for the 4-bit base.