Skip to main content

DP-ST

PyPI version GitHub stars License

Code repository for the EMNLP 2025 paper: Leveraging Semantic Triples for Private Document Generation with Local Differential Privacy Guarantees

Getting Started

Installation

You can now install DP-ST directly as a Python package.

# Install the core runtime engine
pip install dpst

# Install the optional data-preparation extensions required for the initial setup
pip install "dpst[setup]"

Note on Heavy Runtimes: We highly recommend installing the correct flavor of PyTorch matching your hardware's CUDA capability before installing this package.

Automated Database & Cluster Setup

In order to run DP-ST, you must first run the preparation stage as described in the paper. This includes booting up your local vector database, extracting triples from a public text corpus, clustering them, and storing them locally.

Ensure your local Weaviate instance is running, then execute the following automated command in your terminal:

dpst setup

Note: This can take a very long time! We recommend you set it and forget it. Alternatively, you can tweak the max_rows parameter of initialize_database to use less texts for the database preparation.

The above replaces the legacy workflow of manually executing Triple2DB.ipynb and triple_cluster.ipynb. The command will automatically stream the FineWeb public corpus dataset, extract/embed triples into Weaviate, run the MiniBatchKMeans allocations (50k, 100k, and 200k), and write the resulting cluster assets straight into the package data directory. If you prefer a more tailored approach, we still recommend using the notebooks.

Usage

Running DP-ST is simple once the automated setup has completed:

from dpst import DPST

# Initialize the engine (specify mode: "50k", "100k", or "200k")
X = DPST(mode="50k", model_checkpoint=MODEL_NAME, hf_token=TOKEN)

# Privatize your text corpus
private_texts = X.privatize([TEXTS], epsilon=DOC_PRIVACY_BUDGET)

MODEL_NAME refers to the model used for text reconstruction (i.e., the Llama-3.2 models we use in the work), and hf_token is only necessary for gated models on Hugging Face.

Running other DP Methods

In this repository (under the comparison directory), you will find a number of scripts (*_perturb.py) to reproduce the privatized texts as performed in our work.

The code for DP-BART and DP-Prompt can be found in LLMDP.py. DP-MLM can be found here and the code for TEM can be found here.

We also include the evaluation code for cosine similarity (CS.py) and G-Eval (Geval.ipynb), located in evaluation.

NOTE: in all provided notebooks, please make sure to include the correct libraries and link the paths accordingly. This is necessary for the code to run correctly!

Citation

If you use this code in your research, please consider citing the published work:

@inproceedings{meisenbacher-etal-2025-leveraging,
    title = "Leveraging Semantic Triples for Private Document Generation with Local Differential Privacy Guarantees",
    author = "Meisenbacher, Stephen  and
      Chevli, Maulik  and
      Matthes, Florian",
    editor = "Christodoulopoulos, Christos  and
      Chakraborty, Tanmoy  and
      Rose, Carolyn  and
      Peng, Violet",
    booktitle = "Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing",
    month = nov,
    year = "2025",
    address = "Suzhou, China",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2025.emnlp-main.455/",
    doi = "10.18653/v1/2025.emnlp-main.455",
    pages = "8976--8992",
    ISBN = "979-8-89176-332-6"
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dpst-0.3.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dpst-0.3.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file dpst-0.3.1.tar.gz.

File metadata

  • Download URL: dpst-0.3.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for dpst-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4d3f22baaaacfc8c7ade1465824a71cb7e9cd41bdfc88d4cc726b38902332ae1
MD5 996f7daebe41370a20642d0184b0837a
BLAKE2b-256 27b99a73cf5a3d2ac31b8b48ca2cea588ecaaed18dde6dbe2b0f1813cf256f3c

See more details on using hashes here.

File details

Details for the file dpst-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: dpst-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for dpst-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08ecf54f84eddc6ad0988e922e1fa17832e45557ae5c0f7c6993fd04df9e01b2
MD5 f717a54dc22b5d8745ac10ef26097abe
BLAKE2b-256 b57c1851b3fb99362e9853caadf394bab5239d8f1bc0537fa3b260493f82a6f7

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.9

2 files

0.3.8

2 files

0.3.5

2 files

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page