SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.14348 · 2022

Synthetic Text Generation with Differential Privacy: A Simple and Practical Recipe

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2210.14348.json · badge: /api/ran/2210.14348.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
microsoft/dp-transformers canonical (classifier label)
classifier basis not recorded on the link
4 ran · 1 no recorded run
FunctionStatusWhere it lives
calc_perplexity Ran
ran on a synthesized input
microsoft/dp-transformers/research/synthetic-text-generation-with-DP/generate-text.py
code served (permissive licence) · get_code("eed0eaf234273f91")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal config class that has the attributes used by the function
class MinimalConfig:
    def __init__(self):
        self.n_positions = 1024
        self.pad_token_id = 0
        self.vocab_size = 100
        self.hidden_size = 16

# Create a minimal model that accepts input_ids and labels, returns loss
class MinimalModel(nn.Module):
    def __init__(self, config):
        super().__init__()
        self.config = config
        self.embedding = nn.Embedding(config.vocab_size, config.hidden_size)
        self.lm_head = nn.Linear(config.hidden_size, config.vocab_size)
    
    def forward(self, input_ids, labels=None):
        # Simple forward pass that returns a loss value
        embeddings = self.embedding(input_ids)
        logits = self.lm_head(embeddings)
        
        if labels is not None:
            # Compute a simple cross-entropy loss
            loss_fn = nn.CrossEntropyLoss(ignore_index=-100)
            shift_logits = logits[..., :-1, :].contiguous()
            shift_labels = labels[..., 1:].contiguous()
            loss = loss_fn(shift_logits.view(-1, self.config.vocab_size), shift_labels.view(-1))
            return (loss,)
        
        return (logits,)

# Instantiate config and model
config = MinimalConfig()
model = MinimalModel(config)

# Create encodings tensor: (batch_size=2, sequence_length=2048)
# Use token IDs in range [1, vocab_size) to avoid pad token mostly
encodings = torch.randint(1, config.vocab_size, (2, 2048))

ARGS = {
    'encodings': encodings,
    'cur_model': model,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_model Ran
ran on a synthesized input
microsoft/dp-transformers/research/synthetic-text-generation-with-DP/generate-text.py
code served (permissive licence) · get_code("67563e08a8fbe297")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import os
import tempfile

torch.manual_seed(0)

# Create a temporary directory to act as checkpoint_path
temp_dir = tempfile.mkdtemp()

# Create a minimal state dict with some sample tensors
sample_state_dict = {
    '_module.module.layer1.weight': torch.randn(4, 3),
    '_module.module.layer1.bias': torch.randn(4),
    '_module.module.layer2.weight': torch.randn(3, 4),
}

# Save the state dict to the temporary directory
checkpoint_path = temp_dir
torch.save(sample_state_dict, os.path.join(checkpoint_path, 'pytorch_model.bin'))

ARGS = {
    'checkpoint_path': checkpoint_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
create_author_mapping Ran
ran on a synthesized input
microsoft/dp-transformers/src/dp_transformers/dp_utils.py
code served (permissive licence) · get_code("3bdbafd8411ba32d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from datasets import Dataset
import pandas as pd

# Create a simple dataset with author information
data = {
    'author': ['Alice', 'Bob', 'Alice', 'Charlie', 'Bob', 'Alice'],
    'text': ['sample1', 'sample2', 'sample3', 'sample4', 'sample5', 'sample6']
}

dataset = Dataset.from_dict(data)

ARGS = {
    'dataset': dataset,
    'author': 'author'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
main_preprocess_function Ran
ran on a synthesized input
microsoft/dp-transformers/research/fine_tune_llm_w_qlora/data_utils.py
code served (permissive licence) · get_code("575843dbe0cdffe7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleTokenizer:
    def __init__(self):
        self.pad_token_id = 0
    
    def __call__(self, texts):
        # Return a dict with 'input_ids' and 'attention_mask'
        # Each text gets tokenized to a short list of token ids
        result = {
            'input_ids': [],
            'attention_mask': []
        }
        for text in texts:
            # Simple mock tokenization: convert text length to token ids
            tokens = [1, 2] + [3] * (len(text) % 3)
            result['input_ids'].append(tokens)
            result['attention_mask'].append([1] * len(tokens))
        return result

examples = {
    'text': ['Hello world', 'This is a test'],
    'label': [1, 0]
}

tokenizer = SimpleTokenizer()
text_field = 'text'
prompt_begin = 'Question: '
prompt_end = ' Answer: '
label_field = 'label'
sequence_len = 16
single_token = True

ARGS = {
    'examples': examples,
    'tokenizer': tokenizer,
    'text_field': text_field,
    'prompt_begin': prompt_begin,
    'prompt_end': prompt_end,
    'label_field': label_field,
    'sequence_len': sequence_len,
    'single_token': single_token
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
force_causal_attention Not yet run
unverified (harvested, no recorded run)
microsoft/dp-transformers/src/dp_transformers/module_modification.py
code served (permissive licence) · get_code("cc6277c4af092dcc")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 5 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Privacy concerns have attracted increasing attention in data-driven products due to the tendency of machine learning models to memorize sensitive training data. Generating synthetic versions of such data with a formal privacy guarantee, such as differential privacy (DP), provides a promising path to mitigating these privacy concerns, but previous approaches in this direction have typically failed to produce synthetic data of high quality. In this work, we show that a simple and practical recipe in the text domain is effective: simply fine-tuning a pretrained generative language model with DP enables the model to generate useful synthetic text with strong privacy protection. Through extensive empirical analyses on both benchmark and private customer data, we demonstrate that our method produces synthetic text that is competitive in terms of utility with its non-private counterpart, meanwhile providing strong protection against potential privacy leakages.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2210.14348")
get_code_for_paper("2210.14348")
have("2210.14348")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2210.14348.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2210.14348.svg)](https://syntology.ai/paper/2210.14348)

Connect an agent — have() is free.