Skip to main content

Universal knowledge distillation toolkit for text, code, vision, and multimodal models

Project description

Zynthé 🧠 ⚡

ZynthéFrom "Synthesize". Knowledge distillation is the process of synthesizing knowledge from a massive, complex model down into a smaller, more focused one.

Universal Knowledge Distillation Toolkit
A Python library for compressing large language models into smaller, deployable student models — across text, code, vision, and multimodal architectures.

PyPI version License: MIT Python 3.10+ CI codecov Docs

Large transformer models (BERT-110M, GPT-2-124M, ViT-86M) deliver state-of-the-art accuracy but are often too expensive for edge deployment, mobile inference, and cost-sensitive production. Zynthé solves this by training a smaller "student" model to replicate the behavior of a larger "teacher" model using a unified, multi-stage distillation pipeline.


🌟 Key Features

  • Modality Agnostic: Works out-of-the-box with Text, Code, Vision, VLM, and Multimodal models via an auto-detecting AdapterRegistry.
  • Multi-Stage Distillation: Supports sequential distillation stages:
    • Logit Distillation (KD Hinton)
    • Feature Alignment (Hidden representations)
    • Attention Transfer (Attention patterns)
    • Structural Similarity (Cross-layer relationships)
  • Zero-Config Presets: 7 battle-tested distillation plans (quick_start, balanced, compression_max, etc.).
  • Preflight Analysis: Validates configurations, hardware compatibility, and estimates memory before training starts.
  • Post-Training Quantization (PTQ): Further compress your distilled models to INT8.
  • Rich Visualization: Auto-generates training curves, distillation gap plots, and metric grids.

📦 Installation

Install Zynthé via pip:

# Core installation
pip install zynthe

# With evaluation and plotting dependencies
pip install zynthe[eval]

# For computer vision support
pip install zynthe[vision]

🚀 Quickstart

Zynthé makes complex multi-stage distillation as simple as 5 lines of code:

Zynthé Typing Demo

Basic Usage

from zynthe import DistillationToolkit
from transformers import AutoModelForSequenceClassification

# 1. Load your models
teacher = AutoModelForSequenceClassification.from_pretrained("textattack/bert-base-uncased-SST-2").cuda()
student = AutoModelForSequenceClassification.from_pretrained("google/bert_uncased_L-4_H-256_A-4").cuda()

# 2. Initialize the Toolkit
toolkit = DistillationToolkit(teacher, student, device="cuda")

# 3. Create a balanced multi-stage distillation plan
plan = toolkit.build_plan(goal="balanced")

# 4. Run Distillation
report = toolkit.run(plan, train_loader, val_loader, output_dir="./zynthe_output")

📊 Example Results

BERT-base (110M) → DistilBERT (66M) on SST-2 (Single NVIDIA T4)

Metric Teacher Student Distilled Student
Accuracy 92.1% ~81.5% (scratch) 86.8%
Model Size 418 MB 255 MB 255 MB
Quantized (PTQ) - - 64 MB (6.5x smaller)

🛠️ Architecture

Zynthé uses a modular, plugin-based architecture:

  • DistillationToolkit: The primary user-facing facade.
  • AdapterRegistry: Automatically normalizes I/O across HuggingFace architectures.
  • PipelineBuilder: Constructs deterministic, multi-stage training plans.
  • PreflightAnalyzer: Catches OOMs and shape mismatches before training.
  • Evaluator & ModelComparator: Side-by-side student vs. teacher analysis.

📚 Documentation


📄 License

This project is licensed under the MIT License.

You are free to use, modify, distribute, and use this software for commercial purposes. See the LICENSE file for the full text.

Note: Models distilled using Zynthé inherit the license of their respective teacher models and datasets. Please ensure you comply with the licensing terms of the models you are distilling.

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

zynthe-0.2.6.tar.gz (300.9 kB view details)

Uploaded Source

Built Distribution

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

zynthe-0.2.6-py3-none-any.whl (342.3 kB view details)

Uploaded Python 3

File details

Details for the file zynthe-0.2.6.tar.gz.

File metadata

  • Download URL: zynthe-0.2.6.tar.gz
  • Upload date:
  • Size: 300.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for zynthe-0.2.6.tar.gz
Algorithm Hash digest
SHA256 d0db9fc89c13596a1afa9d870c3bb5f9c4850232e2e141602a5cbc0540dbed2f
MD5 2c299411d0ae6add93566d76be64acc9
BLAKE2b-256 b9e046e15714465f88352d5d985ff6f978c437238d59f2a08fcd124f0935c5d5

See more details on using hashes here.

File details

Details for the file zynthe-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: zynthe-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 342.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for zynthe-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 afd3f2518ae033d4c2020fdf5a86b765354284ae345f980f405026b9ecf1847e
MD5 1978c8bce0afe5a78396df7b3c41cb5d
BLAKE2b-256 45c7dcb231545512de2021d54f54e830b6b09e84792c475f24d8ebfa3657aa0e

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