# rfls-emyton/ninmeni architecture

> Architecture diagram of the GitHub repository rfls-emyton/ninmeni, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rfls-emyton/ninmeni
- Repository: https://github.com/rfls-emyton/ninmeni

## Overview

NINMENI is the reproducible Generation 1 Indonesian character-level language-model framework, not the unpublished Veyra architecture. The main workflow turns JSONL corpus records into NMU ID shards, then trains the reference model with a unified pretraining/SFT loop and saves resumable checkpoints. The codec and fixed registry are also independently usable for encode/decode experiments. Training and shard-builder relationships follow the README and indexed imports; unsampled implementation details are not inferred.

Main entry points: [`training/train_unified_native.py`](https://github.com/rfls-emyton/ninmeni/blob/main/training/train_unified_native.py) (Unified trainer), [`nmu/codec.py`](https://github.com/rfls-emyton/ninmeni/blob/main/nmu/codec.py) (NMU codec), [`pipeline/build_shards.py`](https://github.com/rfls-emyton/ninmeni/blob/main/pipeline/build_shards.py) (Shard builder), [`training/sft_native.py`](https://github.com/rfls-emyton/ninmeni/blob/main/training/sft_native.py) (SFT data and loss)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_representation["NMU representation"]
  node_registry["NMU registry<br/>[nmu_v1.json]"]
  node_codec["NMU codec<br/>[codec.py]"]
  node_codec_errors["Codec errors<br/>[errors.py]"]
end

subgraph group_preparation["Corpus preparation"]
  node_shard_builder["Shard builder<br/>[build_shards.py]"]
  node_shard_data["ID shards"]
end

subgraph group_training["Model training"]
  node_unified_trainer["Unified trainer"]
  node_sft_logic["SFT data and loss<br/>[sft_native.py]"]
  node_training_utils["Sampling and checkpoints<br/>[native_utils.py]"]
end

subgraph group_model["Reference model"]
  node_reference_model["Reference decoder<br/>[reference_model.py]"]
end

node_corpus["JSONL corpus"]
node_sft_data["SFT turn data"]
node_checkpoints["Training checkpoints"]

node_corpus -->|"ingests JSONL"| node_shard_builder
node_shard_builder -->|"encodes records"| node_codec
node_shard_builder -->|"writes shards"| node_shard_data
node_codec -->|"loads registry"| node_registry
node_codec -->|"raises errors"| node_codec_errors
node_unified_trainer -->|"loads registry"| node_registry
node_unified_trainer -->|"samples pretraining"| node_shard_data
node_unified_trainer -->|"loads SFT data"| node_sft_data
node_unified_trainer -->|"uses SFT routines"| node_sft_logic
node_unified_trainer -->|"uses sampler and saves"| node_training_utils
node_unified_trainer -->|"trains model"| node_reference_model
node_training_utils -->|"writes checkpoints"| node_checkpoints
node_sft_logic -->|"encodes turns"| node_codec
node_sft_logic -->|"computes SFT loss"| node_reference_model

click node_shard_builder "https://github.com/rfls-emyton/ninmeni/blob/main/pipeline/build_shards.py"
click node_registry "https://github.com/rfls-emyton/ninmeni/blob/main/registry/nmu_v1.json"
click node_codec "https://github.com/rfls-emyton/ninmeni/blob/main/nmu/codec.py"
click node_codec_errors "https://github.com/rfls-emyton/ninmeni/blob/main/nmu/errors.py"
click node_unified_trainer "https://github.com/rfls-emyton/ninmeni/blob/main/training/train_unified_native.py"
click node_sft_logic "https://github.com/rfls-emyton/ninmeni/blob/main/training/sft_native.py"
click node_training_utils "https://github.com/rfls-emyton/ninmeni/blob/main/training/native_utils.py"
click node_reference_model "https://github.com/rfls-emyton/ninmeni/blob/main/model/reference_model.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_registry,node_codec,node_codec_errors toneBlue
class node_shard_builder,node_shard_data toneAmber
class node_unified_trainer,node_sft_logic,node_training_utils toneMint
class node_reference_model toneRose
class node_corpus,node_sft_data,node_checkpoints toneIndigo
```

## Components

### NMU representation

- [NMU registry](https://github.com/rfls-emyton/ninmeni/blob/main/registry/nmu_v1.json): `registry/nmu_v1.json`
- [NMU codec](https://github.com/rfls-emyton/ninmeni/blob/main/nmu/codec.py): `nmu/codec.py`
- [Codec errors](https://github.com/rfls-emyton/ninmeni/blob/main/nmu/errors.py): `nmu/errors.py`

### Corpus preparation

- [Shard builder](https://github.com/rfls-emyton/ninmeni/blob/main/pipeline/build_shards.py): `pipeline/build_shards.py`
- **ID shards**

### Model training

- [Unified trainer](https://github.com/rfls-emyton/ninmeni/blob/main/training/train_unified_native.py): `training/train_unified_native.py`
- [SFT data and loss](https://github.com/rfls-emyton/ninmeni/blob/main/training/sft_native.py): `training/sft_native.py`
- [Sampling and checkpoints](https://github.com/rfls-emyton/ninmeni/blob/main/training/native_utils.py): `training/native_utils.py`

### Reference model

- [Reference decoder](https://github.com/rfls-emyton/ninmeni/blob/main/model/reference_model.py): `model/reference_model.py`

### Other components

- **JSONL corpus**
- **SFT turn data**
- **Training checkpoints**

## Connections

- JSONL corpus → Shard builder: ingests JSONL (evidence: `README.md`)
- Shard builder → NMU codec: encodes records (evidence: `pipeline/build_shards.py`)
- Shard builder → ID shards: writes shards (evidence: `pipeline/build_shards.py`)
- NMU codec → NMU registry: loads registry (evidence: `nmu/codec.py`)
- NMU codec → Codec errors: raises errors (evidence: `nmu/codec.py`)
- Unified trainer → NMU registry: loads registry (evidence: `training/train_unified_native.py`)
- Unified trainer → ID shards: samples pretraining (evidence: `README.md`)
- Unified trainer → SFT turn data: loads SFT data (evidence: `README.md`)
- Unified trainer → SFT data and loss: uses SFT routines (evidence: `training/train_unified_native.py`)
- Unified trainer → Sampling and checkpoints: uses sampler and saves (evidence: `training/train_unified_native.py`)
- Unified trainer → Reference decoder: trains model (evidence: `training/train_unified_native.py`)
- Sampling and checkpoints → Training checkpoints: writes checkpoints (evidence: `training/native_utils.py`)
- SFT data and loss → NMU codec: encodes turns (evidence: `training/sft_native.py`)
- SFT data and loss → Reference decoder: computes SFT loss (evidence: `training/sft_native.py`)
