DEV Community

Cover image for AI Document Anonymisation Assistant (For Whistleblowers)
Daniel Rosehill
Daniel Rosehill

Posted on

AI Document Anonymisation Assistant (For Whistleblowers)

Link to Assistant

Why This Was Created

The primary goal of this project is to provide a practical solution for anonymizing documents using large language models (LLMs). Whistleblowers, in particular, often face the challenge of sharing critical information without exposing their identities. This tool aims to help by offering a model configuration that can redact or replace identifiable information while preserving the integrity of the document’s context.

While I generally consolidate my LLM assistant configurations in a single repository, this project felt significant enough to warrant its own dedicated space. The hope is that this tool can serve as a small but meaningful contribution to the public good by empowering individuals who need to share sensitive information safely.

Image description

How It Works: Context and Approach

When redacting information, the typical approach involves substituting identifiable or indirectly identifiable data with replacement information that doesn’t alter the overall meaning or context. This is where LLMs shine—they can infer which details are critical to redact and which should remain untouched.

However, as with any AI-driven process, human supervision is essential. This configuration assumes that users will carefully review the output to ensure accuracy and appropriateness. Here are some key features of the tool:

  • Predefined Redaction Rules: The configuration includes guidelines on what types of personal information should always be redacted (e.g., names, addresses, phone numbers). These rules are customizable based on specific requirements.
  • Improved Version (V2): The second version refines the initial configuration by being more deterministic in its approach. It’s available in both JSON and Markdown formats for flexibility.
  • Inference-Based Decisions: The model leverages inference to distinguish between information that must always be redacted and information that should never be altered.

The example provided in V1 acts as a guide for the assistant, demonstrating the style and logic it should follow. While it requires some autonomous decision-making by the model, the user remains in control through careful review.

Ideas for Variants

This configuration serves as a proof of concept but opens up possibilities for further enhancements. Here are some ideas for potential variants:

  • Proposed Substitutions: Instead of directly replacing identifiable data, the assistant could suggest substitutions for user approval. This ensures that synthetic data generated by the model is sufficiently distinct from real-world facts.
  • Customizable Use Cases: The tool could be adapted for different scenarios requiring anonymization, such as legal documents or medical records.
  • Enhanced Validation: Additional layers of validation could be implemented to ensure that redacted documents meet specific privacy standards.

While this initial configuration demonstrates the use case effectively, it’s not intended as a definitive solution. Instead, it’s hoped that others will build on this foundation to create even more robust tools.

Generating Synthetic Data

For testing and validation purposes, generating synthetic data is crucial. Using an uncensored or unrestricted LLM may be necessary depending on the model’s refusal thresholds. In some cases, especially when dealing with sensitive scenarios like workplace harassment or abuse, including graphic descriptions might be required to ensure realistic testing conditions.

The test data folder includes two fictitious diaries that represent synthetic data describing instances of workplace harassment. These examples are entirely fictional and were generated by the same LLM used for this project.

Demonstration Documents: Testing and Validation

To validate the effectiveness of this configuration, I conducted test runs using Llama 3.3 70B Instruct hosted on Hugging Face Chat. The results demonstrated good adherence to the redaction requirements outlined in the test prompt.

Here’s what you’ll find in the test data folder:

  • Before and After Texts: Examples showing how documents were processed using the V1 configuration.
  • Synthetic Test Data: Fictional diary entries used for testing purposes. Any resemblance to real individuals or organizations is purely coincidental.

These demonstration documents showcase how well the model performs in anonymizing sensitive content while preserving context.

Conclusion

This project was created with a specific purpose: to provide a tool that helps individuals anonymize sensitive documents safely and effectively. Whether you’re a whistleblower sharing critical information or someone working on anonymization tasks more broadly, this configuration offers a starting point for leveraging LLMs in these scenarios.

While there’s room for improvement and customization, I hope this tool proves useful and inspires others to explore similar applications of AI for privacy protection. If you have ideas for enhancements or new use cases, feel free to share them!

Top comments (0)