Adjusting the summary length
The pipeline() function, has two important parameters: min_new_tokens and max_new_tokens. These are useful for adjusting the length of the resulting summary text to be short, longer, or within a certain number of words. You might want to do this if there are space constraints (i.e., small storage), to enhance readability, or improve the quality of the summary.
You'll experiment with a short and long summarizer by setting these two parameters to a small range, then a wider range.
pipeline from the transformers library and the original_text have already been loaded for you.
Deze oefening maakt deel uit van de cursus
Working with Hugging Face
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Generate a summary of original_text between 1 and 10 tokens
short_summarizer = pipeline(task="summarization", model="cnicu/t5-small-booksum", ____=1, ____=10)
short_summary_text = ____(original_text)
print(short_summary_text[0]["summary_text"])