Skip to main content

Create synthetic datasets with LLM generators and samplers

Project description

Chatan

Create diverse, synthetic datasets. Start from scratch or augment an existing dataset. Simply define your dataset schema as a set of generators, typically being LLMs with a prompt describing what kind of examples you want.

Installation

Basic installation (includes OpenAI, Anthropic, and core functionality):

pip install chatan

With optional features:

# For local model support (transformers + PyTorch)
pip install chatan[local]

# For advanced evaluation features (semantic similarity, BLEU score)
pip install chatan[eval]

# For all optional features
pip install chatan[all]

Getting Started

import chatan

# Create a generator
gen = chatan.generator("openai", "YOUR_API_KEY")

# Define a dataset schema
ds = chatan.dataset({
    "topic": chatan.sample.choice(["Python", "JavaScript", "Rust"]),
    "prompt": gen("write a programming question about {topic}"),
    "response": gen("answer this question: {prompt}")
})

# Generate the data with a progress bar
df = ds.generate(n=10)

Generator Options

API-based Generators (included in base install)

# OpenAI
gen = chatan.generator("openai", "YOUR_OPENAI_API_KEY")

# Anthropic
gen = chatan.generator("anthropic", "YOUR_ANTHROPIC_API_KEY")

Local Model Support (requires pip install chatan[local])

# HuggingFace Transformers
gen = chatan.generator("transformers", model="microsoft/DialoGPT-medium")

Examples

Create Data Mixes

from chatan import dataset, generator, sample
import uuid

gen = generator("openai", "YOUR_API_KEY")

mix = [
    "san antonio, tx",
    "marfa, tx",
    "paris, fr"
]

ds = dataset({
    "id": sample.uuid(),
    "topic": sample.choice(mix),
    "prompt": gen("write an example question about the history of {topic}"),
    "response": gen("respond to: {prompt}"),
})

Augment datasets

from chatan import generator, dataset, sample
from datasets import load_dataset

gen = generator("openai", "YOUR_API_KEY")
hf_data = load_dataset("some/dataset")

ds = dataset({
    "original_prompt": sample.from_dataset(hf_data, "prompt"),
    "variation": gen("rewrite this prompt: {original_prompt}"),
    "response": gen("respond to: {variation}")
})

Evaluation

Evaluate rows inline or compute aggregate metrics:

from chatan import dataset, eval, sample

ds = dataset({
    "col1": sample.choice(["a", "a", "b"]),
    "col2": "b",
    "score": eval.exact_match("col1", "col2")
})

df = ds.generate()
aggregate = ds.evaluate({
    "exact_match": ds.eval.exact_match("col1", "col2")
})

Advanced Evaluation (requires pip install chatan[eval])

# Semantic similarity using sentence transformers
aggregate = ds.evaluate({
    "semantic_sim": ds.eval.semantic_similarity("col1", "col2")
})

# BLEU score evaluation
aggregate = ds.evaluate({
    "bleu": ds.eval.bleu_score("col1", "col2")
})

Installation Options Summary

Feature Install Command What's Included
Basic pip install chatan OpenAI, Anthropic, core sampling, basic evaluation
Local Models pip install chatan[local] + HuggingFace Transformers, PyTorch
Advanced Eval pip install chatan[eval] + Semantic similarity, BLEU scores, NLTK
Everything pip install chatan[all] All features above

Citation

If you use this code in your research, please cite:

@software{reetz2025chatan,
  author = {Reetz, Christian},
  title = {chatan: Create synthetic datasets with LLM generators.},
  url = {https://github.com/cdreetz/chatan},
  year = {2025}
}

Contributing

Community contributions are more than welcome, bug reports, bug fixes, feature requests, feature additions, please refer to the Issues tab.

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

chatan-0.2.0.tar.gz (268.7 kB view details)

Uploaded Source

Built Distribution

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

chatan-0.2.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file chatan-0.2.0.tar.gz.

File metadata

  • Download URL: chatan-0.2.0.tar.gz
  • Upload date:
  • Size: 268.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for chatan-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d894d9a3da1acd9ac820b038ba2e039fc2af59c108192cb02582258901deeb45
MD5 4e67622b32890708418e51079575c330
BLAKE2b-256 8abef6b1d2aa8f43662013db018e3c51f9d60092581044ab00b6d9bb814e6860

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatan-0.2.0.tar.gz:

Publisher: publish.yml on cdreetz/chatan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatan-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: chatan-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for chatan-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66e2ea442970f5fc2086a3e694939caeaab25794cf2a1c08aa8412ddb8b9add5
MD5 d41e083f8beef9ea03cb1d316ca3e3df
BLAKE2b-256 2edff187f222be160d97f751c829f838c65c23261acaf461895ed3fd4c2466d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatan-0.2.0-py3-none-any.whl:

Publisher: publish.yml on cdreetz/chatan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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