AfriScience-MT
Collection
AfriScience-MT (arXiv:2605.29741): MT models for African scientific text in Amharic, Hausa, Luganda, N. Sotho, Yoruba and isiZulu. • 254 items • Updated
How to use dsfsi/gemma_3_4b_it-lora-r8-yor-eng with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-3-4b-it")
model = PeftModel.from_pretrained(base_model, "dsfsi/gemma_3_4b_it-lora-r8-yor-eng")This is a LoRA adapter for the AfriScience-MT project, enabling efficient scientific machine translation for African languages.
| Property | Value |
|---|---|
| Base Model | google/gemma-3-4b-it |
| Translation Direction | Yoruba → English |
| LoRA Rank (r) | 8 |
| LoRA Alpha | 16 |
| Training Method | QLoRA (4-bit quantization) |
| Domain | Scientific/Academic texts |
LoRA (Low-Rank Adaptation) enables efficient fine-tuning by training only a small number of additional parameters. This adapter adds only ~4.0M parameters to the base model while achieving strong translation performance.
Performance on the AfriScience-MT test set:
| Split | BLEU | chrF | SSA-COMET |
|---|---|---|---|
| Validation | 25.46 | 45.86 | 62.35 |
| Test | 23.60 | 44.42 | 61.07 |
Metrics explanation:
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 = "dsfsi/gemma_3_4b_it-lora-r8-yor-eng"
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 Yoruba scientific text to English."
# 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)
# 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, "dsfsi/gemma_3_4b_it-lora-r8-yor-eng")
| Parameter | Value |
|---|---|
| LoRA Rank (r) | 8 |
| LoRA Alpha | 16 |
| LoRA Dropout | 0.05 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Epochs | 3 |
| Batch Size | 2 |
| Learning Rate | 2e-04 |
| Max Sequence Length | 512 |
| Gradient Accumulation | 4 |
| Configuration | VRAM Required |
|---|---|
| 4-bit (QLoRA) | ~8-12 GB |
| 8-bit | ~16-20 GB |
| Full precision | ~24-40 GB |
To reproduce this adapter:
# Clone the AfriScience-MT repository
git clone https://github.com/afriscience-mt/afriscience-mt.git
cd afriscience-mt
# Install dependencies
pip install -r requirements.txt
# Run LoRA training
python -m afriscience_mt.scripts.run_lora_training \
--data_dir ./data \
--source_lang yor \
--target_lang eng \
--model_name google/gemma-3-4b-it \
--model_type gemma \
--lora_rank 8 \
--output_dir ./output \
--num_epochs 3 \
--batch_size 4 \
--load_in_4bit
If you use this model, please cite the AfriScience-MT paper (arXiv:2605.29741):
@article{abdulmumin2026afriscience,
title = {AfriScience-MT: Towards Decolonizing Science in Africa through Text Translation},
author = {Abdulmumin, Idris and Gwadabe, Tajuddeen and Muhammad, Shamsuddeen Hassan and Adelani, David Ifeoluwa and Khalo, Nomonde and Ahmad, Ibrahim Said and Modupe, Abiodun and Mumm, Anina and Biyela, Sibusiso and Rabie, Michelle and Havemann, Johanna and Rei, Marek and Abbott, Jade and Marivate, Vukosi},
journal = {arXiv preprint arXiv:2605.29741},
year = {2026},
url = {https://arxiv.org/abs/2605.29741}
}
This adapter is released under the Apache 2.0 License.