CoolFace
Modelpublic

c-elo/kikuyu_translategemma_4b_v7_highrank_rslora

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
1likes44downloads
Model Card

Uploaded finetuned model

  • —Developed by: gateremark
  • —License: apache-2.0
  • —Finetuned from model: google/translategemma-4b-it

This Gemma3 / TranslateGemma model was trained with Unsloth and Hugging Face's TRL library.

<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>

C-elo Labs Organization Release

This repository is the C-elo Labs organization release of the Kikuyu TranslateGemma-4B V7 model, originally developed by Mark Gatere under `gateremark/kikuyu_translategemma_4b_v7_highrank_rslora`.

This is the current preferred C-elo Labs English → Kikuyu translation model for production-facing use. The original gateremark repository remains available as the development-history copy, while this c-elo repository is maintained for C-elo Labs research, product, and public release references.

Kikuyu TranslateGemma-4B V7

Fine-tuned English -> Kikuyu translation model based on Google's TranslateGemma-4B-it.

This is the current fast production model behind C-elo Translate. It was trained as a smaller, faster alternative to the earlier 12B model while improving automatic evaluation scores and manual translation quality.

Live demo: c-elo.com/c-elo-ai

Previous 12B model: gateremark/kikuyu_translategemma_12b_merged_V2

Model Details

AttributeValue
Base modelgoogle/translategemma-4b-it
Model familyTranslateGemma / Gemma3
Hub size~5B parameters, BF16 safetensors
Fine-tuning methodrsLoRA, high-rank LoRA
LoRA rank / alphar=256, alpha=256
Training data30,430 English-Kikuyu pairs
DirectionEnglish -> Kikuyu
BLEU21.93
chrF++42.87
Eval loss0.7518
FrameworkUnsloth + TRL + Transformers
Training platformModal, NVIDIA H100

Why This Model

The earlier 12B Kikuyu TranslateGemma model reached 19.61 BLEU, but it was large and slower to cold-start in production. This V7 4B-family model is smaller, faster to load, and evaluated better on the same held-out split:

ModelBLEUchrF++Notes
12B LoRA V219.61-Earlier production model
4B V2 LoRA r25617.7638.31Strong first 4B run
4B V3 DoRA r12815.8135.88DoRA did not improve this setup
4B V6 LoRA r256, 4 epochs17.6738.28Longer training did not improve V2
4B V7 rsLoRA r25621.9342.87Current champion

Usage

Recommended: Unsloth / Gemma3Processor Path

This model uses the TranslateGemma/Gemma3 chat template. For reliable generation, use the processor for apply_chat_template() and the underlying text tokenizer for tokenization/decoding.

python
import torch
from unsloth import FastLanguageModel

model_id = "gateremark/kikuyu_translategemma_4b_v7_highrank_rslora"

model, processor = FastLanguageModel.from_pretrained(
    model_name=model_id,
    max_seq_length=4096,
    dtype=None,
    load_in_4bit=False,  # Set True if you need lower VRAM and accept possible quality changes.
)

text_tokenizer = (
    getattr(processor, "tokenizer", None)
    or getattr(processor, "text_tokenizer", None)
    or processor
)

if text_tokenizer.pad_token_id is None:
    text_tokenizer.pad_token = text_tokenizer.eos_token

model.config.pad_token_id = text_tokenizer.pad_token_id
text_tokenizer.padding_side = "left"
FastLanguageModel.for_inference(model)

terminators = []
for token_id in [
    text_tokenizer.eos_token_id,
    text_tokenizer.convert_tokens_to_ids("<end_of_turn>"),
    text_tokenizer.convert_tokens_to_ids("<eos>"),
]:
    if (
        isinstance(token_id, int)
        and token_id >= 0
        and token_id != getattr(text_tokenizer, "unk_token_id", None)
        and token_id not in terminators
    ):
        terminators.append(token_id)


