Skip to main content

Synthetic data generation using LLMs

Project description

Synthetic Data Generation PoC

Overview

This project generates synthetic data using an AI model based on a given YAML configuration file and a reference CSV file. The generated data follows the provided column structure and user-defined constraints.

Features

  • Reads column definitions and user instructions from a YAML configuration file.
  • Validates the structure of the YAML file.
  • Validates the format of the reference CSV file.
  • Generates synthetic data using Groq's Mixtral model.
  • Ensures the output is in CSV format without headers or extra text.
  • Enforces unique rows with consistent column counts.

Prerequisites

  • Python 3.8+
  • Required Python packages:
    • yaml
    • pandas
    • json
    • csv
    • groq

Usage

Run the script with the required YAML configuration file and reference CSV file:

python test1.py config.yaml test_data.csv [optional_api_key]

Arguments

config.yaml - YAML file specifying column definitions and generation rules. test_data.csv - Reference CSV file to guide synthetic data generation. [optional_api_key] - (Optional) Your own Groq API key. If not provided, a default API key will be used.

YAML Configuration Structure

The YAML file should define columns and the prompt:

columns:
  - name: "id"
    type: "integer"
  - name: "name"
    type: "string"
  - name: "email"
    type: "string"
  - name: "age"
    type: "integer"
  - name: "city"
    type: "string"
  - name: "signup_date"
    type: "datetime"
    
num_rows: 100
prompt: "Generate a dataset for user profiles."

Reference CSV File (test_data.csv)

This file provides sample data for reference.

Example test_data.csv:

id,name,age,email,city,signup_date
101,John Doe,28,john.doe@example.com,New York,2023-05-14
102,Jane Smith,34,jane.smith@example.com,Los Angeles,2022-11-21
...

Expected Output

  • The generated dataset will be stored in synthetic_data.csv.
  • The output will contain only comma-separated values without extra text or headers.
  • The generated rows will be unique and follow the reference data pattern.

Error Handling

  • If the YAML configuration is invalid, the script will display an error message and exit.
  • If the reference CSV file has missing columns, the script will halt with an error.
  • If no valid data is generated, an appropriate message will be displayed.

License

This project is for demonstration purposes only. Usage is subject to Groq API policies.

Project details


Download files

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

Source Distribution

syn_data_csv-0.1.1.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

syn_data_csv-0.1.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file syn_data_csv-0.1.1.tar.gz.

File metadata

  • Download URL: syn_data_csv-0.1.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for syn_data_csv-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8df5eb9cd9a354e0ee281e2d588e7e80ccc17bbed65d29a1fa3aedd54e45bf41
MD5 d72db6ab4d2665a6491447a8af7a79b1
BLAKE2b-256 f40fce3a68bb59d65f2c6cd24ea2c0a07c0339620a6b24533a82b7aa9a212803

See more details on using hashes here.

File details

Details for the file syn_data_csv-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: syn_data_csv-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for syn_data_csv-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f802bacd0d5cb8a8e63cf53432e46a33d52db65d487e9e41a5e5cb6054a0a462
MD5 ae93d1b420f557f5759d3b9bd5f685e0
BLAKE2b-256 ff7bea9d90a34749cf0a8320bfd0be2dc6ae98a7c9c40202ebb0faf534086932

See more details on using hashes here.

Supported by

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