Skip to content

Quickstart

The shortest path to see piighost at work, without downloading a model. You will de-identify a sentence from a dictionary of known values, in under a minute.

import asyncio

from piighost.components.detector import ExactMatchDetector
from piighost.pipeline import AnonymizationPipeline

detector = ExactMatchDetector({"John Doe": "PERSON", "Paris": "LOCATION"})
pipeline = AnonymizationPipeline(detector)


async def main() -> None:
    result = await pipeline.anonymize("John Doe lives in Paris.")
    print(result.text)


asyncio.run(main())

The output should be:

<<PERSON:1>> lives in <<LOCATION:1>>.

How it works

ExactMatchDetector spots the values of the dictionary at word boundaries. The pipeline fills the other stages with their defaults, including an anonymizer that numbers the tokens per label. The First pipeline builds these stages one at a time.

See also

  • For real automatic detection, arbitrary names and locations, move on to the First pipeline with an NER like GLiNER2.
  • To describe a full pipeline in a file rather than in Python, see the configuration reference.
  • To de-identify across a conversation with persistent memory, see the Conversational pipeline.