Helsinki-NLP/news_commentary
Viewer • Updated • 4.23M • 2.28k • 39
How to use leonrafael29/bert2bert_uncased_english_to_spanish with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "translation" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline
pipe = pipeline("translation", model="leonrafael29/bert2bert_uncased_english_to_spanish") # Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("leonrafael29/bert2bert_uncased_english_to_spanish")
model = AutoModelForSeq2SeqLM.from_pretrained("leonrafael29/bert2bert_uncased_english_to_spanish", device_map="auto")