LoRA (Low-Rank Adaptation) enables efficient fine-tuning by training only a small number of additional parameters. This adapter adds only
~64.0M parameters
to the base model while achieving strong translation performance.
Evaluation Results
Performance on the AfriScience-MT test set:
Split
BLEU
chrF
SSA-COMET
Validation
16.04
40.42
66.03
Test
15.52
41.17
65.23
Metrics explanation:
BLEU
: Measures n-gram overlap with reference translations (0-100, higher is better)
chrF
: Character-level F-score, robust for morphologically rich languages (0-100, higher is better)
SSA-COMET
: Neural metric trained for Sub-Saharan African languages, shown as percentage (0-100, higher is better) (
McGill-NLP/ssa-comet-stl
)
Usage
Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
# Configure 4-bit quantization (recommended for memory efficiency)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
)
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"google/gemma-3-4b-it",
quantization_config=bnb_config,
device_map="auto",
torch_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-4b-it")
# Load LoRA adapter
adapter_name = "AfriScience-MT/gemma_3_4b_it-lora-r128-eng-yor"
model = PeftModel.from_pretrained(base_model, adapter_name)
model.eval()
# Prepare translation prompt
source_text = "Climate change significantly impacts agricultural productivity in sub-Saharan Africa."
instruction = "Translate the following English scientific text to Yoruba."# Format for Gemma chat template
messages = [{"role": "user", "content": f"{instruction}\n\n{source_text}"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
# Generate translation
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
num_beams=5,
early_stopping=True,
pad_token_id=tokenizer.pad_token_id,
)
# Decode only the generated part
generated = outputs[0][inputs["input_ids"].shape[1]:]
translation = tokenizer.decode(generated, skip_special_tokens=True)
print(translation)
Without Quantization (Full Precision)
# For GPUs with sufficient memory (>24GB for larger models)
base_model = AutoModelForCausalLM.from_pretrained(
"google/gemma-3-4b-it",
device_map="auto",
torch_dtype=torch.bfloat16,
)
model = PeftModel.from_pretrained(base_model, "AfriScience-MT/gemma_3_4b_it-lora-r128-eng-yor")
gemma_3_4b_it-lora-r128-eng-yor huggingface.co is an AI model on huggingface.co that provides gemma_3_4b_it-lora-r128-eng-yor's model effect (), which can be used instantly with this AfriScience-MT gemma_3_4b_it-lora-r128-eng-yor model. huggingface.co supports a free trial of the gemma_3_4b_it-lora-r128-eng-yor model, and also provides paid use of the gemma_3_4b_it-lora-r128-eng-yor. Support call gemma_3_4b_it-lora-r128-eng-yor model through api, including Node.js, Python, http.
gemma_3_4b_it-lora-r128-eng-yor huggingface.co is an online trial and call api platform, which integrates gemma_3_4b_it-lora-r128-eng-yor's modeling effects, including api services, and provides a free online trial of gemma_3_4b_it-lora-r128-eng-yor, you can try gemma_3_4b_it-lora-r128-eng-yor online for free by clicking the link below.
AfriScience-MT gemma_3_4b_it-lora-r128-eng-yor online free url in huggingface.co:
gemma_3_4b_it-lora-r128-eng-yor is an open source model from GitHub that offers a free installation service, and any user can find gemma_3_4b_it-lora-r128-eng-yor on GitHub to install. At the same time, huggingface.co provides the effect of gemma_3_4b_it-lora-r128-eng-yor install, users can directly use gemma_3_4b_it-lora-r128-eng-yor installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
gemma_3_4b_it-lora-r128-eng-yor install url in huggingface.co: