The Structured Reasoning Extraction Factory — Generate high-quality fine-tuning datasets from raw domain data
Project description
Distill-Align
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.pyscripts 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
- Clone the repository
- Install dependencies with Poetry:
poetry install - Install dev dependencies:
poetry install --with dev - Run tests:
poetry run pytest - Run linting:
poetry run ruff check src/
License
MIT License - see LICENSE for details.
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
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 distill_align-0.1.1.tar.gz.
File metadata
- Download URL: distill_align-0.1.1.tar.gz
- Upload date:
- Size: 90.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ed492b759e9a9c23b70d165df1f75c5b2a75a0ecc5760341aa57a30473e7ed6
|
|
| MD5 |
15f474fed36f48d379e625523fcb729b
|
|
| BLAKE2b-256 |
8f7e50dcfd4c0087caa509cdd090ef2dc36688d23ec2c986e8724238926714b2
|
Provenance
The following attestation bundles were made for distill_align-0.1.1.tar.gz:
Publisher:
release.yml on o69dn/Distill-Align
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
distill_align-0.1.1.tar.gz -
Subject digest:
8ed492b759e9a9c23b70d165df1f75c5b2a75a0ecc5760341aa57a30473e7ed6 - Sigstore transparency entry: 1864671264
- Sigstore integration time:
-
Permalink:
o69dn/Distill-Align@4fe7b841c483afcd64c954b1f39141e028b2fb3f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/o69dn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4fe7b841c483afcd64c954b1f39141e028b2fb3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file distill_align-0.1.1-py3-none-any.whl.
File metadata
- Download URL: distill_align-0.1.1-py3-none-any.whl
- Upload date:
- Size: 131.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
715a05764b53ec8517f49cb740d34b1685f2b4e49eb0879695e4fcd53e381882
|
|
| MD5 |
0d660d97e5adc62df7440955b5b19a01
|
|
| BLAKE2b-256 |
d2ec8a1050cc4327c8877945446c193af66c546d37b6df231c2520ccaffcafc5
|
Provenance
The following attestation bundles were made for distill_align-0.1.1-py3-none-any.whl:
Publisher:
release.yml on o69dn/Distill-Align
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
distill_align-0.1.1-py3-none-any.whl -
Subject digest:
715a05764b53ec8517f49cb740d34b1685f2b4e49eb0879695e4fcd53e381882 - Sigstore transparency entry: 1864671270
- Sigstore integration time:
-
Permalink:
o69dn/Distill-Align@4fe7b841c483afcd64c954b1f39141e028b2fb3f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/o69dn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4fe7b841c483afcd64c954b1f39141e028b2fb3f -
Trigger Event:
push
-
Statement type: