Skip to main content

Distill-Align

Python 3.11+ License: MIT CI PyPI version Security

Distill-Align: The Structured Reasoning Extraction Factory

A CLI/Python framework that automates the generation of high-quality, fine-tuning datasets from raw domain data. It utilizes high-context frontier reasoning models as teachers, captures their deep thinking traces, and filters/prunes those traces into highly structured instruction-following formats optimized for fine-tuning.

🌐 العربية: README.ar.md — الترجمة العربية لهذا الدليل.

Features

  • Smart Ingestion: Async chunking pipelines with semantic-aware splitting for Markdown and Code (PDF, DOCX, HTML, CSV, JSON, Jupyter notebooks, and web pages also supported).
  • Multi-Provider Synthesis: Supports OpenAI, Ollama, vLLM, Anthropic Claude, Google Gemini, and Azure OpenAI backends with async worker pools.
  • Socratic Transformer: Converts raw reasoning into structured, multi-turn conversational Q&A.
  • Scaffold Action Pruner: Strips conversational filler to extract pure tool-calling or structural output.
  • LLM-as-Judge Evaluation (optional): Automated quality scoring of generated conversations using a separate judge model, with confidence scores normalized 0–1.
  • Preference (DPO) Generation: Create preference pairs from judge-scored conversations for Direct Preference Optimization training.
  • Multiple Export Formats: ShareGPT, Alpaca, ChatML, HuggingFace messages (JSONL/JSON), streaming JSON Lines, and Apache Parquet.
  • Streaming Export: Export large datasets without loading them entirely into memory using iterative producers.
  • Cost Tracking: Pay-as-you-go cost estimation and tracking across all providers with per-request token accounting.
  • Unsloth Integration: Auto-generates optimized train.py scripts for Unsloth fine-tuning.
  • Rich TUI: Interactive terminal dashboard for monitoring pipeline execution.

Installation

pip install distill-align

# With optional dependencies
pip install distill-align[parquet]   # Parquet export support
pip install distill-align[hub]       # HuggingFace Hub integration
pip install distill-align[all]       # All extras

Quick Start

# Ingest and process data
distill-align ingest --source ./my-docs --output ./chunks.json

# Synthesize conversations (with judge evaluation)
distill-align synthesize \
    --input ./chunks.json \
    --output ./conversations.json \
    --provider openai \
    --model gpt-4o \
    --judge \
    --judge-model gpt-4o-mini

# Export to training format
distill-align export \
    --input ./conversations.json \
    --format hf_messages \
    --output ./dataset

# Generate preference pairs for DPO training
distill-align export \
    --input ./conversations.json \
    --format preference \
    --output ./dpo-pairs

# Launch TUI
distill-align tui

Supported Providers

Provider SDK-Free Structured Output Auth
OpenAI ✓ ✓ API key
Anthropic ✓ ✓ (JSON mode) API key
Google Gemini ✓ ✓ (MIME type) API key
Azure OpenAI ✓ ✓ API key or Entra ID (OAuth2)
Ollama ✓ — None (local)
vLLM ✓ ✓ (OpenAI compat) None / API key

Export Formats

Format Extension Description
hf_messages .jsonl HuggingFace messages format (JSONL recommended)
jsonl .jsonl Generic JSON Lines (streaming-capable)
parquet .parquet Columnar format (requires pyarrow)
sharegpt .json ShareGPT conversation format
alpaca .json Alpaca instruction format
chatml .json ChatML markup format
conversation .json Raw conversation schema export
preference .json DPO preference pairs (requires judge scores)

Project Structure

This project follows a Modular Monolith architecture.

distill-align/
├── src/distill_align/    # Core application package
│   ├── core/             # Config, schemas, logging, caching, checkpointing
│   ├── ingestion/        # Data loaders and chunkers (PDF, DOCX, HTML, code, etc.)
│   ├── synthesis/        # LLM clients, worker pool, prompts, judge, cost tracking
│   │   └── models/       # Provider-specific clients (OpenAI, Anthropic, Gemini, Azure, Ollama, vLLM)
│   ├── exporter/         # Formatters, validator, splitter, preference generator
│   │   └── formatters/   # Output format converters (JSONL, Parquet, ShareGPT, Alpaca, etc.)
│   ├── tui/              # Textual terminal UI
│   └── cli/              # Typer CLI entry points
├── tests/                # Pytest suite
└── docs/                 # Documentation (MkDocs)

Development

  1. Clone the repository
  2. Install dependencies with Poetry: poetry install
  3. Install dev dependencies: poetry install --with dev
  4. Run tests: poetry run pytest
  5. Run linting: poetry run ruff check src/

License

MIT License - see LICENSE for details.

Metadata

Release files for distill-align 0.1.1

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

Source distribution (sdist)

Source distribution for distill-align 0.1.1
File Size Uploaded Provenance
distill_align-0.1.1.tar.gz 90.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for distill-align 0.1.1
File Interpreter ABI Platform
distill_align-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 222.1 kB

Release files / distill_align-0.1.1.tar.gz

Download URL distill_align-0.1.1.tar.gz
Size 90.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8ed492b759e9a9c23b70d165df1f75c5b2a75a0ecc5760341aa57a30473e7ed6
BLAKE2b-256 checksum
How to use checksums
8f7e50dcfd4c0087caa509cdd090ef2dc36688d23ec2c986e8724238926714b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.

Transparency log

Release files / distill_align-0.1.1-py3-none-any.whl

Download URL distill_align-0.1.1-py3-none-any.whl
Size 131.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
715a05764b53ec8517f49cb740d34b1685f2b4e49eb0879695e4fcd53e381882
BLAKE2b-256 checksum
How to use checksums
d2ec8a1050cc4327c8877945446c193af66c546d37b6df231c2520ccaffcafc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.

Transparency log

Security for distill-align 0.1.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for distill_align-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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