How to print a few examples at the beginning of training when using Trainer?
I would like to see a few examples to manually verify the input and output. Previously in an older version of transformers there is a functionality of doing that. I am wondering whether there is something similar for trianer?
2021-06-29T12:05:00Z
This is not something related to theTrainer, you just have to print some elements of your dataset. The functionality is implemented in all examples, see for instancethis one
2021-06-29T16:35:28Z
Thanks!A follow-up question is how I could print out a few examples with output say per-batch? A concrete example would be given a seq2seqtrainer, I want to check the raw output during training as a measurement of progress. Would that be something doable?
2021-06-29T17:06:30Z
You can get the first batch of the training dataloader by doing:for batch in trainer.get_train_dataloader():
    breakand then access the sentences in batch. You will need to decode the inputs using your tokenizer though.
2021-06-29T18:29:31Z
I see. But this only has theinput, right? How could I access a few random examples of the output?
2021-06-29T18:30:59Z
output = model(**batch)will give you the output.