Skip to content

About

Train music retrieval heads, multimodal adapters, GLM output heads and LLM drafts. Compare greedy token sequences, draft acceptance and latency against a baseline.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Model Improvement Lab

Русская версия

Model Improvement Lab trains and evaluates model adaptations locally. Its music retrieval trainer learns what makes recordings similar for one task, such as melody, genre or drum sound. The lab also fine-tunes vision, speech and music captioning models, trains LLM drafts and GLM output heads, and exports benchmark measurements to OboroLabs.

Task Entry point
Train music similarity or CLAP/MERT rank fusion coach.py music train
Run a pretrained model, train an adapter, resume or prepare a Hugging Face package coach.py multimodal
Capture features and train DFlash2/D-PACE or offline EAGLE-3 drafts coach.py run, coach.py eagle3
Fit a GLM output head and verify a merged GGUF coach.py train-output-head, coach.py verify-gguf-merge
Check greedy token agreement, draft acceptance and speed coach.py benchmark, coach.py benchmark-export

Train a music retrieval head

With Python 3.10+ and NumPy, the following commands run on CPU. The example creates synthetic embeddings with a known similarity rule and fits a head on 24 training triplets. It selects among candidates on eight validation triplets. Use a new directory for the example and a new filename for the head.

python3 -m pip install -r requirements-music.txt
python3 examples/music_fixture.py ../music-example
python3 coach.py music train --dataset ../music-example --profile custom \
  --axis melody --output ../melody.json

With Python 3.11+ and the OboroLabs music extra, score the remaining eight test triplets with oborolabs music-test ../music-example --profile custom --axis melody --weights ../melody.json. OboroLabs

For the Oboro SBS-Music-Training collection, point SBS at the local data directory containing items.jsonl, triplets.jsonl, profiles/ and encoder_bank/. The feature banks and manifests are separate inputs. This example credits the publisher of the fitted head as biscet. Supply your own public credit when publishing your run. Omitting --publisher leaves it unset.

python3 coach.py music train --dataset "$SBS" --profile mert --axis genre \
  --publisher biscet --output ../mert-genre.json
oborolabs music-test "$SBS" --profile mert --axis genre --weights ../mert-genre.json
SBS profile Training inputs and output
mert, mert-mixed, clap, music-clap Core triplets and frozen embeddings. Each run fits nonnegative weights on squared coordinate distances for one axis.
muq The Meertens Field extension contains a MuQ bank and labeled melody triplets. Use --axis melody with the same dataset root.
hybrid Ranked candidate lists from CLAP and MERT. The trainer learns their reciprocal-rank fusion weights for the selected axis.

Training updates only the retrieval weights. Validation chooses the head or rank mixture. OboroLabs compares the exported result with its baseline on test. Head JSONs record source hashes, encoder identity for single-bank profiles, the selection result and dataset credit. Training protocol

For your own embeddings, use the custom profile and the layout produced by the example. Store unique string ids and a finite vectors matrix in encoder_bank/custom.npz. Each item in items.jsonl needs id and split. A triplet needs anchor, positive, negative, axis and split, with three different IDs from the same split. Use train, validation and test. For overall, include a stable comparison_id for each listener judgment. Set profile, id, revision, dimension and optional dataset_credit in profiles/custom.json. Runnable example

Try the offline demo

Python 3.10 or newer is enough. No packages or API key are needed.

python3 coach.py demo --run-dir ../model-improvement-lab-demo
python3 coach.py status --run-dir ../model-improvement-lab-demo
python3 -m unittest discover -s tests -v
python3 coach.py privacy-check

The demo writes synthetic files outside the source folder. It does not train a model or call DeepSeek. Tests that need PyTorch are skipped when it is absent. Choose a new demo directory for another run.

Evaluate a draft

coach.py benchmark runs the same held-out prompts twice without a draft, with the parent draft and with the candidate. Both drafts use the configured --spec-type and device placement. The checks follow the ThunderLLM experiments. Recompute the aggregate review offline with Python alone.

python3 coach.py benchmark-export --review "$RUN_DIR/evidence/benchmark-measurements.jsonl"
  • candidate_vs compares generated token IDs and text with both references. earliest_difference_1based is the earliest differing position across pairs. Check token_pairs_checked for missing observations.
  • variants reports agreement between repeats and draft tokens accepted divided by tokens proposed across requests with counters.
  • review_checks requires matching prompts, cache and token counts, timed steps, identical tokens and text across all runs, active drafts in every draft request, no flagged empty or repetitive answers and decode speed at least equal to the parent.

Older runs may lack evidence for these checks. A pass only qualifies the candidate for manual review on the measured inputs. It does not establish task accuracy or install a model.

Share benchmark measurements

python3 coach.py benchmark-export "$RUN_DIR/evidence/benchmark-measurements.jsonl" > portable.json
oborolabs llm-report portable.json

The first command works offline with completed no-draft, parent and candidate runs. It checks both repeats for every case and derives the number of timed decode steps from the server's native rate. The export contains ordinal case numbers, numeric timings, text agreement flags and visible-answer quality flags. The latter count empty final answers and repetitive output, including repetition in reasoning when the runtime supplies it. Read the resulting JSON directly or use the llm-report command from OboroLabs. Keep the source JSONL private. Both export modes omit text, token IDs, digests, original case identifiers and host metadata.

