Skip to main content

Kushim: A Framework for Verifiable, Self-Optimizing LLM Evaluation Datasets

Kushim is a framework for generating high-quality, verifiable Question & Answer datasets. In an era of generative models, creating reliable evaluation data is one of the biggest challenges. Kushim addresses this by providing an end-to-end workflow built on two core principles: verifiability by design and self-optimizing quality.

It's not just about generating data; it's about generating trustworthy data that gets better on its own.

Kushim Illustration

The Kushim Philosophy: Core Concepts

1. Verifiable by Design

The biggest risk with synthetic data is factual inconsistency. Kushim is built to mitigate this risk. Every single question-answer pair generated by the pipeline is subjected to a strict validation step. An LLM-based validator checks if the generated answer is factually and unambiguously supported by the original source text. If a pair fails this check, it's discarded.

This ensures that your final dataset isn't just a collection of plausible-sounding questions, but a set of verifiable facts grounded in a source of truth.

2. Self-Optimizing Quality with DSPy

A static, one-size-fits-all prompt is not optimal. The best way to phrase a question depends on the source material. Kushim leverages the power of DSPy to create a self-improving pipeline.

Instead of just running a prompt, Kushim can "compile" it. It uses DSPy's optimizers (teleprompters) to:

  1. Generate a small training set from your source documents.
  2. Test multiple variations of prompts to see which ones produce the highest-quality, most verifiable Q&A pairs for your specific data.
  3. Save this "compiled" program, which contains the optimized, high-performance prompts.

This means Kushim learns from your data to improve its own performance, leading to a significantly higher-quality final dataset.

How It Works: The Kushim Pipeline Workflow

The Kushim pipeline integrates these concepts into an efficient, streaming workflow that proceeds in the following stages:

  1. Source & Fetch: The process begins by fetching raw documents from a designated Source, such as a Wikipedia article or a local file directory.

  2. Chunking: The fetched documents are broken down into smaller, manageable text chunks. This is a standard practice in RAG-style pipelines and prepares the data for the generation models.

  3. Self-Optimization (A One-Time "Compile" Step): This is the heart of Kushim's quality assurance process. Instead of using a static prompt, the pipeline:

    • Generates a Training Set: It takes a small sample of the chunks to create a temporary training set.
    • Optimizes Prompts: It uses DSPy to test multiple prompt variations, identifying the one that produces the highest-quality, most verifiable Q&A pairs for your specific data.
    • This "compiled" program, containing the optimized prompts, is saved and used for the main generation task.
  4. Generation: Using the high-performance prompts from the compilation step, the pipeline generates question-answer pairs from all of the text chunks.

  5. Validation & Filtering: Each generated Q&A pair is rigorously validated. An LLM checks if the answer is factually supported by its original source chunk. Pairs that pass validation proceed to the final dataset; those that fail are discarded.

This multi-stage process ensures that the final output is not only relevant but also verifiable and of the highest possible quality.

Getting Started

After installing Kushim (uv add kushim or pip install kushim), you can use its core components directly. The key is to instantiate the pipeline and run it. The optimization is handled for you—the first run compiles and saves the best prompts, and subsequent runs are fast.

# A conceptual example of using the Kushim pipeline
from kushim import pipeline, config, source

# 1. Choose your source and model
data_source = source.WikipediaSource()
pipeline_config = config.KushimConfig(
    model_name="openrouter/openai/gpt-4.1",
    fetch_kwargs={"mode": "search", "query": "History of coffee"}
)

# 2. Instantiate the pipeline
kushim_pipeline = pipeline.KushimPipeline(
    source=data_source,
    config=pipeline_config
)

# 3. Run it!
# This will automatically handle compiling and saving the optimized
# generator to a .json file for you on the first run.
validated_dataset, _ = kushim_pipeline.run(
    optimize=True,
    compiled_generator_path="compiled_coffee_generator.json"
)

print(validated_dataset)

For complete, runnable scripts demonstrating the full dataset creation lifecycle (merging, encryption, and pushing to the Hugging Face Hub), please see the examples/ directory in the GitHub repository.

Metadata

Release files for kushim 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kushim 0.0.3
File Size Uploaded Provenance
kushim-0.0.3.tar.gz 255.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kushim 0.0.3
File Interpreter ABI Platform
kushim-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 280.9 kB

Release files / kushim-0.0.3.tar.gz

Download URL kushim-0.0.3.tar.gz
Size 255.0 kB
Tags Source
SHA-256 checksum
How to use checksums
22d042fc93665e20f366344c05760b3c491754ebfa4ef03db14b01aeb013c49f
BLAKE2b-256 checksum
How to use checksums
11097e4eaa43b5bea78e5826ec35c3cd2af06ed38ba38f4040cf2c77533d5f6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.4

Release files / kushim-0.0.3-py3-none-any.whl

Download URL kushim-0.0.3-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd0a0646d84ea6e9d2074ebfec2ffa7d2d57448cd4149ef5f1fe56822b2a4af2
BLAKE2b-256 checksum
How to use checksums
8b5e5c4d5f49303864ea816be03f2bde061dc3e55f6818d33199e0dc3fe59636
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.4

Security for kushim 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page