Get startedGet started for free

Using min_length and max_length

The pipeline() function, has two important parameters: min_length and max_length. 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.

This exercise is part of the course

Working with Hugging Face

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a short summarizer
short_summarizer = pipeline(task="summarization", model="cnicu/t5-small-booksum", ____=1, ____=10)

# Summarize the input text
short_summary_text = ____(original_text)

# Print the short summary
print(short_summary_text[0]["summary_text"])
Edit and Run Code