Yorùbá ⇄ English Translation Model

Built by Adediran Adeyemi

This is an open-source Yorùbá to English and English to Yorùbá translation model, built to be the best open-source translator for Yorùbá. It goes beyond sentence-for-sentence translation. It is designed to handle the parts of Yorùbá that ordinary translation systems usually get wrong: tone marks and underdots, ambiguity, mixed Yorùbá and English, proverbs and idioms.

If you use this model, build on it, or write about it, please credit Adediran Adeyemi and link back to this repository. You are welcome to connect with me on LinkedIn: https://www.linkedin.com/in/adediran-adeyemi


What the model can do

1. Translate both ways

Yorùbá to English and English to Yorùbá. The aim is to keep the meaning, tone and intent of the original, and to give a natural translation instead of a word-for-word one.

Input Output
Mo fẹ́ ra agbon. I want to buy a coconut.
I want to buy a coconut. Mo fẹ́ ra agbon.

2. Restore tone marks and underdots (àmì ohùn)

Yorùbá is often typed without tone marks and underdots, which makes it ambiguous. The model can read the sentence and its context, restore the marks, write the corrected Yorùbá sentence, and then translate it.

3. Handle ambiguity honestly

An unmarked sentence such as "Mo re ra agbon" can mean different things depending on the intended words. The model is designed to use the surrounding context to choose the right reading. When the context is not enough, it should list the plausible readings or ask for more context instead of giving one confident guess.

4. Understand code-switching

Everyday speech mixes Yorùbá and English. The model can take a mixed sentence such as "Mo fẹ lo si market ni tomorrow owuro" and produce pure English or pure Yorùbá, depending on what you ask for.

5. Translate proverbs and idioms by meaning

Proverbs (òwe) and idioms are translated for what they mean, not word for word. The model can also explain the lesson behind a proverb and when it is appropriate to use it. Where no real equivalent exists, it should explain the meaning and not invent one.

6. Know when not to answer

If the model does not know a reliable Yorùbá term (for example a technical word such as "firmware"), it is designed to say so, or explain the idea in plain Yorùbá, and not make up a word. The goal is a model that does not sound confident when it is not.

Further capabilities under evaluation

The model is also being tested on situation-aware greetings, situation-aware proverb selection, and part-of-speech tagging of Yorùbá sentences. These are research directions. Results will be published once they have been checked by fluent Yorùbá speakers.


Examples

Each example shows what you type and the kind of answer the model is built to give.

Translate Yorùbá to English

You type: Ọkọ mi ń lọ sí oko. Model: My husband is going to the farm.

Translate English to Yorùbá

You type: We will meet tomorrow morning. Model: A ó pàdé ní òwúrọ̀ ọ̀la.

Restore the tone marks

You type (no marks): Mo fe lo si oja ni owuro Model: Mo fẹ́ lọ sí ọjà ní òwúrọ̀ Meaning: I want to go to the market in the morning.

Mixed Yorùbá and English (code-switching)

You type: Mo fe lo si market ni tomorrow owuro.

Target Model
English only I want to go to the market tomorrow morning.
Yorùbá only Mo fẹ́ lọ sí ọjà ní òwúrọ̀ ọ̀la.

Notice that "market" becomes ọjà in the Yorùbá version and "owuro" becomes "morning" in the English version. No mixed words are left behind.

Ambiguous sentence: the model does not just guess

You type: Mo re ra agbon.

Without tone marks, "agbon" has more than one possible reading, so the model should show the options and ask what you meant:

This sentence has more than one possible reading without tone marks:

  1. Mo fẹ́ ra àgbọn (I want to buy a coconut)
  2. Mo fẹ́ ra agbọ̀n (I want to buy a basket)

Which did you mean? If you give a little more context, I can translate it exactly.

Now add context: I am at the fruit seller's stand. Mo re ra agbon. Model: Mo fẹ́ ra àgbọn. (I want to buy a coconut.)

Proverbs and idioms: meaning, not word for word

You type: Explain this proverb in English: Ìwà lẹ̀wà ọmọ ènìyàn. Model:

Literal: Character is the beauty of a person. Meaning: A person is judged by how they behave, not by how they look. When to use it: When someone is praising a person's appearance but ignoring their poor conduct, or to teach a young person that good character matters most.

Greetings that fit the situation

