Text proofreading guide

Text Proofreader
Example

The MediaPipe Text Proofreader task lets you identify spelling, grammatical, and stylistic errors in a text and generate a corrected version while maintaining the original meaning. This task operates on text data with a machine learning (ML) model and outputs the corrected text.

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 a code example with recommended configuration options:

  • Android - Code example (https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/text_proofreader/android) - Guide
  • Python - Code example (https://github.com/google-ai-edge/mediapipe-samples/blob/main/examples/text_proofreader/python/text_proofreader.ipynb) - Guide
  • iOS - Code example (https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/text_proofreader/ios) - Guide

Task details

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

Features

  • Input text processing - Handles text pre-processing, including tokenization if needed.
  • Granular corrections - Provides a detailed breakdown of granular corrections, allowing you to identify which words were inserted, deleted, or left unchanged.
Task inputs Task outputs
Text Proofreader accepts the following input data type:
  • String
Text Proofreader outputs the following results:
  • String: represents the proofread result.
  • List of corrections: detailed breakdown of granular edits (insertions, deletions, or unchanged text segments).

Configuration options

This task has the following configuration options:

Option Name Description Value Range / Type Default Value
max_num_tokens The maximum number of tokens for proofread tasks. If set, the proofread output will be truncated if the input and output exceed this value. If not set (or equal to 0), the default limit is decided by the model capacity (8k). Integer None

Models

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

A lightweight 200M parameter model fine-tuned to identify spelling, grammatical, and stylistic errors in a text and generate a corrected version. This model is released under the Apache 2.0 license.

Model name Input Quantization type Versions
Text Proofreader string Mixed Precision (Int4 + Int8) Latest

Task benchmarks

Here are the task benchmarks for the whole pipeline on a Pixel 10 Pro CPU. 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) 1280 170 980
500 (~900 tokens) 1095 163 4,900
1000 (~1900 tokens) 1025 150 16,000
2000 (~3600 tokens) 980 140 28,000