def translate_to_kikuyu(text: str) -> str:
    messages = [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "source_lang_code": "en",
                    "target_lang_code": "ki",
                    "text": text,
                }
            ],
        }
    ]

    formatted_text = processor.apply_chat_template(
        messages,
        tokenize=False,
        add_generation_prompt=True,
    )

    inputs = text_tokenizer(
        [formatted_text],
        return_tensors="pt",
        padding=True,
    )
    inputs = {key: value.to(model.device) for key, value in inputs.items()}

    with torch.no_grad():
        outputs = model.generate(
            **inputs,
            max_new_tokens=128,
            do_sample=False,
            eos_token_id=terminators,
            pad_token_id=text_tokenizer.pad_token_id,
        )

    input_len = inputs["input_ids"].shape[1]
    response = text_tokenizer.decode(
        outputs[0][input_len:],
        skip_special_tokens=True,
    )
    return response.strip()


print(translate_to_kikuyu("Hello, how are you?"))
# Example output: Ndũmĩrĩrie, ũraigua atĩa?

Minimal Inference Notes

  • —Use target_lang_code="ki" for Kikuyu.
  • —Use left padding for batched generation with decoder-only models.
  • —Deterministic decoding (do_sample=False) is recommended for translation.
  • —The model is trained for English -> Kikuyu. Reverse Kikuyu -> English was not part of this run.

Training Details

Dataset

V7 Hyperparameters

ParameterValue
MethodrsLoRA
LoRA rank256
LoRA alpha256
LoRA dropout0
DoRAFalse
Epochs3
Learning rate1e-4
Batch size32 effective batch
OptimizerAdamW 8-bit
Weight decay0.01
PrecisionBF16
Max sequence length4096

Target Modules

python
[
    "q_proj",
    "k_proj",
    "v_proj",
    "o_proj",
    "gate_proj",
    "up_proj",
    "down_proj",
]

Evaluation

Evaluation was run on the held-out 5% split from the same dataset using BLEU and chrF++.

MetricScore
BLEU21.93
chrF++42.87
Eval loss0.7518

Automatic metrics are useful for regression testing, but Kikuyu quality should also be checked with native-speaker review because morphology, idiom, tone, and dialect variation are not fully captured by BLEU.

Sample Translations

EnglishKikuyu
Hello, how are you?Hihi, ũrĩ atĩa?
The weather is beautiful today.Rĩera nĩ rĩega mũno ũmũthĩ
I love learning new languages.Nĩ nyendete kwĩruta thiomi njerũ

Intended Use

  • —English -> Kikuyu translation tools
  • —Kikuyu language learning applications
  • —Low-resource African language NLP research
  • —Cultural and linguistic preservation projects
  • —Prototyping multilingual AI interfaces for Kikuyu speakers

Limitations

  • —Direction: English -> Kikuyu only. Kikuyu -> English was not trained in this run.
  • —Language coverage: Optimized for Kikuyu (ki), not other Gikuyu-related dialects or neighboring Bantu languages.
  • —Domain: Best for general text. Technical, legal, medical, poetic, or highly idiomatic content may need human review.
  • —Evaluation: BLEU and chrF++ do not fully measure naturalness, dialect fit, or cultural nuance.
  • —Production use: Review outputs before high-stakes use.

Citation

bibtex
@misc{gatere2026kikuyutranslategemma4bv7,
  author = {Mark Gatere},
  title = {Kikuyu TranslateGemma-4B V7: rsLoRA Fine-tuning for English to Kikuyu Translation},
  year = {2026},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/gateremark/kikuyu_translategemma_4b_v7_highrank_rslora}}
}

Acknowledgments

  • —Google for TranslateGemma-4B-it
  • —Unsloth for efficient fine-tuning
  • —Hugging Face for model and dataset hosting
  • —Modal for GPU training and deployment infrastructure
  • —Kikuyu speakers and reviewers supporting C-elo's translation work