gitmyhub

ntkmirror

Python ★ 342 updated 10d ago

A Python library that teaches an AI language model new behaviors by learning a tiny set of scaling values, no rewriting the model, no extra modules, runs in minutes on a regular laptop, and lets you combine multiple trained behaviors together.

Pythonpipsetup: easy

NTK-Mirror is a Python tool for adapting AI language models to specific tasks without modifying the model itself. Most fine-tuning approaches require either rewriting the model's internal weights or attaching extra modules called LoRA adapters. This library takes a different approach: it learns a small set of scaling values, called a controller, that sit on top of the frozen model and adjust how it processes information during a forward pass. The model file stays unchanged; only the controller is saved and loaded.

The practical workflow is straightforward. You prepare a set of training examples in a simple text file, each with a prompt and the expected completion. You then run a command to fit a controller on those examples. Once trained, you can attach the controller when generating text, and the model will behave differently than it would without it. The entire adaptation can run in minutes on consumer hardware rather than requiring the large compute budgets that full fine-tuning typically needs.

One notable feature is controller composition. Because the scaling values are stored as signed numbers in a particular mathematical coordinate system, you can add two controllers together to combine their effects. For example, if you trained one controller on math problems and another on code generation, you can merge them into a single controller that nudges the model toward both behaviors at once.

The library also includes a persistent memory system. You can store individual controllers as named memory items, tag them, and then retrieve the most relevant ones at generation time based on a text query. This lets the model draw on stored task knowledge without needing to put that knowledge into the prompt text.

NTK-Mirror is released under the MIT license and is available as a standard Python package installable with pip.

Where it fits