Closed-Loop Training System — ReMiT + RLPT Flywheel
╔══════════════════════════════════════════════════════════╗
║ ██████╗██╗ ██████╗ ███████╗██████╗ ██╗ ║
║ ██╔════╝██║ ██╔═══██╗██╔════╝██╔══██╗██║ ║
║ ██║ ██║ ██║ ██║█████╗ ██║ ██║██║ ║
║ ██║ ██║ ██║ ██║██╔══╝ ██║ ██║██║ ║
║ ╚██████╗██████╗╚██████╔╝███████╗██████╔╝███████╗ ║
║ ╚═════╝╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚══════╝ ║
║ ║
║ L O O P T R A I N I N G ║
║ ║
║ ReMiT + RLPT | Continuous Self-Improvement ║
╚══════════════════════════════════════════════════════════╝
Author: KingLabsA
GitHub: https://github.com/KingLabsA/llm-training-platform
HuggingFace: https://huggingface.co/King3Djbl | https://huggingface.co/fableforge-ai
Ollama: https://ollama.com/FableForge-AI
License: Apache 2.0
Continuous self-improving training: ReMiT token reweighting + RLPT next-segment reasoning, chained in iterative flywheel.
Quickstart
pip install closed-loop-training # or: pip install -e .
closedloop train --model meta-llama/Llama-3.2-1B --corpus data.jsonl
# Try dummy mode first:
closedloop train --model dummy --corpus data.json --iterations 3 --tui
Features
- ReMiT Mid-Training — Dynamic token reweighting using frozen RL reference. Tokens where the RL model assigns higher probability get upweighted. Soft sigmoid weighting clipped to [0.8, 1.2]. No token discarding.
- RLPT Post-Training — Next-segment reasoning on pre-training data. GRPO-style optimization with generative reward model (GRM). No human annotations needed.
- Closed-Loop Flywheel — Post-trained model becomes the RL reference for the next cycle. Each iteration bootstraps from the previous. Convergence detection stops when improvement < 0.5%.
- Live TUI — Rich terminal dashboard with real-time ReMiT/RLPT metrics, progress bars, and iteration history table.
- Dummy Mode — Test the full pipeline without GPU or real models. Use
--model dummy. - Checkpoint & Resume — Save & resume from any iteration. History saved as JSON.
- Convergence Detection — Automatic early stopping when per-iteration improvement falls below threshold.
Architecture: Closed-Loop Flywheel
┌─────────────────────────────────────┐
│ Closed-Loop Iteration │
│ │
│ ┌──────────┐ ┌──────────────┐ │
│ │ ReMiT │ │ RLPT │ │
│ │ Mid- │───>│ Post- │ │
│ │ Training │ │ Training │ │
│ └────┬─────┘ └──────┬───────┘ │
│ │ │ │
│ v v │
│ ┌─────────────────────────────┐ │
│ │ RL Reference Model │ │
│ │ (becomes teacher next cycle)│ │
│ └──────────────┬──────────────┘ │
│ │ │
│ v │
│ ┌─────────────────────────────┐ │
│ │ Gap Analysis + │ │
│ │ Domain Targeting │ │
│ └─────────────────────────────┘ │
│ │ │
└─────────────────┼───────────────────┘
│
v
┌─────────────────────┐
│ Improved Base Model │
│ (fed to next cycle) │
└─────────────────────┘
How It Works
- Initialize — Load a base model and training corpus. If no RL reference exists yet, skip ReMiT weighting on the first iteration.
- ReMiT Mid-Training — For each batch, compute per-token loss discrepancy between the base model and the frozen RL reference. Generate importance weights via centered sigmoid clipped to [0.8, 1.2]. Train on weighted NLL.
- RLPT Post-Training — Segment corpus text into sentence units. For each segment, prompt the model to predict the next segment. Score predictions with a Generative Reward Model (GRM). Optimize via GRPO (group-relative advantages with KL penalty).
- Reference Update — Set the post-trained model as the new RL reference (frozen). The next ReMiT cycle will compare against this improved reference.
- Convergence Check — Measure ReMiT loss improvement. If below threshold, stop.
- Iterate — Repeat. Each cycle the model learns from its own improvements.
CLI Reference
closedloop train
| Flag | Default | Description |
|---|---|---|
--model |
meta-llama/Llama-3.2-1B |
HuggingFace model name or dummy |
--corpus |
(required) | Path to JSON, JSONL, or text corpus |
--iterations |
3 |
Number of closed-loop flywheel iterations |
--mid-train-steps |
500 |
ReMiT steps per iteration |
--rl-train-steps |
500 |
RLPT steps per iteration |
--remit-batch-size |
8 |
Batch size for ReMiT |
--rlpt-batch-size |
4 |
Batch size for RLPT |
--max-samples |
10000 |
Max corpus samples to load |
--domain |
None |
Target domain name |
--max-seq-length |
2048 |
Maximum sequence length |
--lr |
3e-4 |
Base learning rate |
--remit-lr |
3e-4 |
ReMiT learning rate |
--rlpt-lr |
1e-6 |
RLPT learning rate |
--output-dir |
./closed_loop_output |
Output directory |
--log-interval |
10 |
Steps between logging |
--device |
auto |
auto, cuda, or cpu |
--tui |
(flag) | Enable live TUI display |
closedloop resume
| Flag | Default | Description |
|---|---|---|
--checkpoint |
(required) | Path to .pt checkpoint |
--output-dir |
checkpoint dir | Output directory |
--iterations |
from checkpoint | Override remaining iterations |
--tui |
(flag) | Enable live TUI display |
TUI Mode vs Non-TUI Mode
- TUI mode (
--tui): Rich live dashboard with real-time ReMiT/RLPT metrics, progress bars, iteration history table, phase indicators, and elapsed time. Ideal for demos, monitoring, and debugging. - Non-TUI mode (default): Print-based logging. Each step logs loss/metrics. Compact output suitable for scripts, CI/CD, and headless environments.
Environment Variables
| Variable | Purpose |
|---|---|
PYTHONPATH |
Should include project root for imports |
Citation
@misc{kinglabsa2026closedloop,
author = {KingLabsA},
title = {Closed-Loop Training System: ReMiT + RLPT Flywheel},
year = {2026},
publisher = {GitHub},
url = {https://github.com/KingLabsA/llm-training-platform}
}
@article{huang2026remit,
title={ReMiT: Reinforcement Learning Guided Mid-Training for Large Language Models},
author={Huang et al.},
journal={arXiv preprint arXiv:2602.03075},
year={2026}
}
@inproceedings{li2026rlpt,
title={RLPT: Reinforcement Learning on Pre-Training Data for Next-Segment Reasoning},
author={Li et al.},
booktitle={ACL 2026},
year={2026}
}
License
Apache 2.0 — See LICENSE file.
Built by KingLabsA. ReMiT paper: arXiv 2602.03075. RLPT paper: ACL 2026.
Release files for closed-loop-training 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| closed_loop_training-0.5.0.tar.gz | 77.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| closed_loop_training-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 147.6 kB
Release files / closed_loop_training-0.5.0.tar.gz
| Download URL | closed_loop_training-0.5.0.tar.gz |
|---|---|
| Size | 77.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c108609dc86809e052c6d3afe38a7e747cf02b02cd279afaa155340a33c7a2c
|
|
BLAKE2b-256 checksum How to use checksums |
aef57b44567077525e865da2812aba1b279d2deaf4d4ca813067f862692d2403
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / closed_loop_training-0.5.0-py3-none-any.whl
| Download URL | closed_loop_training-0.5.0-py3-none-any.whl |
|---|---|
| Size | 69.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5012fe887810ee42f853f060a73b73eef84de5e3994f24e9a7189a0ddd717836
|
|
BLAKE2b-256 checksum How to use checksums |
b8c78b5d2a28c7b60f0cdb49f9ef101a9bf999d20a861a4991fd838fa1debd02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|