Helsinki-NLP/opus-100
Viewer • Updated • 55.1M • 27.2k • 235
How to use dmedhi/eng2french-t5-small with PEFT:
from peft import PeftModel
from transformers import AutoModelForSeq2SeqLM
base_model = AutoModelForSeq2SeqLM.from_pretrained("t5-small")
model = PeftModel.from_pretrained(base_model, "dmedhi/eng2french-t5-small")How to use dmedhi/eng2french-t5-small 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="dmedhi/eng2french-t5-small") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("dmedhi/eng2french-t5-small", dtype="auto")A language translation model fine-tuned on opus100 dataset for English to French translation.
The model is intended to use for English to French translation related tasks.
Install necessary libraries
pip install transformers peft accelerate
Use the code below to get started with the model.
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("dmedhi/eng2french-t5-small")
model = AutoModelForSeq2SeqLM.from_pretrained("t5-small")
model = PeftModel.from_pretrained(model, "dmedhi/eng2french-t5-small")
context = tokenizer(["Do you want coffee?"], return_tensors='pt')
output = model.generate(**context)
result = tokenizer.decode(output[0], skip_special_tokens=True)
print(result)
# Output
# Tu veux du café?
Base model
google-t5/t5-small