1. Learn
  2. /
  3. Courses
  4. /
  5. Working with Hugging Face

Connected

Exercise

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.

Instructions 1/2

undefined XP
  • 1
    • Create a summarization pipeline to summarize original_text to between 1 and 10 tokens.
  • 2
    • Repeat these steps for a summarization pipeline that has a minimum length of 50 and maximum of 150.