Instructions to use google-t5/t5-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google-t5/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="google-t5/t5-small")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-small") model = AutoModelForSeq2SeqLM.from_pretrained("google-t5/t5-small") - Inference
- Notebooks
- Google Colab
- Kaggle
scores for model.generate()
Hi,
I intend to fine-tune the t5 model with a custom loss function (REINFORCE) since I do not have access to the immediate decoder outputs. Instead, I'd be using the decoder output for another downstream task which generates the pipeline non-differentiable. As such, I'm trying to find out how efficient it is to train using REINFORCE by using the probability of output generation: P(decoder_output). Is there a way to obtain the output generation logits for greedy decoding, something like:
model.generate(input_ids).logits
I tried to set output_scores = True, but that didn't work. On a different note, I could generate the output and use it alongside the input to get the logits using
output_ids = model.generate(input_ids)
model(input_ids, output_ids).logits
However, I think this might output incorrect probabilities owing to the teacher forcing. Is that correct?
Thanks !