Production-grade synthetic data generation using LLMs with structured outputs, caching, checkpointing, and monitoring.
Project description
syndatalab
Production-grade synthetic data generation using LLMs with structured outputs, caching, checkpointing, and monitoring.
Installation
pip install syndatalab
# Install with specific provider support
pip install syndatalab[openai]
pip install syndatalab[anthropic]
pip install syndatalab[all] # all providers
pip install syndatalab[all,quality] # all providers + quality filters
Quick Start
import syndatalab as sd
from pydantic import BaseModel
class QAPair(BaseModel):
question: str
answer: str
class QAGenerator(sd.LLM):
response_format = QAPair
def prompt(self, input: dict) -> str:
return f"Generate a Q&A pair about {input['topic']}"
def parse(self, input: dict, response: QAPair) -> dict:
return {"topic": input["topic"], "q": response.question, "a": response.answer}
gen = QAGenerator(model="gpt-4o-mini")
result = gen(dataset=[{"topic": "python"}, {"topic": "rust"}])
print(result.dataset) # HuggingFace Dataset
print(result.stats) # Token usage, cost, performance
print(result.run_id) # Resume ID if interrupted
Features
- Multi-provider: OpenAI, Anthropic, LiteLLM, Ollama with automatic detection
- Provider failover: Automatic fallback chain across providers
- Structured outputs: Pydantic models with layered validation and auto-repair
- Checkpoint/resume: Crash recovery with deterministic run IDs
- Rate limiting: Dual token-bucket (RPM + TPM) with adaptive backoff
- Caching: SQLite-based with WAL mode, TTL, and atomic writes
- Quality filters: Deduplication, diversity scoring, custom filters
- TUI dashboard: Real-time progress, stats, cost tracking
- Audit trail: Per-request JSONL logging for debugging
- CLI tools: Cache management, run history, output inspection
Pipeline Chaining
gen1 = TopicGenerator(model="gpt-4o-mini")
gen2 = QAGenerator(model="gpt-4o-mini")
pipeline = gen1 | gen2
result = pipeline(dataset=[{"seed": "machine learning"}])
Quality Filtering
result = gen(
dataset=inputs,
filters=[
sd.filters.min_length("answer", 50),
sd.filters.no_duplicates("answer", threshold=0.85),
sd.filters.custom(lambda row: "I cannot" not in row["answer"]),
],
)
CLI
syndatalab cache stats
syndatalab cache clear
syndatalab history
syndatalab inspect <run_id>
Configuration
Create ~/.syndatalab/config.toml:
[defaults]
model = "gpt-4o-mini"
max_retries = 3
max_concurrent_requests = 50
show_dashboard = true
[rate_limits]
max_requests_per_minute = 500
max_tokens_per_minute = 200000
[logging]
level = "INFO"
License
MIT
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
syndatalab-0.1.0.tar.gz
(751.1 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 syndatalab-0.1.0.tar.gz.
File metadata
- Download URL: syndatalab-0.1.0.tar.gz
- Upload date:
- Size: 751.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93a5ed6d5c7f5a4d51503caeeb73d9dfe592c4659bb039379ea3db9f0f145e5b
|
|
| MD5 |
813a09301dffb9bed9e8da4cdc3c07c6
|
|
| BLAKE2b-256 |
91c625acd753771eb5085735260910fd7e492ceb0ba08f5540f3c52f469fc167
|
File details
Details for the file syndatalab-0.1.0-py3-none-any.whl.
File metadata
- Download URL: syndatalab-0.1.0-py3-none-any.whl
- Upload date:
- Size: 46.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ec4196f8f47333854e73bb009d47139e54e217852a66d334b712295502842a7
|
|
| MD5 |
ff3229bc615f1135238d2e9c3ed30e2d
|
|
| BLAKE2b-256 |
17e511bd62aac0da41c6dcc7ee34bd5bf1c5aa1eeb85a74578488d0f9b42b651
|