Text summarization guide

Text Summarizer
Example

The MediaPipe Text Summarizer task lets you identify the most important information in a text and generate a shorter version while maintaining the original context meaning. This task operates on text data with a machine learning (ML) model and outputs a summary string.

This task supports two modes:

  • TLDR: Generates a short paragraph of 1–2 sentences.
  • Keypoints: Generates a bulleted list of 3–5 key points.

Get Started

Start using this task by following one of these implementation guides for your target platform. These platform-specific guides walk you through a basic implementation of this task, including a recommended model, and code example with recommended configuration options:

Task details

This section describes the capabilities, inputs, outputs, and configuration options of this task.

Features

  • Input text processing - Supports out-of-graph tokenization for models without in-graph tokenization.
Task inputs Task outputs
Text Summarizer accepts the following input data type:
  • String
Text Summarizer outputs the following results:
  • String: represents the summary.

Configuration options

This task has the following configuration options:

Option Name Description Value Range Default Value
mode The summarization mode of the text summarizer task. Can be a short summary paragraph or bulleted list of key points. TextSummarizerMode.TLDR, TextSummarizerMode.KEYPOINTS TextSummarizerMode.KEYPOINTS
max_num_tokens The maximum number of tokens for summarization tasks. If set, the summarization will be truncated if the input and output exceed this value. If not set, then the default limit is decided by the model capacity. Integer None (model capacity 8k)

Models

We offer a default, recommended model when you start developing with this task.

A lightweight, 200M-parameter model fine-tuned to generate two types of summaries in real time: TLDR and Keypoints. This model is released under the Apache 2.0 license.

Model name Input Quantization type Versions
Summarization 200M string Mixed Precision (Int4 + Int8) Latest

Task benchmarks

Here are the task benchmarks for the whole pipeline on a Pixel 10 Pro CPU, presenting the average latency across both Keypoints and TLDR modes. Peak memory usage for on-device model inference varies from approximately 200MB to 350MB depending on the input length (100 to 2000 words).

MediaPipe E2E Benchmark

Device Input Words (tokens) Prefill (tokens/s) Decode (tokens/s) E2E Latency (ms)
Pixel 10 Pro CPU 100 (~200 tokens) 980 133 900
500 (~900 tokens) 950 130 1790
1000 (~1900 tokens) 690 100 5,000
2000 (~3600 tokens) 470 55 12,000-17,000