smaple.tr
AI & Data

Synthetic Data Generation: Methods, Tools and Privacy Checks

Mehmet Kurtipek
June 15, 2026
16 min read
AI & Data
Synthetic data
Data privacy
Machine learning
Test data

Synthetic data generation is the process of creating artificial records that keep the structure and statistical patterns of a real dataset (the same columns, similar distributions, similar relationships between fields) without reusing the real records. There are three broad ways to do it: write rules and fill them with fake values, train a statistical or deep generative model on real data and sample from it, or prompt a large language model to write examples. The method matters less than the two checks you run afterwards: does a model trained on the synthetic data still work on real data, and can anyone find a real person in it?

What counts as synthetic data

Fake data is produced by rules: random names and addresses, ID numbers with valid check digits, dates inside a range. The generator never sees real records, so it can't leak them. It can't discover anything either. If order totals should rise with customer age, that only happens when you write the rule.

Model-generated data comes from a generator that was trained on a real dataset and is then sampled. It reproduces correlations nobody wrote down, and for the same reason it can reproduce things you didn't want, up to near-copies of individual records. An LLM writing examples is a special case: it draws on what it learned in pre-training plus whatever you put in the prompt.

Simulated data comes from a physics engine, game engine or process simulator: camera images for a robot, sensor readings for a machine, event logs for a warehouse. It matters most in computer vision and robotics.

Masking is a separate technique. A masked table keeps the real rows and swaps the identifiers, so every real customer's purchase history is still in it. For the organisation that did the masking, that is pseudonymised data, and GDPR still treats pseudonymised data as personal data.

Start from the job

What the data is for decides the method. Three jobs cover most uses: test data; data for training, analysis or sharing; and text for LLM work, which gets its own section further down.

Test, demo and staging data

For a software team the usual goal is to stop copying production into staging. You rarely need a trained model for that. A library such as Faker gives you plausible names, addresses, phone numbers and dates, and you write the business logic that ties them together: an order placed after the account was created, a discharge after the admission. Because nothing is learned from real records, the privacy question largely goes away. If you're working toward ISO 27001, as we are, Annex A control 8.33 asks that test information be appropriately selected, protected and managed, and generated test data is about the simplest way to meet it.

The hard part is reproducing the messy cases. Oplist, a client we build for, runs a hospital shift-scheduling SaaS that receives staff and leave data from hospitals' HR and payroll systems over live API integrations. The real feeds contained duplicate staff records, and some leave types take precedence over others, so we had to deduplicate and apply a precedence order inside Oplist instead of trusting the source. A generator written from the schema produces neither case, so the tests pass on clean data and the problem shows up in production. Before you generate test data, list the faults you have actually seen in production and generate those on purpose.

Training, analysis or sharing

When the data has to behave like the real thing statistically, you need a generator trained on the real table. The typical reasons: you want more examples of a rare class (fraud, an uncommon diagnosis), you want to share a dataset with a vendor or research partner who may not see the original, or your data scientists need a development copy without raw personal records.

Two cautions. For an imbalanced classifier, try class weights or a simple oversampler such as SMOTE before a generative model; they are cheaper and often enough. And a generator can't add information that isn't in the data. Fit it to 300 fraud cases and you get 30,000 rows built from those 300 cases' patterns, which look more convincing than they are. Synthetic data is sometimes pitched as a way to avoid labelling real data, but for supervised learning you still need a labelled real set to test against.

When to skip it

Leave synthetic data out when the outliers are the point (investigating specific fraudulent transactions, say), when the real dataset is small and its owners can simply approve access, and for the final evaluation of any model, which has to run on real data.

Methods, from simplest to heaviest

Method

What it learns

Good for

Watch out for

Rules and fake-value libraries (Faker)

Nothing from real data

Test and demo data

Correlations exist only if you code them

