Downloads · 30 days
5
2% of all-time downloads
SynapseQAI/T5-base-wmt14
T5-base-wmt14 is a machine learning model from SynapseQAI. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This model was finetuned using 50 K French English sentence pairs on WMT14 Fr En dataset.
Downloads · 30 days
5
2% of all-time downloads
All-time downloads
294
Public
Parameters
223M
1.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors892 MB · 100%
From the Hugging Face model README
This model was finetuned using 50 K French English sentence pairs on WMT14 Fr En dataset.
from transformers import T5Tokenizer, T5ForConditionalGeneration
# Load the pre-trained model and tokenizer
model_name = "SynapseQAI/T5-base-wmt14"
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)
# Function to translate using beam search (default strategy)
def translate(sentence):
# Prepare the input for the model
input_text = f": {sentence}"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
# Generate translation using beam search
outputs = model.generate(input_ids, num_beams=3, max_length=50, early_stopping=True)
# Decode the generated translation
translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
return translation
# French sentences from easy to advanced
sentences = [
"Le soleil se lève à l'est et se couche à l'ouest.",
"Les scientifiques travaillent dur pour trouver un remède.",
"La capitale de la France est Paris.",
"Je voudrais un café s'il vous plaît.",
"Il fait beau aujourd'hui.",
"J'aime lire des livres et regarder des films pendant mon temps libre.",
"Si j'avais su que tu venais, j'aurais préparé quelque chose de spécial pour le dîner.",
"Même si les avancées technologiques apportent de nombreux avantages, elles posent également des défis éthiques considérables qu'il nous faut relever."
]
# Translate each sentence and print the best translation
for sentence in sentences:
translated_sentence = translate(sentence)
print(f"French: {sentence}\nEnglish: {translated_sentence}\n")