This Gemma3 / TranslateGemma model was trained with
Unsloth and Hugging Face's TRL library.
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.
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.
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.
1import torch
2from unsloth import FastLanguageModel
3
4model_id = "gateremark/kikuyu_translategemma_4b_v7_highrank_rslora"
5
6model, processor = FastLanguageModel.from_pretrained(
7 model_name=model_id,
8 max_seq_length=4096,
9 dtype=None,
10 load_in_4bit=False, # Set True if you need lower VRAM and accept possible quality changes.
11)
12
13text_tokenizer = (
14 getattr(processor, "tokenizer", None)
15 or getattr(processor, "text_tokenizer", None)
16 or processor
17)
18
19if text_tokenizer.pad_token_id is None:
20 text_tokenizer.pad_token = text_tokenizer.eos_token
21
22model.config.pad_token_id = text_tokenizer.pad_token_id
23text_tokenizer.padding_side = "left"
24FastLanguageModel.for_inference(model)
25
26terminators = []
27for token_id in [
28 text_tokenizer.eos_token_id,
29 text_tokenizer.convert_tokens_to_ids("<end_of_turn>"),
30 text_tokenizer.convert_tokens_to_ids("<eos>"),
31]:
32 if (
33 isinstance(token_id, int)
34 and token_id >= 0
35 and token_id != getattr(text_tokenizer, "unk_token_id", None)
36 and token_id not in terminators
37 ):
38 terminators.append(token_id)
39
40
41def translate_to_kikuyu(text: str) -> str:
42 messages = [
43 {
44 "role": "user",
45 "content": [
46 {
47 "type": "text",
48 "source_lang_code": "en",
49 "target_lang_code": "ki",
50 "text": text,
51 }
52 ],
53 }
54 ]
55
56 formatted_text = processor.apply_chat_template(
57 messages,
58 tokenize=False,
59 add_generation_prompt=True,
60 )
61
62 inputs = text_tokenizer(
63 [formatted_text],
64 return_tensors="pt",
65 padding=True,
66 )
67 inputs = {key: value.to(model.device) for key, value in inputs.items()}
68
69 with torch.no_grad():
70 outputs = model.generate(
71 **inputs,
72 max_new_tokens=128,
73 do_sample=False,
74 eos_token_id=terminators,
75 pad_token_id=text_tokenizer.pad_token_id,
76 )
77
78 input_len = inputs["input_ids"].shape[1]
79 response = text_tokenizer.decode(
80 outputs[0][input_len:],
81 skip_special_tokens=True,
82 )
83 return response.strip()
84
85
86print(translate_to_kikuyu("Hello, how are you?"))
87# Example output: Ndũmĩrĩrie, ũraigua atĩa?
1[
2 "q_proj",
3 "k_proj",
4 "v_proj",
5 "o_proj",
6 "gate_proj",
7 "up_proj",
8 "down_proj",
9]
Evaluation was run on the held-out 5% split from the same dataset using BLEU and chrF++.
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.
1@misc{gatere2026kikuyutranslategemma4bv7,
2 author = {Mark Gatere},
3 title = {Kikuyu TranslateGemma-4B V7: rsLoRA Fine-tuning for English to Kikuyu Translation},
4 year = {2026},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/gateremark/kikuyu_translategemma_4b_v7_highrank_rslora}}
7}