Skip to content

The aim of this repo is to test q# for generating synthetic data. It is just an experiment

mia-platform/quantum-synthetic-data-generator-experimemt

Repository files navigation

Quantum Book Generation System

πŸ“– For detailed technical explanations and quantum algorithms implementation, see HOWITWORK.md

A sophisticated quantum computing application that generates realistic synthetic book datasets using quantum superposition, entanglement, and advanced quantum algorithms. This project demonstrates how quantum computing can create synthetic data with natural correlations and true randomness that classical systems cannot achieve.

🌟 Features

Quantum Techniques Used

  • Quantum Superposition: Creates probabilistic distributions for genre and title selection
  • Quantum Entanglement: Generates correlated features (genre-title, creator-updater relationships)
  • Quantum Random Number Generation: True randomness for publication years and ISBNs
  • Quantum Fingerprinting: Description matching using quantum state signatures
  • Quantum Measurement: Collapses superposition states to definite values

Generated Book Data

  • Book Titles: Genre-correlated titles using quantum entanglement
  • Genres: 8 book genres with weighted quantum probability distributions
  • Publication Years: 1900-2024 range using quantum random generation
  • ISBNs: Valid 13-digit ISBN codes with quantum bit patterns
  • Descriptions: Genre-specific descriptions using quantum fingerprinting
  • User Assignments: Creator/updater correlations through quantum entanglement

πŸ“ Project Structure

quantum-hello-world/
β”œβ”€β”€ SimpleQuantumGenerator.qs        # πŸŽ“ Simple tutorial - Start here for learning
β”œβ”€β”€ QuantumDataGenerator.qs          # πŸ”¬ Advanced quantum data generator  
β”œβ”€β”€ QuantumBookGenerator.qs          # πŸ“š Real-world application example
β”œβ”€β”€ QuantumDataGeneration.ipynb      # πŸ““ Jupyter notebook demonstration
β”œβ”€β”€ sample_data.json                 # JSON configuration for data structure
β”œβ”€β”€ books.json                       # Input example book data
β”œβ”€β”€ genbooks.json                    # Generated synthetic books (50 books)
β”œβ”€β”€ qsharp.json                      # Q# project configuration
β”œβ”€β”€ README.md                        # This file
└── HOWITWORK.md                     # Detailed technical explanation

πŸŽ“ Learning Path

New to Quantum Programming? Follow this progression:

  1. πŸŽ“ Start with SimpleQuantumGenerator.qs - Simple tutorial covering fundamental concepts

    • Learn quantum superposition for data generation
    • Understand quantum entanglement for correlated features
    • See simple examples with age, income, and categories
  2. πŸ”¬ Progress to QuantumDataGenerator.qs - Advanced techniques and algorithms

    • Explore quantum walks and variational circuits
    • Master complex probability distributions
    • Learn quantum fingerprinting and noise injection
  3. πŸ“š Apply with QuantumBookGenerator.qs - Real-world domain-specific application

    • Generate realistic book datasets
    • See practical implementation of quantum concepts
    • Understand production-ready quantum data generation

πŸš€ Quick Start Guide

Follow these step-by-step instructions to clone, build, and run the quantum book generation application.

Step 1: Prerequisites Installation

Install VS Code and Q# Extension

  1. Download and install Visual Studio Code
  2. Open VS Code and install the Quantum Development Kit (QDK) extension:
    • Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
    • Search for "Microsoft Quantum Development Kit"
    • Click "Install"

Install Python and Quantum Dependencies (Optional - for Jupyter notebooks)

# Install Python 3.8+ if not already installed
python3 --version

# Install quantum packages for Jupyter notebook support
pip3 install qsharp qsharp-widgets jupyter

Step 2: Clone the Repository

# Clone the repository
git clone [email protected]:mia-platform/quantum-synthetic-data-generator-experimemt.git
cd quantum-synthetic-data-generator-experimemt

# Or if downloading manually, extract to a folder and navigate to it
cd path/to/quantum-synthetic-data-generator-experimemt

Step 3: Verify Project Structure

Ensure your project contains these files:

ls -la
# Expected output:
# SimpleQuantumGenerator.qs
# QuantumDataGenerator.qs  
# QuantumBookGenerator.qs
# books.json
# qsharp.json
# README.md
# HOWITWORK.md

