AfriScience-MT / llama_3.1_8b_instruct-lora-r64-amh-eng

huggingface.co
Total runs: 3
24-hour runs: 0
7-day runs: 0
30-day runs: -16
Model's Last Updated: April 10 2026
translation

Introduction of llama_3.1_8b_instruct-lora-r64-amh-eng

Model Details of llama_3.1_8b_instruct-lora-r64-amh-eng

llama_3.1_8b_instruct-lora-r64-amh-eng

Model on HF

This is a LoRA adapter for the AfriScience-MT project, enabling efficient scientific machine translation for African languages.

Adapter Description
Property Value
Base Model meta-llama/Llama-3.1-8B-Instruct
Translation Direction Amharic → English
LoRA Rank (r) 64
LoRA Alpha 128
Training Method QLoRA (4-bit quantization)
Domain Scientific/Academic texts
Why LoRA?

LoRA (Low-Rank Adaptation) enables efficient fine-tuning by training only a small number of additional parameters. This adapter adds only ~32.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
Test - - -

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(
    "meta-llama/Llama-3.1-8B-Instruct",
    quantization_config=bnb_config,
    device_map="auto",
    torch_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")

# Load LoRA adapter
adapter_name = "AfriScience-MT/llama_3.1_8b_instruct-lora-r64-amh-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 Amharic scientific text to English."

# Format prompt
prompt = f"""### Instruction:
{instruction}

### Input:
{source_text}

### Response:
"""

# 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(
    "meta-llama/Llama-3.1-8B-Instruct",
    device_map="auto",
    torch_dtype=torch.bfloat16,
)
model = PeftModel.from_pretrained(base_model, "AfriScience-MT/llama_3.1_8b_instruct-lora-r64-amh-eng")
Training Details
Hyperparameters
Parameter Value
LoRA Rank (r) 64
LoRA Alpha 128
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
Hardware Requirements
Configuration VRAM Required
4-bit (QLoRA) ~8-12 GB
8-bit ~16-20 GB
Full precision ~24-40 GB
Reproducibility

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 amh \
    --target_lang eng \
    --model_name meta-llama/Llama-3.1-8B-Instruct \
    --model_type llama \
    --lora_rank 64 \
    --output_dir ./output \
    --num_epochs 3 \
    --batch_size 4 \
    --load_in_4bit
Limitations
  • Domain Specificity : Optimized for scientific/academic texts; may underperform on casual or colloquial language.
  • Language Direction : Only supports Amharic → English translation.
  • Base Model Required : Must be used with the meta-llama/Llama-3.1-8B-Instruct base model.
  • Context Length : Maximum context is model-dependent; longer texts should be chunked.
Citation

If you use this adapter, please cite the AfriScience-MT project:

@inproceedings{afriscience-mt-2025,
  title={AfriScience-MT: Machine Translation for African Scientific Literature},
  author={AfriScience-MT Team},
  year={2025},
  url={https://github.com/afriscience-mt/afriscience-mt}
}
License

This adapter is released under the Apache 2.0 License .

Acknowledgments

Runs of AfriScience-MT llama_3.1_8b_instruct-lora-r64-amh-eng on huggingface.co

3
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
-16
30-day runs

More Information About llama_3.1_8b_instruct-lora-r64-amh-eng huggingface.co Model

More llama_3.1_8b_instruct-lora-r64-amh-eng license Visit here:

https://choosealicense.com/licenses/apache-2.0

llama_3.1_8b_instruct-lora-r64-amh-eng huggingface.co

llama_3.1_8b_instruct-lora-r64-amh-eng huggingface.co is an AI model on huggingface.co that provides llama_3.1_8b_instruct-lora-r64-amh-eng's model effect (), which can be used instantly with this AfriScience-MT llama_3.1_8b_instruct-lora-r64-amh-eng model. huggingface.co supports a free trial of the llama_3.1_8b_instruct-lora-r64-amh-eng model, and also provides paid use of the llama_3.1_8b_instruct-lora-r64-amh-eng. Support call llama_3.1_8b_instruct-lora-r64-amh-eng model through api, including Node.js, Python, http.

llama_3.1_8b_instruct-lora-r64-amh-eng huggingface.co Url

https://huggingface.co/AfriScience-MT/llama_3.1_8b_instruct-lora-r64-amh-eng

AfriScience-MT llama_3.1_8b_instruct-lora-r64-amh-eng online free

llama_3.1_8b_instruct-lora-r64-amh-eng huggingface.co is an online trial and call api platform, which integrates llama_3.1_8b_instruct-lora-r64-amh-eng's modeling effects, including api services, and provides a free online trial of llama_3.1_8b_instruct-lora-r64-amh-eng, you can try llama_3.1_8b_instruct-lora-r64-amh-eng online for free by clicking the link below.

AfriScience-MT llama_3.1_8b_instruct-lora-r64-amh-eng online free url in huggingface.co:

https://huggingface.co/AfriScience-MT/llama_3.1_8b_instruct-lora-r64-amh-eng

llama_3.1_8b_instruct-lora-r64-amh-eng install

llama_3.1_8b_instruct-lora-r64-amh-eng is an open source model from GitHub that offers a free installation service, and any user can find llama_3.1_8b_instruct-lora-r64-amh-eng on GitHub to install. At the same time, huggingface.co provides the effect of llama_3.1_8b_instruct-lora-r64-amh-eng install, users can directly use llama_3.1_8b_instruct-lora-r64-amh-eng installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

llama_3.1_8b_instruct-lora-r64-amh-eng install url in huggingface.co:

https://huggingface.co/AfriScience-MT/llama_3.1_8b_instruct-lora-r64-amh-eng

Url of llama_3.1_8b_instruct-lora-r64-amh-eng

llama_3.1_8b_instruct-lora-r64-amh-eng huggingface.co Url

Provider of llama_3.1_8b_instruct-lora-r64-amh-eng huggingface.co

AfriScience-MT
ORGANIZATIONS

Other API from AfriScience-MT