JuliusFx/dyu-fr-ctranslate2
This is a machine translation model that translates Dyula to French using the ctranslate2 framework.
The modelbased on this google colab notebook that was kindly created by Kartheek Akella.
Model description
More information needed
Intended uses & limitations
More information needed
Training and evaluation train_df
More information needed
Usage
Load and use for inference
import ctranslate2
import sentencepiece as spm
# Download model
snapshot_download(
repo_id="JuliusFx/dyula-french-ctranslate2_v2_25epochs",
local_dir="/path/to/save/locally"
)
# Define model interface
class CTranslate2Model:
def __init__(self, model_dir: str, sp_model_path: str) -> None:
self.translator = ctranslate2.Translator(model_dir)
self.sp = spm.SentencePieceProcessor()
self.sp.Load(sp_model_path)
def translate(self, sentence: str) -> str:
'''
Translate the given sentence.
:param sentence: Sentence to be translated
:return: Translated sentence.
'''
prepared_train_df = clean_text(sentence)
tokens = self.sp.Encode(prepared_train_df, out_type=str)
translation = self.translator.translate_batch([tokens], beam_size=5)
translated_sentence = self.sp.Decode(translation[0].hypotheses[0])
return translated_sentence
# Initialize the model once
model_dir = "/path/to/your/model_dir"
sp_model_path = "/path/to/your/sp_model_path"
translator = CTranslate2Model(model_dir=model_dir, sp_model_path=sp_model_path)
def translate_sentence(sentence: str) -> str:
return translator.translate(sentence)
# Example usage
dyula_sentence = "i tɔgɔ bi cogodɔ"
translated_sentence = translate_sentence(dyula_sentence)
print("Dyula sentence:", dyula_sentence)
print("Translated French sentence:", translated_sentence)
Training procedure
Training hyperparameters
More information needed
Training results
More information needed
Framework versions
- Downloads last month
- 10