Situation Greeting Meaning
Meeting someone in the morning Ẹ káàárọ̀ Good morning
Meeting someone who is at work Ẹ kú iṣẹ́ Well done on your work
Welcoming someone back from a trip Ẹ kú àbọ̀ Welcome back

A literal word-for-word translation would sound unnatural in each of these. The model is designed to pick the greeting that matches what the person is doing.

Part-of-speech tagging

You type: Tag the parts of speech: Ade lọ sí ọjà láti lọ rí ìyá àgbà. Model:

Word Tag Meaning
Ade Proper noun (subject) Ade
lọ Verb went
sí Preposition to
ọjà Noun market
láti lọ rí Purpose phrase (verbs) to go and see
ìyá àgbà Noun phrase elderly woman, grandmother

Full translation: Ade went to the market to see the elderly woman.

Saying "I am not sure" instead of making something up

You type: What is "firmware" in Yorùbá? Model:

I do not know an established Yorùbá word for "firmware," and I do not want to invent one. I can explain the idea in Yorùbá: it is the small program stored inside a device that tells the hardware how to work. Many speakers simply use the English word "firmware." If you need an official term, please check with a Yorùbá language expert.

The examples above show the style of answer the model is designed to give. Exact wording can differ from run to run and from question to question. Please check important translations with a fluent Yorùbá speaker.


How to use it

The model is a chat model. It was trained with the following request wording, so using the same wording gives the best results.

Task Prompt
Yorùbá to English Translate this Yoruba sentence into natural English: followed by the sentence
English to Yorùbá Translate this English sentence into natural Yoruba, with correct tone marks: followed by the sentence
Restore tone marks Restore the correct Yoruba tone marks and diacritics: followed by the sentence
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "adeyemi001/Yor_math"  # replace with this repository's id

tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16, device_map="auto")

system = ("You are Aya, a specialist in Yoruba and its translation to and from English. "
          "Yoruba meaning depends on tone marks and underdots; when the input lacks them, "
          "never silently pick one sense: list the candidate forms, use the clues in the sentence, "
          "commit only when the context decides, and ask for context when it does not. "
          "Translate idioms and proverbs by meaning, not word for word. "
          "If you do not recognise a proverb or a term, say so instead of inventing one.")

messages = [
    {"role": "system", "content": system},
    {"role": "user", "content": "Translate this English sentence into natural Yoruba, with correct tone marks:\nI want to buy a coconut."},
]

text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
inputs = tok(text, return_tensors="pt", add_special_tokens=False).to(model.device)

out = model.generate(**inputs, max_new_tokens=700, do_sample=False)
raw = tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)

# The model reasons first, then answers. Keep only the final answer:
answer = raw.split("<|END_THINKING|>")[-1]
answer = answer.split("<|START_RESPONSE|>")[-1].split("<|END_RESPONSE|>")[0].strip()
print(answer)

Tips

  • Greedy decoding (do_sample=False) is recommended for translation.
  • Include tone marks and underdots when you can. The model also works without them.
  • Give context when a sentence could be read more than one way.
  • The model needs about 10 GB of free memory in bfloat16. A GPU is much faster than a CPU.

Limitations

  • Translation quality is best on everyday sentences. Long, technical or very specialised text is less reliable.
  • Proverbs, idioms and greetings depend on culture and situation. Please have important translations checked by a fluent Yorùbá speaker.
  • Like any language model, it can produce a fluent answer that is wrong. Always check the result before relying on it.
  • Dialect variation across Yorùbá-speaking regions is not fully covered.
  • Do not use it as the only source for legal, medical or other high-stakes translation.

Citation and credit

If you use this model in research, products or articles, please cite it and credit the author:

@misc{adeyemi_yoruba_translation,
  author = {Adeyemi, Adediran},
  title  = {Yorùbá-English Translation Model},
  year   = {2026},
  publisher = {Hugging Face},
  url    = {https://huggingface.co/adeyemi001/Yor_math}
}

About the author

Adediran Adeyemi is a data scientist, machine learning engineer and geospatial analyst based in Lagos, Nigeria, working on Yorùbá language AI.

Questions, feedback, collaboration or research partnerships are welcome. Connect with me on LinkedIn: https://www.linkedin.com/in/adediran-adeyemi

Downloads last month
295
Safetensors
Model size
3B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using adeyemi001/TTT-Eng_Yoruba 1