Skip to main content

Add your description here

Project description

Mimic-Kit

Python 3.13+ License: MIT

中文文档 | English

Mimic-Kit is a black-box knowledge distillation scaffolding that helps you distill capabilities from powerful teacher models into smaller, more efficient student models.

Features

  • 🤖 Teacher Model Generation: Use OpenAI API (or compatible APIs) to generate high-quality training data
  • 🚀 Efficient Training: Built on ms-swift for streamlined model training
  • 🧩 Flexible Tuning: Support both LoRA (parameter-efficient) and full fine-tuning
  • Performance Optimized: Integrated with DeepSpeed and Liger Kernel for accelerated training
  • 💾 Smart Caching: Automatically cache API responses to save costs
  • 📊 Multiple Data Formats: Support both chat and text completion formats

Quick Start

1. Installation

# Clone the repository
git clone <repository-url>
cd mimic-kit

# Install dependencies using UV
uv sync

# Or with dev dependencies
uv sync --group dev

2. Initialize Configuration

uv run mimic init

This creates a config.yaml template. Edit it to configure your teacher model, student model, and training parameters.

3. Prepare Your Data

Create a JSONL file with your prompts. Supports two formats:

Chat Format:

{"messages": [{"role": "user", "content": "Explain Python decorators"}]}
{"messages": [{"role": "user", "content": "How to reverse a linked list?"}]}

Text Completion Format:

{"text": "Python decorators are a powerful feature..."}
{"text": "To reverse a linked list, you need to..."}

4. Generate Training Data

uv run mimic generate

This sends your prompts to the teacher model and saves the generated responses as training data.

5. Train Your Student Model

uv run mimic train

The student model will be fine-tuned on the generated data using the configured method (LoRA or full fine-tuning).

Configuration

See config.yaml for all available options. Key sections:

  • data: Input/output paths, system prompts, templates
  • teacher: API provider, model, generation parameters
  • student: Base model, tuning method, hyperparameters
  • training: Batch size, learning rate, saving strategy

Project Structure

mimic-kit/
├── mimic/
│   ├── cli.py              # CLI entry point
│   ├── config.py           # Configuration models (Pydantic v2)
│   ├── generator/          # Teacher model data generation
│   └── trainer/            # Student model training (ms-swift)
├── data/                   # Training data directory
├── config.yaml             # Your configuration file
└── output/                 # Model outputs and checkpoints

Requirements

  • Python 3.13+
  • CUDA-capable GPU (for training)
  • OpenAI API key (or compatible API)

Development

# Run tests
uv run pytest

# Run single test
uv run pytest tests/test_cli.py::test_function

# Format code
uv run ruff format .

# Check linting
uv run ruff check .

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Built with ms-swift for model training
  • Uses Pydantic for configuration validation
  • Powered by Click for CLI

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

mimic_kit-0.1.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

mimic_kit-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file mimic_kit-0.1.0.tar.gz.

File metadata

  • Download URL: mimic_kit-0.1.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mimic_kit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc8b55150ed25198d5a6392db446e381feb404e89a4fedd715d946316de3ac02
MD5 28bf799e32244e93bc387431466b2ee2
BLAKE2b-256 245f7f8aa2c5553353dbd358668e44efe91746273247254b92dd34dc5d0c5b91

See more details on using hashes here.

File details

Details for the file mimic_kit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mimic_kit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mimic_kit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4fb6c4287f4d879ac193aa258e8d0ec697057836333c19ddabf9edadb939131e
MD5 b6b532821f00b4549d17b18a22a194af
BLAKE2b-256 ca9ed26716a3164e2f00d4812e9a0a99fa3fee568fe607ded4aa5768368fdeac

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