Model reference · open weights
AfriE5-Large is an open-weight embedding model from McGill-NLP. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | McGill-NLP |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Parameters (lead) | 560M |
| Context | 514 tokens |
| Runs with | sentence-transformers |
| Based on | intfloat/multilingual-e5-large-instruct |
| Released | 2025-09-02 |
| Popularity | 2k downloads / month |
| Licence | Open weights |
About
AfriE5-Large-instruct is a text embedding model adapted from multilingual-e5-large-instruct to better support African languages. It was developed by leveraging cross-lingual contrastive learning with knowledge distillation, specifically targeting 9 African languages while generalizing well to 59 languages covered in the AfriMTEB benchmark.
from sentence_transformers import SentenceTransformer
# Load the model
model = SentenceTransformer('McGill-NLP/AfriE5-Large-instruct')
# Define queries and documents
# IMPORTANT: Queries require a specific instruction prefix.
# Documents do not strictly need a prefix, but usage should mirror mE5 conventions.
query_instruction = "Instruct: Retrieve sentences that are semantically consistent with the input.\nQuery: "
queries = [
"What are the key features of AfriMTEB?",
"Hali ya hewa ikoje leo?" # Swahili: How is the weather today?
]
documents = [
"AfriMTEB is a benchmark for evaluating text embeddings in African languages.",
"Leo kuna jua kali sana." # Swahili: Today it is very sunny.
]
# Add prefix to queries
formatted_queries = [query_instruction + q for q in queries]
# Encode
query_embeddings = model.encode(formatted_queries, normalize_embeddings=True)
doc_embeddings = model.encode(documents, normalize_embeddings=True)
# Compute similarity
scores = (query_embeddings @ doc_embeddings.T) * 100
print(scores)
import torch
import torch.nn.functional as F
from transformers import AutoTokenizer, AutoModel
def average_pool(last_hidden_states, attention_mask):
last_hidden = last_hidden_states.masked_fill(~attention_mask[..., None].bool(), 0.0)
return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained('McGill-NLP/AfriE5-Large-instruct')
model = AutoModel.from_pretrained('McGill-NLP/AfriE5-Large-instruct')
# Define input texts
query_instruction = "Instruct: Retrieve sentences that are semantically consistent with the input.\nQuery: "
input_texts = [
query_instruction + "What is the capital of Nigeria?",
"Abuja is the capital city of Nigeria.",
"Lagos is the largest city in Nigeria."
]
# Tokenize
batch_dict = tokenizer(input_texts, max_length=512, padding=True, truncation=True, return_tensors='pt')
# Get embeddings
outputs = model(**batch_dict)
embeddings = average_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
# Normalize embeddings
embeddings = F.normalize(embeddings, p=2, dim=1)
# Compute cosine similarity
scores = (embeddings[:1] @ embeddings[1:].T) * 100
print(scores)
AfriE5-Large-instruct was evaluated on AfriMTEB, a comprehensive benchmark for African languages.
Average performance across 12 tasks on 9 target African languages.
| Model | Average Score |
|---|---|
| AfriE5-Large-instruct | 63.7 |
| Gemini Embedding-001 | 63.1 |
| mE5-Large-instruct | 62.0 |
| BGE-M3 | 55.0 |
Macro-average across 38 datasets and 59 languages.
| Model | Average Score |
|---|---|
| AfriE5-Large-instruct | 62.4 |
| mE5-Large-instruct | 61.3 |
| Gemini Embedding-001 | 60.6 |
| BGE-M3 | 55.8 |
Note: AfriE5 outperforms strong baselines despite being trained on only 9 languages, demonstrating effective cross-lingual generalization.
facebook/nllb-200-3.3B.BAAI/bge-reranker-v2-m3.If you use this model or the AfriMTEB benchmark, please cite:
@article{uemura2025afrimteb,
title={AfriMTEB and AfriE5: Benchmarking and Adapting Text Embedding Models for African Languages},
author={Uemura, Kosei and Zhang, Miaoran and Adelani, David Ifeoluwa},
journal={arXiv preprint},
year={2025}
}
This work adapts the FlagEmbedding library. We thank the BAAI team for their open-source contributions.
From the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys afrie5-large for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (afrie5-large below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/embeddings \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"afrie5-large","input":"text to embed"}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.