GLM output-head experiments

The output-head recipe learns two low-rank factors for output.weight while the GLM-5 Next backbone stays frozen. It reads a local GGUF, verifies its SHA-256, and checks the feature server's model path, alias, chat template and adapter list. Start a compatible ThunderLLM or llama-server locally with the same absolute model path, --embeddings --pooling none, and the selected chat template. The template's low-reasoning generation boundary must end in <think></think>. Install the training dependencies and the runtime's matching gguf-py package. Allocate sufficient batch, microbatch and context capacity for the requested token limit.

python3 coach.py train-output-head --base "$BASE_GGUF" --base-sha "$BASE_SHA256" \
  --model-alias "$MODEL_ALIAS" --template "$CHAT_TEMPLATE" --server "$FEATURE_URL" \
  --data "$TRAIN_JSONL" --run "$RUN_DIR" --round 1 --seconds 60
python3 coach.py verify-gguf-merge "$BASE_GGUF" "$MERGED_GGUF" "$TARGET_DIGESTS"

Training JSONL rows have unique IDs, a domain from reasoning, math, code, ru, or en, and chat messages ending with an assistant answer. Each optimizer step samples one row per domain. The timer covers capture and updates. Repeat the same round to resume, or advance the round number after completion. The output contains an adapter GGUF and the optimizer checkpoint. The default device for training the head is CPU. Score the adapter separately with an adapter-aware runtime. For a merged model, supply an independently obtained JSON map from target tensor name to expected merged-byte SHA-256. The verifier checks the full tensor inventory, dimensions, target digests, and type and byte equality of every other tensor.

The CPU router probe builds with the same GGML checkout used by ThunderLLM. It reports the sum of top-eight expert weights for four synthetic logits, using both denominator rules. These values measure numerical normalization.

cmake -S capture -B "$BUILD_DIR" -DLLAMA_CPP_DIR="$RUNTIME_SOURCE"
cmake --build "$BUILD_DIR" --target router-normalization
"$BUILD_DIR/router-normalization"

Train a DFlash2 draft

Follow the English guide. It covers the runtime build, CUDA environment, data format, API key, preparation, launch, resume and evaluation. The Russian guide covers the same steps.

Start with configs/example.json. Copy it to configs/training.local.json before changing paths. Paths in JSON are resolved relative to that JSON file. The small dataset example uses configs/lite.example.json instead. coach.py run drives feature capture as part of the bundled DFlash2 workflow. For a different target architecture, provide a compatible capture tool and DFlash2 recipe.

Set "training_objective": "dpace" before preparing a new run to use D-PACE. The default is uniform. The DFlash2 guide explains how D-PACE weights token and selector losses.

Train an EAGLE-3 draft

python3 coach.py eagle3 --help lists the capture, training and export stages. The EAGLE-3 guide shows how to run the bundled Whittle recipe on a V100 with SpecForge and llama.cpp.

Important

EAGLE-3 training reads precomputed target features. Run eagle3 capture before eagle3 train for the bundled recipe. For another supported target, capture its features separately and use a matching SpecForge recipe.

ML-Docs covers the D-PACE experiment and EAGLE-3 feature layout. ML-Docs

Vision, speech and audio experiments

python3 coach.py multimodal --help provides download, dataset validation, inference, bounded fine-tuning, resume and Hugging Face package staging. The initial recipes cover Qwen3.5-4B vision LoRA, Qwen3-ASR-0.6B speech LoRA, Music Flamingo music-caption LoRA, and CLAP audio/text projection training. See the multimodal guide for formats and commands.

Public dataset examples

  • DFlash DeepSeek TraceMix. Use deepseek for the main task splits or stage2 for the separate 272-context training supplement with the main validation and test splits.
  • DFlash ChatGPT TraceMix Lite. The lite example uses OpenMix. It reserves part of the source validation families for testing because that subset has no separate test file.

Only links, pinned revisions and download settings are stored here. Dataset records are downloaded only when the user runs download-example. Existing completions are discarded. Labels and features for training come from the configured target model.

Limits of this version

The portable controller has CPU and mocked integration tests. Its training backend comes from an existing CUDA implementation. A complete GPU run of this portable package is still needed before treating a new setup as verified.

The recipe fixes the feature layers, vocabulary and draft architecture in code. Changing target_model alone does not make another architecture compatible. The example stops after at most one full pass; DeepSeek can stop earlier. Loss and prefix metrics are offline proxies. They do not establish serving speed or response quality. The candidate is not installed into an inference service.

Versions and licenses

The architecture is documented in the Russian architecture guide.

Development continues on main. Tag v3.0.0 pins the release. The v2.0.1, v2.0.0 and v1.0.0 branches preserve earlier releases. See the changelog and release steps.

Original utilities use Apache-2.0. The upstream DFlash model implementation uses MIT. See NOTICE, LICENSE and DFlash MIT.

About

Train music retrieval heads, multimodal adapters, GLM output heads and LLM drafts. Compare greedy token sequences, draft acceptance and latency against a baseline.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages