from transformers import T5ForConditionalGeneration, T5Tokenizer | |
from huggingface_hub import login | |
# Log in to Hugging Face (optional, only if model access requires authentication) | |
hf_token = "YOUR_HF_TOKEN" # Replace with your Hugging Face token | |
login(token=hf_token) | |
# Download and save model and tokenizer | |
model = T5ForConditionalGeneration.from_pretrained('t5-small') | |
tokenizer = T5Tokenizer.from_pretrained('t5-small') | |
model.save_pretrained('./t5_small_weights') | |
tokenizer.save_pretrained('./t5_small_weights') | |
print("T5-small model and tokenizer downloaded and saved to './t5_small_weights'") |