Step 4: Open in VS Code

# Open the project in VS Code
code .

Wait for the Q# extension to activate (you'll see "Q# Language Server" in the status bar).

Step 5: Build the Project

The Q# project will automatically build when you open it. To manually verify:

  1. Open any .qs file in VS Code
  2. Check for any red underlines (compilation errors)
  3. If errors appear, ensure all imports are correct

Step 6: Start Your Quantum Learning Journey

πŸŽ“ Option A: Begin with the Tutorial (Recommended for Beginners)

  1. Start with the simple tutorial:

    # Run the simple quantum data generator tutorial
    qsharp run SimpleQuantumGenerator.qs
  2. Learn the fundamentals:

    • Observe how quantum superposition creates data distributions
    • See quantum entanglement generate correlated features (age/income)
    • Understand quantum measurement for final data values
  3. Tutorial output explanation:

    • Small sample size (10 items) for easy understanding
    • Clear step-by-step explanations in the output
    • Educational comments throughout the code

πŸ”¬ Option B: Advanced Quantum Techniques

Once comfortable with basics, try the advanced generator:

# Run the advanced quantum data generator with sophisticated algorithms
qsharp run QuantumDataGenerator.qs

πŸ“š Option C: Real-World Application

For the complete book generation example:

  1. Run the book generator:

    # Generate realistic book datasets
    qsharp run QuantumBookGenerator.qs
  2. Using VS Code (Alternative):

    • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
    • Type "Q#: Run Q# program"
    • Select your chosen .qs file
    • View results in the OUTPUT panel

Option B: Using the Provided Example

The repository includes a books.json file as input example and a generated genbooks.json with 50 quantum-generated books.

  1. View the input example:

    cat books.json
  2. View the generated output:

    cat genbooks.json | head -20  # View first 20 lines
  3. Regenerate books (if desired):

    # Run the quantum book generator to create new synthetic books
    qsharp run QuantumBookGenerator.qs

Step 7: Run Other Quantum Generators

Simple Quantum Data Generator

# Run the simple quantum data generator tutorial
qsharp run SimpleQuantumGenerator.qs

Advanced Quantum Data Generator

# Run the advanced quantum data generator with entanglement
qsharp run QuantumDataGenerator.qs

Step 8: Explore with Jupyter Notebook (Optional)

If you installed Python dependencies:

  1. Start Jupyter Notebook:

    jupyter notebook
  2. Open the quantum notebook:

    • Navigate to QuantumDataGeneration.ipynb
    • Run cells to see interactive quantum data generation
  3. Run Q# in Jupyter:

    import qsharp
    
    # Load and run Q# operations
    qsharp.eval("open Microsoft.Quantum.Canon;")
    result = qsharp.eval("operation SampleOperation() : Result { use q = Qubit(); H(q); return M(q); }")

πŸ“Š Example Usage and Output

Running the Book Generator

qsharp run QuantumBookGenerator.qs

Expected Output:

Quantum Book Generation Results:

Generated Book 1:
ID: 68f226aa98254bc1f6d51c000011
Title: "Midnight Investigation"
Genre: Mystery
ISBN: 9782413716715
Published: 2019
Description: A labyrinth of clues leading to an unexpected conclusion.
State: PUBLIC
Creator: stefano, Updater: alice

Generated Book 2:
ID: 68f226aa98254bc1f6d51c000001  
Title: "The Revolution"
Genre: Historical
ISBN: 9782822123766
Published: 1987
Description: History comes alive in this meticulously researched narrative.
State: PUBLIC
Creator: alice, Updater: giulio

...

Analyzing Generated Data

# Count books by genre
cat genbooks.json | grep -o '"genre":"[^"]*"' | sort | uniq -c

# Expected output:
#      16 "genre":"Biography"
#       3 "genre":"Fantasy"  
#       9 "genre":"Fiction"
#       4 "genre":"Historical"
#       2 "genre":"Mystery"
#       1 "genre":"Romance"
#       5 "genre":"Science Fiction"
#      10 "genre":"Thriller"

Verifying Quantum Correlations

