Downloads · 30 days
18
42% of all-time downloads
JuliusFx/dyula-french-nmt-8
dyula-french-nmt-8 is a translation model from JuliusFx. Use it when you need text moved from one language to another.
language: - dyu - fr - multilingual tags: - translation - ctranslate2 model-index: - name: JJuliusFx/dyula-french-ctranslate2v250epochs results: [] ---
Downloads · 30 days
18
42% of all-time downloads
All-time downloads
43
Public
Repo size
26.3 MB
Likes
0
Public
Click a slice to open those files.
.bin6.4 MB · 96%
From the Hugging Face model README
language:
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.
More information needed
More information needed
More information needed
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)
More information needed
More information needed