OllamaCLI icon
SlackIncomingWebhook icon

Privacy-Safe PII Redaction with a Local Ollama Model

Redact PII from documents with a local Ollama model in Kestra. The text never leaves your network, and only the sanitized artifact moves downstream.

Categories
AI

Using a cloud API to remove personal data from a document has an obvious flaw: the unredacted document, PII included, must be sent to the cloud first. This blueprint inverts that. io.kestra.plugin.ollama.cli.OllamaCLI runs the redaction model on your own infrastructure, so the sensitive original never crosses the network boundary, and only the sanitized redacted.txt artifact is available for downstream steps that talk to external tools, vendors, or larger cloud LLMs.

How it works

  1. redact receives the document through inputFiles (inline here for the demo; map it from internal storage in real use) and runs ollama run {{ inputs.model }} with a prompt that names the PII categories to strip, mandates the [REDACTED] placeholder, and forbids any other changes to the text.
  2. The model's answer is redirected to redacted.txt, and outputFiles uploads it to internal storage as the execution's sanitized artifact, addressable as {{ outputs.redact.outputFiles['redacted.txt'] }} by any downstream task.
  3. enableModelCaching: true persists the model between runs, so recurring redaction jobs skip the download.
  4. notify posts a completion pointer to Slack. Deliberately, neither the original nor the redacted content is interpolated into the payload, since the notification channel itself may leave the compliance boundary.
  5. The errors block posts a distinct alert that explicitly warns against sharing the source document when the run fails.

What you get

  • A redaction step whose data flow is auditable by construction: sensitive text in, sanitized artifact out, nothing external in between.
  • The sanitized version as a first-class artifact that downstream cloud-facing tasks can reference without ever touching the original.
  • A model-as-input design, so compliance can mandate a specific validated model per environment.
  • Failure semantics that fail closed: no redacted artifact is produced unless the model run completes.

Who it's for

  • Teams in healthcare, finance, or the public sector that must sanitize documents before external processing.
  • Platform engineers building a redact-first gate in front of cloud LLM or vendor integrations.
  • Anyone whose data processing agreements rule out sending raw customer text to hosted APIs.

Why orchestrate this with Kestra

A redaction policy is only as good as its enforcement point. Running the model inside a Kestra flow makes the sanitized artifact the only thing downstream tasks can conveniently reference, gives every redaction an execution record for audits, and alerts the moment a run fails instead of letting an unsanitized file slip through a broken script. LLM-based redaction is probabilistic, so keep a human review step for high-stakes documents; the execution artifact gives reviewers exactly one file to check.

Prerequisites

  • The default containerImage runs Ollama inside Docker, so the Kestra worker needs access to a Docker daemon. On self-hosted workers that already have Ollama installed locally, set the task's taskRunner to Process to keep inference on that machine.
  • A model validated against your own document samples; spot-check recall on every category you must redact.
  • A Slack incoming webhook.

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook URL.

Quick start

  1. Add the SLACK_WEBHOOK_URL secret to your Kestra namespace.
  2. Execute the flow and download redacted.txt; all three names, emails, and the phone number in the sample should read [REDACTED].
  3. Replace the inline document with a file from internal storage, S3, or a webhook trigger.

How to extend

  • Chain a downstream task that sends only redacted.txt to a cloud LLM for summarization, combining local privacy with hosted model quality.
  • Add a verification pass: a second local model run or a regex scan over redacted.txt that fails the execution if an email or phone pattern survived.
  • Extend the prompt's category list to account numbers, addresses, or internal project codenames.
  • Batch-redact a folder of documents with a ForEach over file names, reusing the warmup pattern from the Ollama model warmup blueprint.

Links

Orchestrate with Kestra
Orchestrate Slack with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.