LlamaIndex components that mask personal data or extract entities defined in a plain-English rulebook, using ReDefiNER.
pip install llama-index-redefiner Copy PIP instructions
Personal-data masking and entity extraction for LlamaIndex, using ReDefiNER: an open model (0.8B parameters, Apache 2.0) that finds what a rulebook written in plain English defines. It runs locally on CPU or GPU. English only.
The PII components use the rulebook of jungroo-ai/redefiner-pii by default (20 types: names, contact details, addresses, dates, ID and card numbers and more). Pass your own rulebook to mask by your own policy.
pip install llama-index-redefiner The first call downloads the model weights (about 0.8 GB) from Hugging Face.
from llama_index_redefiner import ReDefiNERPIINodePostprocessor query_engine = index.as_query_engine(node_postprocessors=[ReDefiNERPIINodePostprocessor()]) A node that reads "Hi, this is Meera Nair from Brightwater Dental. Call me on 020 7946 0155." reaches the LLM as "Hi, this is [PERSON_12] from [ORGANIZATION_28]. Call me on [PHONE_59]." The mapping from tags to the original text is kept in node.metadata["__pii_node_info__"], which is excluded from what the LLM and the embedding model see, as with LlamaIndex's own PII postprocessors.
from llama_index.core import Document from llama_index.core.ingestion import IngestionPipeline from llama_index_redefiner import ReDefiNERPIIMasker pipeline = IngestionPipeline(transformations=[ReDefiNERPIIMasker()]) nodes = pipeline.run(documents=[Document(text="Hi, this is Meera Nair from Brightwater Dental. Call me on 020 7946 0155.")]) nodes[0].get_content() # 'Hi, this is [PERSON] from [ORGANIZATION]. Call me on [PHONE].' Nothing of the masked text is kept. Put a text splitter and an embedding model after it in the same pipeline as usual.
A rulebook lists the types you want, with a one-line description each, and can add rules and a list of what must never be found. See the rulebook guide. rulebook takes the text or the path of a rulebook file.
Every component also takes model, min_confidence, none_bias, threshold, max_span_tokens, device, revision and batch_size; see the ReDefiNER README for what the model settings do.
pip install -e ".[dev]" pytest # fast tests with a stand-in model pytest -m slow # the real model on CPU Licence Apache License 2.0. See LICENSE. Made by Jungroo AI Labs.
llama-index llamaindex pii redaction rag named-entity-recognition redefiner
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




