Downloads · 30 days
7
7% of all-time downloads
alakxender/flan-t5-news-articles
flan-t5-news-articles is a machine learning model from alakxender. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
This project fine-tunes a Flan-T5 model to generate news articles in Dhivehi language based on titles.
Downloads · 30 days
7
7% of all-time downloads
All-time downloads
106
Public
Parameters
248M
3 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt2 GB · 67%
From the Hugging Face model README
This project fine-tunes a Flan-T5 model to generate news articles in Dhivehi language based on titles.
The model was evaluated using ROUGE metrics on a validation set. Here are the final evaluation results:
The training metrics at epoch 4.35:
The model shows reasonable performance on the validation set with ROUGE scores indicating decent overlap between generated and reference texts. The relatively low validation loss of 0.154 compared to training loss suggests the model is generalizing well without overfitting.
from transformers import T5ForConditionalGeneration, T5Tokenizer
# Load your finetuned model
model = T5ForConditionalGeneration.from_pretrained("alakxender/flan-t5-news-articles")
tokenizer = T5Tokenizer.from_pretrained("alakxender/flan-t5-news-articles")
def generate_text(prompt, max_new_tokens=150, num_beams=1, repetition_penalty=1.2, no_repeat_ngram_size=1, do_sample=True):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
num_beams=num_beams,
repetition_penalty=repetition_penalty,
no_repeat_ngram_size=no_repeat_ngram_size,
do_sample=do_sample,
early_stopping=True # this flag is only used in beam-based generation modes. You should set `num_beams>1` or unset `early_stopping`
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
prompt = "ބައެއް ފިހާރަތަކުގައި އަދިވެސް ބިދޭސީ ސޭޓުން!"
output = generate_text(f"Create an article about: {prompt}")
print(output)