Skip to main content

Generate high-quality synthetic multi-turn chat datasets with Gemini

Project description

SynthLab — Synthetic conversations. Real impact.

PyPI GitHub stars Python License

SynthLab

SynthLab turns Gemini into a synthetic data engine for multi-turn chat datasets.

Describe any domain in a short brief. SynthLab designs the persona, invents realistic scenarios, generates conversations, and exports JSONL ready for fine-tuning, evaluation, or RAG-style instruction data.

Why SynthLab

  • Any domain — finance, support, healthcare intake, legal FAQ, sales, HR, education, coding copilots, and more
  • Any language or register — formal, casual, bilingual, technical; controlled entirely by your brief
  • Plan → generate — Gemini proposes scenarios, then fills assistant turns as the teacher model
  • Fine-tuning ready — standard system / user / assistant message format
  • CLI + Python API — ship in CI or script custom pipelines

Use cases

Area Example briefs
Customer support Order tracking, returns, billing disputes, product troubleshooting
Finance & banking Card blocks, transfers, loans, KYC, fraud triage, personal finance coaching
Insurance Claims intake, policy questions, coverage explanations
Healthcare Appointment booking, symptom intake (non-diagnostic), insurance eligibility
Legal / compliance FAQ-style guidance, document checklist flows (not legal advice)
Sales & success Discovery calls, objection handling, onboarding walkthroughs
HR & internal ops PTO policy, IT helpdesk, expense reports
Education Tutors, exam prep, language practice, Socratic teaching
Developer tools API helpers, debugging assistants, code-review chat
Local / multilingual Any locale or dialect mix you specify in the brief

The package does not ship domain presets. Quality and scope come from how precise your --brief is.

Features

  • Scenario planning — Gemini invents varied multi-turn user skeletons from one brief
  • Persona synthesis — system prompts generated or supplied by you
  • Short chat realism — configurable turn depth (default: 3 user / 3 assistant)
  • Temporary sessions — generation avoids polluting your Gemini history
  • Preview & stats — inspect samples before training
  • JSONL export — one sample per line for common fine-tuning loaders

Installation

pip install -U synthlab

Optional browser cookie import:

pip install -U "synthlab[browser]"

Requires Python 3.10+.

Authentication

SynthLab uses a Gemini web session.

  1. Open https://gemini.google.com and sign in
  2. DevTools → Network → refresh → copy:
    • __Secure-1PSID (required)
    • __Secure-1PSIDTS (if present)
  3. Save as cookies.json:
{
  "__Secure-1PSID": "value...",
  "__Secure-1PSIDTS": "value..."
}

Environment variables: SYNTHLAB_SECURE_1PSID, SYNTHLAB_SECURE_1PSIDTS.
For containers / long-running jobs, set SYNTHLAB_COOKIE_PATH to persist refreshed cookies.

Quickstart

synthlab auth check --cookies-json cookies.json
synthlab init

synthlab plan --cookies-json cookies.json \
  --brief "Retail banking assistant. Topics: cards, transfers, fraud alerts. Concise, professional, multilingual-ready. Ask one clarifying question when needed." \
  --count 10 --turns 3

synthlab generate --cookies-json cookies.json --out data/dataset.jsonl
synthlab preview --n 2
synthlab stats

Swap the brief for any vertical — same commands.

CLI reference

Global options (before the subcommand):

--cookies-json PATH   Cookie file
--proxy URL           HTTP(S) proxy
--verbose             Debug logs
--timeout SEC         Request timeout (default 90)
Command Description
synthlab init Create synthlab.yaml and data/
synthlab auth check Validate the Gemini session
synthlab persona new Set persona via --prompt or --from-brief
synthlab plan Invent scenarios from --brief
synthlab generate Run the plan and append JSONL
synthlab preview Print the last N samples
synthlab stats Sample counts by style and turn length
synthlab ask One-shot Gemini prompt (debugging)

Python API

import asyncio
from synthlab import GeminiClient, SynthPipeline

async def main():
    client = GeminiClient("YOUR_1PSID", "YOUR_1PSIDTS")
    await client.init()

    pipeline = SynthPipeline(client)
    pack = await pipeline.plan(
        brief=(
            "B2B SaaS onboarding specialist. Help new admins configure SSO, "
            "invites, and billing. Short multi-turn, clear next steps."
        ),
        count=5,
        turns=3,
    )
    samples = await pipeline.generate(pack)
    for sample in samples:
        print(sample.id, len(sample.messages))

    await client.close()

asyncio.run(main())

Output format

Each JSONL line:

{
  "id": "sso_setup",
  "style": "professional",
  "messages": [
    {"role": "system", "content": "..."},
    {"role": "user", "content": "..."},
    {"role": "assistant", "content": "..."}
  ],
  "meta": {
    "created_at": "2026-07-14T00:00:00+00:00",
    "persona": "onboarding_specialist"
  }
}

Project layout after init

synthlab.yaml      # persona + scenario plan
data/
  dataset.jsonl    # generated samples
cookies.json       # secrets (gitignored)

Writing strong briefs

Good briefs usually specify:

  1. Role — who the assistant is
  2. Scope — topics in / out of bounds
  3. Tone & language — formal, casual, bilingual, technical
  4. Behavior — reply length, when to ask questions, safety limits
  5. Variation — styles of users (angry, confused, expert, first-time)

Example:

You are a claims intake assistant for a P&C insurer.
Handle FNOL, document requests, and status checks only.
Professional English, 1–3 short sentences per turn.
Never invent claim IDs or coverage decisions.
Vary user styles: calm, frustrated, elderly, broker-assisted.

Tips

  • Prefer short turns (--turns 3) for naturalistic chat data
  • Use a dedicated browser session for cookies when possible
  • Always preview a few samples before training
  • Increase --count iteratively; review quality before large runs

License

AGPL-3.0 — see LICENSE.

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

synthlab-0.1.6.tar.gz (485.9 kB view details)

Uploaded Source

Built Distribution

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

synthlab-0.1.6-py3-none-any.whl (97.0 kB view details)

Uploaded Python 3

File details

Details for the file synthlab-0.1.6.tar.gz.

File metadata

  • Download URL: synthlab-0.1.6.tar.gz
  • Upload date:
  • Size: 485.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for synthlab-0.1.6.tar.gz
Algorithm Hash digest
SHA256 6ff4c9a4a325f77aac8cd1ee033bec26024574469139fa160d3de65060fe4ee1
MD5 2dd78b83dcd2520f21133e78dca5df56
BLAKE2b-256 4637709bcb230fadba6b5d9c9cfd1db2ae520322871853b84295e1b2a04c6490

See more details on using hashes here.

File details

Details for the file synthlab-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: synthlab-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 97.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for synthlab-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0d3dd35c6150aa06f7e443e7c1bc85b5735c189a053032ffd7b08711de156fa0
MD5 bc2c227ab6c6ad2f0cbfefbb76689923
BLAKE2b-256 8c7450e62b1411b0d86131aa1d5b50c8b854a4b0727891c604f8eed184188667

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