Statistical models (Gaussian copula, Bayesian networks, the CART models R's synthpop uses)

Column distributions and pairwise relationships

A first attempt on any table; small and medium datasets

Misses complex, conditional interactions

GANs and VAEs for tables (CTGAN, TVAE)

Non-linear relationships in mixed numeric and categorical data

Larger tables where the copula's quality score falls short

Slower, sensitive to tuning, can memorise rows

Diffusion and autoregressive tabular models (TabDDPM, MOSTLY AI's TabularARGN)

The same, usually with higher fidelity

When fidelity matters most and compute is available

Memorisation risk grows with fidelity

LLM prompting

What the model knows, plus your prompt and seed examples

Text, Q&A pairs, instructions, edge-case scenarios

Repetition, factual errors, provider terms

Simulation

The simulator's rules

Images, sensor data, robotics

The gap between simulation and reality

We'd start with a Gaussian copula. It fits in seconds to minutes on a laptop, it's easy to explain to whoever signs off on the data, and its failures show up plainly in the quality report. Move to CTGAN or a diffusion model only when the quality report or the utility test below shows a gap that matters for your use.

A minimal example with SDV 2.0

SDV, from DataCebo, is a widely used Python library for tabular synthetic data. Version 2.0 came out on 15 October 2026 and changed the interface: fit() now takes a dictionary that maps table names to DataFrames, even for a single table, and sample() returns one. Most tutorials online still show the 1.x calls. On 2.0, Metadata.detect_from_dataframe() no longer exists and passing a bare DataFrame to fit() raises an InvalidDataTypeError. The evaluation functions moved as well: sdv.evaluation.single_table is gone, and run_diagnostic and evaluate_quality now come from sdv.evaluation. The snippet below runs on 2.0.0.

Check the licence as well. SDV is under the Business Source License 1.1, which makes it source-available rather than open source. You can use it, in production too, as long as you don't sell its functionality to third parties as a synthetic data service, and each release switches to the MIT licence four years after it ships.

import pandas as pd
from sdv.metadata import Metadata
from sdv.single_table import GaussianCopulaSynthesizer
from sdv.evaluation import run_diagnostic, evaluate_quality

real = pd.read_csv("patients.csv")
train = real.sample(frac=0.5, random_state=0)   # the generator sees only this half
holdout = real.drop(train.index)                 # kept back for the checks below

data = {"patients": train}
metadata = Metadata.detect_from_dataframes(data)  # review detected types and keys

synth = GaussianCopulaSynthesizer(metadata)
synth.fit(data)
synthetic = synth.sample(num_rows=len(train))    # {"patients": DataFrame}

run_diagnostic(data, synthetic, metadata)        # validity: keys, ranges, categories
evaluate_quality(data, synthetic, metadata)      # column shapes and pair trends

On fit(), SDV warns that the metadata hasn't been saved. Once you've checked the detected types (especially which columns it took for IDs and which for categories), save it with metadata.save_to_json() and load it with Metadata.load_from_json() on later runs, so a fresh detection can't quietly change a column's type.

The diagnostic should come out at or near 100%: it checks that keys are unique, values stay inside the real ranges and categories are valid. The quality report scores how closely each column's distribution, and the relationship between each pair of columns, matches the real data. A high score means the table looks right column by column. It says nothing about whether a model trained on it will work, or whether it leaked anyone. Holding back half of the real data is what lets you test both.

Check 1: does it carry the signal?

The standard utility test is TSTR, short for train on synthetic, test on real. Train the model you actually care about on the synthetic table, evaluate it on the real holdout, and compare it with the same model trained on the real training half. If the two scores are close, the synthetic data carries the signal you need. If the synthetic-trained model falls well short, the generator has lost relationships your model depends on, often in exactly the minority class you wanted more of. There is no universal pass mark, so decide before you look how much of a drop in your metric the use can tolerate.

Check 2: is anyone in there?

Generators can memorise, and the more faithful the generator, the more likely it is to reproduce rare records almost verbatim. Rare records (the 97-year-old patient, the one customer with an enormous contract) are also the easiest to re-identify. A USENIX Security 2022 study by Stadler, Oprisanu and Troncoso found that synthetic data from generators without explicit privacy protection didn't protect outlier records: an attacker holding the synthetic dataset could infer with high confidence whether a target record was in the original. Differentially private generators did protect them, at a significant cost in utility, and the existing implementations of two popular DP generators, PrivBayes and PATE-GAN, broke their formal guarantee because they read details such as the possible category values straight from the raw data.

A practical first test comes from Platzer and Reutterer's holdout-based method. With the real data split into equal training and holdout halves, measure for every synthetic row the distance to its closest training row and to its closest holdout row. A generator that learned patterns rather than people produces rows that sit about as close to the holdout as to the training data, so the share of synthetic rows closer to training should be near 50%, and exact copies should be zero.

from sklearn.neighbors import NearestNeighbors

def encode(df, ref, drop=("patient_id",)):
    """One-hot encode categories, scale numbers with the training data's statistics."""
    df, ref = df.drop(columns=list(drop)), ref.drop(columns=list(drop))
    num = ref.select_dtypes("number").columns
    out = pd.get_dummies(df, dtype=float).reindex(
        columns=pd.get_dummies(ref, dtype=float).columns, fill_value=0.0)
    out[num] = (out[num] - ref[num].mean()) / ref[num].std().replace(0, 1)
    return out.fillna(0.0).to_numpy()   # a missing number counts as the training mean

def closest(a, b):
    """Euclidean distance from each row of a to its nearest row in b."""
    return NearestNeighbors(n_neighbors=1).fit(b).kneighbors(a)[0][:, 0]

syn = synthetic["patients"]
cols = train.columns.drop("patient_id")
print("exact copies:", len(syn[cols].merge(train[cols].drop_duplicates())))
print("chance matches (holdout vs training):", len(holdout[cols].merge(train[cols].drop_duplicates())))

S = encode(syn, train)
to_train = closest(S, encode(train, train))
to_holdout = closest(S, encode(holdout, train))
share = (to_train < to_holdout).mean() + 0.5 * (to_train == to_holdout).mean()
print(f"closer to training than to holdout: {share:.0%}")  # aim for about 50%

Leave ID and free-text columns out of the distance (the drop argument), and turn dates into numbers first (days since a fixed date, say), or get_dummies will create a column for every distinct date. Missing numbers are filled with the training mean. Without that step, one empty cell turns every distance into NaN and the share comes out at 0%, which looks like a perfect score.

The paper uses Hamming distance on binned data; Euclidean distance on scaled columns applies the same idea, and scikit-learn's NearestNeighbors (installed with SDV) finds the nearest rows without building the full distance matrix in memory. On a table with only a few coarse columns, some exact matches happen by chance, which is why the snippet also counts holdout rows that match a training row: that number is your baseline. To see the check work, mix a few hundred real training rows into the synthetic table and run it again: exact copies appear and the share rises above 50%.

Passing this test is evidence that the generator isn't copying records. It doesn't prove the data is anonymous: Stadler and colleagues found that privacy evaluations based on similarity between real and synthetic records badly underestimate the risk. An attacker with outside information can try membership inference (was this person in the training data?) or attribute inference (what is this person's diagnosis?). For data that leaves your organisation, add an attack-based assessment or use differential privacy.

Differential privacy, when you need a guarantee

Differential privacy (DP) is the one approach here that puts a mathematical bound on how much the output can reveal about any single person. The bound is set by a privacy budget, epsilon. A smaller epsilon means stronger protection and noisier data, and outliers and small subgroups pay the most. There is no universally right value. NIST's SP 800-226, Guidelines for Evaluating Differential Privacy Guarantees, final since March 2025, is the clearest reference for judging a DP claim, your own or a vendor's. For implementations, OpenDP's SmartNoise Synth (MIT licence) includes DP synthesizers such as MST, AIM and DP-CTGAN, and the MOSTLY AI SDK has a DP training option.

Where the law draws the line

Three points hold under GDPR and similar laws such as Turkey's KVKK.

Training a generator on personal data is processing personal data. It needs a lawful basis like any other use, and producing synthetic output afterwards doesn't change that.

Synthetic output falls outside GDPR only if it is anonymous, meaning nobody can identify a person by means reasonably likely to be used (Recital 26). Until your tests support that, treat synthetic data derived from personal data as personal data. The generator itself can hold personal data too: in Opinion 28/2024 the European Data Protection Board said AI models trained on personal data can't always be considered anonymous.

Uploading the real table to a hosted synthesis platform hands personal data to a processor, possibly in another country, with the contracts and transfer rules that come with that. Tools that run on your own infrastructure, where the data already sits, avoid both questions.

The EU AI Act adds a fourth. Since the Digital Omnibus on AI (Regulation (EU) 2026/1744) came into force on 27 July 2026, the Act's new Article 4a lets AI providers and deployers process special-category data (health, ethnic origin and so on) to detect and correct bias only when synthetic or anonymised data can't do the job, and they have to record why it couldn't. If bias testing is on your roadmap, synthetic data is the option you will be expected to have tried first. We cover the testing side in our post on responsible AI development.

Synthetic data from LLMs

For text, the generator is usually another LLM. Teams use it for fine-tuning pairs, question-and-answer sets that test a RAG system against their own documents, labelled examples for a classifier and simulated customer messages. Four problems come up often enough to plan for:

  • Sameness. Ask for 1,000 support tickets and you get variations on a few dozen. Vary the inputs on purpose: sample personas, products, error types and tone from lists, feed them into each prompt, then deduplicate the results.
  • Confident errors. Validate whatever code can validate (JSON schema, arithmetic, whether the cited passage actually contains the answer) and have a person read a sample of the rest.
  • Feedback loops. Shumailov and colleagues showed in Nature that models trained recursively on generated data degrade, losing the rare tails of the original distribution first. Keep real data in the mix.
  • Terms of use. Some providers, OpenAI among them, prohibit using their outputs to develop competing models. Read the terms of the model you generate with.

NVIDIA's NeMo Data Designer (Apache 2.0) is one framework built for this work: it combines statistical samplers, LLM-generated columns and validators in one pipeline. Gretel, the hosted platform many older articles recommend, was acquired by NVIDIA in 2025, and gretel.ai now redirects to NVIDIA.

Two lessons from AI projects we worked on for clients apply here. For the field-ticket automation we built with an agency partner for an oilfield services company, we tested LLM extraction on real tickets for a month before going live. A synthetic evaluation set helps while you build, but the score that counts is the one on documents the system will actually receive. On Jenesys AI's bookkeeping assistant, custom models we built were later overtaken by frontier models. If your synthetic set exists to fine-tune a model of your own, first check whether a current frontier model with a handful of real examples in the prompt already does the job.

Tools worth knowing in October 2026

Tool

Licence

Where it runs

Use it for

Faker

MIT

Your machine

Fake values for test data, in many locales

SDV 2.0 (DataCebo)

Business Source License 1.1

Your machine

Single- and multi-table synthesis, quality reports

MOSTLY AI Synthetic Data SDK

Apache 2.0

Your machine, or MOSTLY AI's platform

Tabular and text synthesis, DP option

synthcity

Apache 2.0

Your machine

Comparing many generators side by side; last release May 2025

SmartNoise Synth (OpenDP)

MIT

Your machine

Differentially private synthesizers

NeMo Data Designer (NVIDIA)

Apache 2.0

Your machine, plus an LLM endpoint

LLM-generated datasets

Frequently asked questions

Can I generate a whole database, foreign keys included?

For a few related tables, yes. In SDV 2.0 you put every table in the same dictionary, check that detect_from_dataframes found the right primary and foreign keys, and fit an HMASynthesizer. sample_scale(1.0) then returns every table at its original size with valid foreign keys (in 1.x this was sample(scale=...)). SDV's documentation says HMA is built for around five tables with one level of parent-child depth. For a staging database with dozens of tables, rule-based seed scripts are usually less work.

Can I just ask an LLM to write a synthetic table?

For a small demo table, yes: a few dozen plausible customers or products are quick to get that way. For data that has to match the statistics of a real table, no. The model hasn't seen your data, so its distributions and correlations are guesses, and pasting real rows into the prompt to get closer sends personal data to the model provider. Use a tabular generator that runs where the data already sits, and keep LLMs for text.

How many synthetic rows should I generate?

For the utility test, as many as the real training set, so the comparison is fair. Beyond that, extra rows add no information that wasn't in the real data. They help only where a downstream job needs volume, such as a load test.

If you'd like someone outside the project to look over your synthetic data plan or its privacy checks, you can reach us through our data and AI services page.

Related Articles

August 11, 2026

MLOps Guide: What to Set Up First, and What Can Wait

MLOps gets a model into production and keeps it useful there. Here is the order we'd set it up in, with current MLflow and DVC examples, and what changes for LLM features.

Read More: MLOps Guide: What to Set Up First, and What Can Wait
August 9, 2026

Computer Vision Applications: Where It Works and Where It Struggles

Where computer vision works today, from inspection lines to invoices and medical scans, what makes some applications hard, and when a general vision model saves you training your own.

Read More: Computer Vision Applications: Where It Works and Where It Struggles
August 4, 2026

AI Agent Development: When You Need One and How to Build It

An AI agent is a language model working in a loop with tools. When you need one, the loop in Python, choosing a framework, keeping it safe, and what each run costs.

Read More: AI Agent Development: When You Need One and How to Build It