alakxender/mt5-base-dv-en

🤗 Hugging Face 来源mit582M 参数2.3 GBsafetensors✓ 2 个校验和今天更新
一条命令提交

在你的模型文件夹旁边运行它。它会制作种子、将文件与 Hugging Face 比对,然后提交。你只需开始做种,并粘贴你账户中的密钥。它只读取你的文件,绝不修改。如果愿意,可以先阅读脚本。

curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo alakxender/mt5-base-dv-en ./model-folder
需要做种者 →

English-Dhivehi MT5 Translation Model

This is a bilingual machine translation model fine-tuned from the google/mt5-base architecture to support translation between English and Dhivehi in both directions. The model is instruction-prefixed using "2dv" for English→Dhivehi and "2en" for Dhivehi→English.

Performance

BLEU Scores

  • English → Dhivehi: 24.32
  • Dhivehi → English: 50.79

These scores reflect the relative ease of generating fluent English from Dhivehi input compared to the more complex morphological and syntactic challenges when generating Dhivehi from English.

Example Translations

English → Dhivehi

Input: Hello, how are you?
Output: ހެލޯ، ކިހިނެއްވީ؟

Input: I love reading books.
Output: އަހަރެން ފޮތް ކިޔަން ވަރަށް ލޯބިވޭ.

Dhivehi → English

Input: ކިހިނެއްތަ އުޅެނީ؟
Output: how's it going?

Input: ރާއްޖެއަކީ ރީތި ޤައުމެކެވެ.
Output: sri lanka is a beautiful country. (Note: dataset quality may affect accuracy)

Usage

from transformers import MT5ForConditionalGeneration, MT5Tokenizer

# Load model and tokenizer
model = MT5ForConditionalGeneration.from_pretrained("./mt5-base-dv-en/best_model")
tokenizer = MT5Tokenizer.from_pretrained("./mt5-base-dv-en/best_model")

# English to Dhivehi
def translate_to_dhivehi(text):
    inputs = tokenizer("2dv" + text, return_tensors="pt", max_length=512, truncation=True)
    outputs = model.generate(
        **inputs,
        max_length=100,
        num_beams=5,
        length_penalty=2.5,
        repetition_penalty=1.5,
        early_stopping=True,
        no_repeat_ngram_size=2
    )
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

# Dhivehi to English
def translate_to_english(text):
    inputs = tokenizer("2en" + text, return_tensors="pt", max_length=512, truncation=True)
    outputs = model.generate(
        **inputs,
        max_length=100,
        num_beams=5,
        length_penalty=2.5,
        repetition_penalty=1.5,
        early_stopping=True,
        no_repeat_ngram_size=2
    )
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

# Example usage
print(translate_to_dhivehi("Hello, how are you?"))
print(translate_to_english("ކިހިނެއްތަ އުޅެނީ؟"))

Model Architecture

  • Base Model: google/mt5-base
  • Instruction Prefixes:
    • "2dv" for English → Dhivehi
    • "2en" for Dhivehi → English

Disclaimer

This model is an experimental and educational fine-tuning intended to explore low-resource translation capabilities for the Dhivehi language. It is not production-ready and should not be used in high-stakes applications without further evaluation and refinement.