Synthetic Mock Data
Project description
Synthetic Mock Data 🔮
Create data out of nothing. Prompt LLMs for Tabular Data.
Key Features
- A light-weight python client for prompting LLMs for mixed-type tabular data
- Select from a range of LLM endpoints, that provide structured output
- Supports single-table as well as multi-table scenarios.
- Supports variety of data types:
string,categorical,integer,float,boolean,date, anddatetime. - Specify context, distributions and rules via dataset-, table- or column-level prompts.
- Tailor the diversity and realism of your generated data via temperature and top_p.
Getting Started
- Install the latest version of the
mostlyai-mockpython package.
pip install -U mostlyai-mock
- Set the API key of your LLM endpoint (if not done yet)
import os
os.environ["OPENAI_API_KEY"] = "your-api-key"
# os.environ["GEMINI_API_KEY"] = "your-api-key"
# os.environ["GROQ_API_KEY"] = "your-api-key"
Note: You will need to obtain your API key directly from the LLM service provider (e.g. for Open AI from here). The LLM endpoint will be determined by the chosen model when making calls to mock.sample.
- Create your first basic synthetic table from scratch
from mostlyai import mock
tables = {
"guests": {
"prompt": "Guests of an Alpine ski hotel in Austria",
"columns": {
"nationality": {"prompt": "2-letter code for the nationality", "dtype": "string"},
"name": {"prompt": "first name and last name of the guest", "dtype": "string"},
"gender": {"dtype": "category", "values": ["male", "female"]},
"age": {"prompt": "age in years; min: 18, max: 80; avg: 25", "dtype": "integer"},
"date_of_birth": {"prompt": "date of birth", "dtype": "date"},
"checkin_time": {"prompt": "the check in timestamp of the guest; may 2025", "dtype": "datetime"},
"is_vip": {"prompt": "is the guest a VIP", "dtype": "boolean"},
"price_per_night": {"prompt": "price paid per night, in EUR", "dtype": "float"},
"room_number": {"prompt": "room number", "dtype": "integer", "values": [101, 102, 103, 201, 202, 203, 204]}
},
}
}
df = mock.sample(
tables=tables, # provide table and column definitions
sample_size=10, # generate 10 records
model="openai/gpt-4.1-nano", # select the LLM model (optional)
)
print(df)
# nationality name gender age date_of_birth checkin_time is_vip price_per_night room_number
# 0 AT Anna Müller female 29 1994-09-15 2025-01-05 14:30:00 True 350.0 101
# 1 DE Johann Schmidt male 45 1978-11-20 2025-01-06 16:45:00 False 250.0 102
# 2 CH Lara Meier female 32 1991-04-12 2025-01-05 12:00:00 True 400.0 103
# 3 IT Marco Rossi male 38 1985-02-25 2025-01-07 09:15:00 False 280.0 201
# 4 FR Claire Dupont female 24 2000-07-08 2025-01-07 11:20:00 False 220.0 202
# 5 AT Felix Gruber male 52 1972-01-10 2025-01-06 17:50:00 True 375.0 203
# 6 DE Sophie Becker female 27 1996-03-30 2025-01-08 08:30:00 False 230.0 204
# 7 CH Max Keller male 31 1992-05-16 2025-01-09 14:10:00 False 290.0 101
# 8 IT Giulia Bianchi female 36 1988-08-19 2025-01-05 15:55:00 True 410.0 102
# 9 FR Louis Martin male 44 1980-12-05 2025-01-07 10:40:00 False 270.0 103
- Create your first multi-table synthetic dataset
from mostlyai import mock
tables = {
"customers": {
"prompt": "Customers of a hardware store",
"columns": {
"customer_id": {"prompt": "the unique id of the customer", "dtype": "integer"},
"name": {"prompt": "first name and last name of the customer", "dtype": "string"},
},
"primary_key": "customer_id",
},
"warehouses": {
"prompt": "Warehouses of a hardware store",
"columns": {
"warehouse_id": {"prompt": "the unique id of the warehouse", "dtype": "integer"},
"name": {"prompt": "the name of the warehouse", "dtype": "string"},
},
"primary_key": "warehouse_id",
},
"orders": {
"prompt": "Orders of a Customer",
"columns": {
"customer_id": {"prompt": "the customer id for that order", "dtype": "integer"},
"warehouse_id": {"prompt": "the warehouse id for that order", "dtype": "integer"},
"order_id": {"prompt": "the unique id of the order", "dtype": "string"},
"text": {"prompt": "order text description", "dtype": "string"},
"amount": {"prompt": "order amount in USD", "dtype": "float"},
},
"primary_key": "order_id",
"foreign_keys": [
{
"column": "customer_id",
"referenced_table": "customers",
"prompt": "each customer has anywhere between 2 and 3 orders",
},
{
"column": "warehouse_id",
"referenced_table": "warehouses",
},
],
},
"items": {
"prompt": "Items in an Order",
"columns": {
"item_id": {"prompt": "the unique id of the item", "dtype": "string"},
"order_id": {"prompt": "the order id for that item", "dtype": "string"},
"name": {"prompt": "the name of the item", "dtype": "string"},
"price": {"prompt": "the price of the item in USD", "dtype": "float"},
},
"foreign_keys": [
{
"column": "order_id",
"referenced_table": "orders",
"prompt": "each order has between 1 and 2 items",
}
],
},
}
data = mock.sample(
tables=tables,
sample_size=2,
model="openai/gpt-4.1"
)
print(data["customers"])
# customer_id name
# 0 1 Matthew Carlson
# 1 2 Priya Shah
print(data["warehouses"])
# warehouse_id name
# 0 1 Central Distribution Hub
# 1 2 Northgate Storage Facility
print(data["orders"])
# customer_id warehouse_id order_id text amount
# 0 1 2 ORD-10294 3-tier glass shelving units, expedited deliver... 649.25
# 1 1 1 ORD-10541 Office desk chairs, set of 6, with assembly se... 824.9
# 2 1 1 ORD-10802 Executive standing desk, walnut finish, standa... 519.0
# 3 2 1 ORD-11017 Maple conference table, cable management inclu... 1225.5
# 4 2 2 ORD-11385 Set of ergonomic task chairs, black mesh, stan... 767.75
print(data["items"])
# item_id order_id name price
# 0 ITM-80265 ORD-10294 3-Tier Tempered Glass Shelving Unit 409.0
# 1 ITM-80266 ORD-10294 Brushed Aluminum Shelf Brackets (Set of 4) 240.25
# 2 ITM-81324 ORD-10541 Ergonomic Mesh-Back Desk Chair 132.5
# 3 ITM-81325 ORD-10541 Professional Office Chair Assembly Service 45.0
# 4 ITM-82101 ORD-10802 Executive Standing Desk, Walnut Finish 469.0
# 5 ITM-82102 ORD-10802 Desk Installation and Setup Service 50.0
# 6 ITM-83391 ORD-11017 Maple Conference Table, 10-Seat 1125.5
# 7 ITM-83392 ORD-11017 Integrated Table Cable Management Kit 100.0
# 8 ITM-84311 ORD-11385 Ergonomic Task Chair, Black Mesh 359.25
# 9 ITM-84312 ORD-11385 Standard Delivery Service 48.5
- Create your first self-referencing synthetic table
from mostlyai import mock
tables = {
"employees": {
"prompt": "Employees of a company",
"columns": {
"employee_id": {"prompt": "the unique id of the employee", "dtype": "integer"},
"name": {"prompt": "first name and last name of the president", "dtype": "string"},
"boss_id": {"prompt": "the id of the boss of the employee", "dtype": "integer"},
"role": {"prompt": "the role of the employee", "dtype": "string"},
},
"primary_key": "employee_id",
"foreign_keys": [
{
"column": "boss_id",
"referenced_table": "employees",
"prompt": "each boss has at most 3 employees",
},
],
}
}
df = sample(tables=tables, sample_size=10, model="openai/gpt-4.1")
print(df)
# employee_id name boss_id role
# 0 1 Sandra Phillips <NA> President
# 1 2 Marcus Tran 1 Chief Financial Officer
# 2 3 Ava Whittaker 1 Chief Technology Officer
# 3 4 Sophie Martin 1 Chief Operations Officer
# 4 5 Chad Nelson 2 Finance Manager
# 5 6 Ethan Glover 2 Senior Accountant
# 6 7 Kimberly Ortiz 2 Junior Accountant
# 7 8 Lucas Romero 3 IT Manager
# 8 9 Priya Desai 3 Lead Software Engineer
# 9 10 Felix Bennett 3 Senior Systems Analyst
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mostlyai_mock-0.0.9.tar.gz
(16.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mostlyai_mock-0.0.9.tar.gz.
File metadata
- Download URL: mostlyai_mock-0.0.9.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c05facea0d55a98c7bd40691db5b5fd5be4821f0aaef58acbf0aa1dd25814748
|
|
| MD5 |
73858f9fc56dfbf4d1bbd5ef6134fb53
|
|
| BLAKE2b-256 |
34535db2ee99f2a36bbec025e31483788d33a11b2e8574518c51617d952d91d8
|
File details
Details for the file mostlyai_mock-0.0.9-py3-none-any.whl.
File metadata
- Download URL: mostlyai_mock-0.0.9-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
241cb69d4e7f2e3c97af199c126c16fe100bf827b7fed62855ec35f61ca7d00e
|
|
| MD5 |
abe87a3bbcc56d5f74d5fb52ca63fe5d
|
|
| BLAKE2b-256 |
fbea0c9b21dbc237722f5497daf2396e954287462440b48ec1097555610cc22a
|