The quantum generator creates natural correlations:

  • Genre-Title Correlation: Fantasy books have fantasy-themed titles
  • Creator-Updater Patterns: 50% same person, 50% different (quantum entanglement)
  • Year Distribution: Realistic publication year spread across 124 years
  • State Distribution: Realistic PUBLIC/DRAFT/PRIVATE ratios

πŸ”§ Configuration and Customization

Modifying Generation Parameters

  1. Edit QuantumBookGenerator.qs to change:

    • Number of books generated
    • Genre probability weights
    • Title correlations
    • User assignment patterns
  2. Sample Customization:

    // Change genre weights in GenerateQuantumGenre()
    let genreWeights = [0.30, 0.15, 0.15, 0.10, 0.10, 0.10, 0.05, 0.05];
    //                  Fiction^                                        Biography^

Using Custom Input Data

  1. Create your own books.json:

    [
      {
        "_id": "example_id",
        "title": "Example Book",
        "genre": "Fiction",
        "publishedYear": 2023,
        "isbn": "9781234567890",
        "description": "An example book description",
        "__STATE__": "PUBLIC",
        "creatorId": "user1",
        "updaterId": "user2"
      }
    ]
  2. Reference the structure in your quantum generator for consistent output format

πŸ› οΈ Troubleshooting

Common Issues and Solutions

Q# Extension Not Working

# Reload VS Code window
Ctrl+Shift+P β†’ "Developer: Reload Window"

# Or restart VS Code completely

Compilation Errors

# Check Q# syntax - common issues:
# - Missing semicolons
# - Incorrect namespace imports
# - Wrong operation signatures

# Verify all required imports:
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Measurement;

Jupyter Notebook Issues

# Reinstall Q# packages
pip3 uninstall qsharp qsharp-widgets
pip3 install qsharp qsharp-widgets

# Start fresh Jupyter kernel
jupyter notebook --kernel-gateway

Program Not Producing Output

# Ensure you have a @EntryPoint() operation or Main operation
@EntryPoint()
operation Main() : Unit {
    // Your quantum operations here
}

Getting Help

  1. Check the detailed technical explanation:

    # Read the comprehensive how-it-works guide
    cat HOWITWORK.md
  2. Quantum Development Kit Documentation:

  3. Community Resources:

πŸ“ˆ Performance and Validation

Verifying Output Quality

  1. Check statistical distributions:

    # Analyze genre distribution
    python3 -c "
    import json
    with open('genbooks.json') as f:
        books = json.load(f)
    genres = [book['genre'] for book in books]
    from collections import Counter
    print(Counter(genres))
    "
  2. Validate correlations:

    # Check title-genre correlations
    python3 -c "
    import json
    with open('genbooks.json') as f:
        books = json.load(f)
    fantasy_books = [book for book in books if book['genre'] == 'Fantasy']
    print('Fantasy titles:', [book['title'] for book in fantasy_books])
    "

Performance Benchmarks

  • Single Book Generation: ~100ΞΌs (quantum simulation overhead)
  • 50 Books Batch: ~50ms total
  • Memory Usage: Minimal (quantum state vectors)
  • Correlation Quality: High (natural quantum entanglement)

🎯 Next Steps

Learning Path

  1. Start with basic generators β†’ Understand quantum superposition
  2. Explore advanced features β†’ Learn quantum entanglement applications
  3. Read HOWITWORK.md β†’ Deep dive into quantum algorithms
  4. Experiment with parameters β†’ Customize for your use cases
  5. Extend the system β†’ Add new data types and quantum features

Advanced Usage

  • Create custom quantum data generators for different domains
  • Integrate with classical machine learning pipelines
  • Explore quantum machine learning applications
  • Develop quantum-secured data generation systems

πŸ“š Educational Resources

🀝 Contributing

Contributions welcome! Areas for improvement:

  • New quantum algorithms for data generation
  • Additional data types and domains
  • Performance optimizations
  • Educational content and examples
  • Integration with quantum hardware

πŸ“„ License

This project is open source - see the LICENSE file for details.


This quantum book generation system demonstrates practical applications of quantum computing in synthetic data generation, showcasing how quantum properties create advantages over classical approaches while providing hands-on learning opportunities for quantum programming.

About

The aim of this repo is to test q# for generating synthetic data. It is just an experiment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published