explaingit

leochlon/ntkmirror

18PythonAudience · developerLicenseSetup · easy

TLDR

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.

Mindmap

mindmap
  root((NTK-Mirror))
    What it does
      Task adaptation
      No model changes
      Controller only
    How to use
      Prepare text examples
      Train a controller
      Attach at generation
    Key features
      Controller composition
      Persistent memory
      Query-based retrieval
    Advantages
      Consumer hardware
      Minutes to train
      MIT license
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Adapt a large language model to answer math questions in a specific style by training a controller on a few examples, no GPU cluster needed.

USE CASE 2

Combine a code-generation controller with a concise-writing controller to nudge a model toward both behaviors at the same time.

USE CASE 3

Store multiple trained task controllers as named memory items and retrieve the right one at generation time based on a text query.

USE CASE 4

Fine-tune a frozen model for a client-specific task and ship only the tiny controller file instead of a full model copy.

Tech stack

Pythonpip

Getting it running

Difficulty · easy Time to first run · 30min

Installable via pip, training runs on consumer hardware in minutes with a simple text file of prompt-completion pairs.

In plain English

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.

Copy-paste prompts

Prompt 1
Walk me through training an NTK-Mirror controller on my own prompt-completion examples and using it to generate text.
Prompt 2
How do I combine two NTK-Mirror controllers, one for coding and one for math, into a single merged controller?
Prompt 3
Show me how to store NTK-Mirror controllers as named memory items and retrieve the most relevant one using a text query.
Prompt 4
I want to adapt a local language model to follow my writing style using NTK-Mirror, what training data format do I need and how many examples?
Prompt 5
How does NTK-Mirror differ from LoRA adapters, and when should I choose one over the other?
Open on GitHub → Explain another repo

← leochlon on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.