# maagdeveloper/neolm architecture

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

- Interactive diagram: https://gitdiagram.com/maagdeveloper/neolm
- Repository: https://github.com/maagdeveloper/neolm

## Overview

NeoLM is a small language-model project: its Python package implements a configurable decoder-only Transformer, while notebooks document corpus preparation, tokenizer creation, pretraining, inference, and evaluation. The principal workflow runs from corpus preparation or loading through tokenization and token-stream preparation to model pretraining; inference then loads a released model and produces sampled continuations. The graph includes documented evaluation branches and model components. Notebook relationships reflect README descriptions; notebook internals were not sampled, so those edges are documented workflow links rather than inspected calls.

Main entry points: [`neolm/modeling_neolm.py`](https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py) (Transformer Backbone), [`notebooks/training/00_load_corpus.ipynb`](https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/00_load_corpus.ipynb) (Corpus Loading), [`notebooks/training/04_pretrain.ipynb`](https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/04_pretrain.ipynb) (Model Pretraining), [`examples/inference.ipynb`](https://github.com/maagdeveloper/neolm/blob/main/examples/inference.ipynb) (Inference Workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Corpus and Tokenizer"]
  node_corpus_prep["Corpus Preparation"]
  node_corpus_publish["Corpus Publishing"]
  node_corpus_load["Corpus Loading"]
  node_token_benchmark["Tokenizer Benchmark"]
  node_token_train["Tokenizer Training"]
  node_token_streams[("Token Streams")]
end

subgraph group_training["Pretraining"]
  node_pretrain["Model Pretraining<br/>[04_pretrain.ipynb]"]
end

subgraph group_runtime["Model Runtime"]
  node_config["Model Configuration"]
  node_backbone["Transformer Backbone<br/>[modeling_neolm.py]"]
  node_attention["Causal GQA Attention<br/>[modeling_neolm.py]"]
  node_feedforward["SwiGLU Feed-Forward<br/>[modeling_neolm.py]"]
  node_lm_head["Language Model Head<br/>[modeling_neolm.py]"]
  node_classifier["Classification Head<br/>[modeling_neolm.py]"]
  node_inference["Inference Workflow<br/>[inference.ipynb]"]
  node_generation["Text Generation<br/>[modeling_neolm.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_perplexity["Perplexity and BPB"]
  node_hellaswag["HellaSwag Scoring<br/>[03_hellaswag.ipynb]"]
  node_gen_eval["Generation Evaluation"]
  node_model_compare["Model Comparison"]
end

node_corpus_source(("Corpus Source"))
node_hosted_corpus[("NeoCorpus")]
node_model_hub[("Hugging Face Model")]
node_user(("User"))

node_corpus_source -->|"collects and prepares"| node_corpus_prep
node_corpus_prep -.->|"publishes prepared data"| node_corpus_publish
node_corpus_publish -.->|"publishes to"| node_hosted_corpus
node_hosted_corpus -->|"loads from"| node_corpus_load
node_corpus_load -->|"compares tokenization"| node_token_benchmark
node_corpus_load -->|"trains on corpus"| node_token_train
node_token_train -->|"encodes documents"| node_token_streams
node_token_streams -->|"provides training data"| node_pretrain
node_config -->|"configures architecture"| node_backbone
node_backbone -->|"contains attention"| node_attention
node_backbone -->|"contains feed-forward"| node_feedforward
node_backbone -->|"feeds language head"| node_lm_head
node_backbone -->|"feeds classifier"| node_classifier
node_pretrain -->|"initializes model"| node_config
node_pretrain -->|"exports model"| node_model_hub
node_user -->|"provides prompt"| node_inference
node_model_hub -->|"loads model and tokenizer"| node_inference
node_inference -->|"runs autoregressive generation"| node_generation
node_generation -->|"returns continuation"| node_user
node_model_hub -->|"evaluates held-out data"| node_perplexity
node_model_hub -->|"scores benchmark"| node_hellaswag
node_model_hub -->|"evaluates generated text"| node_gen_eval
node_model_hub -->|"compares models"| node_model_compare

click node_corpus_prep "https://github.com/maagdeveloper/neolm/blob/main/notebooks/corpus/00_prepare_corpus.ipynb"
click node_corpus_publish "https://github.com/maagdeveloper/neolm/blob/main/notebooks/corpus/01_publish_corpus.ipynb"
click node_corpus_load "https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/00_load_corpus.ipynb"
click node_token_benchmark "https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/01_tokenizer_benchmark.ipynb"
click node_token_train "https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/02_train_tokenizer.ipynb"
click node_token_streams "https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/03_prepare_token_streams.ipynb"
click node_pretrain "https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/04_pretrain.ipynb"
click node_config "https://github.com/maagdeveloper/neolm/blob/main/neolm/configuration_neolm.py"
click node_backbone "https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py"
click node_attention "https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py"
click node_feedforward "https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py"
click node_lm_head "https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py"
click node_classifier "https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py"
click node_inference "https://github.com/maagdeveloper/neolm/blob/main/examples/inference.ipynb"
click node_generation "https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py"
click node_perplexity "https://github.com/maagdeveloper/neolm/blob/main/benchmarks/01_perplexity.ipynb"
click node_hellaswag "https://github.com/maagdeveloper/neolm/blob/main/benchmarks/03_hellaswag.ipynb"
click node_gen_eval "https://github.com/maagdeveloper/neolm/blob/main/benchmarks/02_generation.ipynb"
click node_model_compare "https://github.com/maagdeveloper/neolm/blob/main/benchmarks/05_model_comparison.ipynb"

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_corpus_prep,node_corpus_publish,node_corpus_load,node_token_benchmark,node_token_train,node_token_streams,node_user toneBlue
class node_pretrain,node_hosted_corpus,node_model_hub toneAmber
class node_config,node_backbone,node_attention,node_feedforward,node_lm_head,node_classifier,node_inference,node_generation toneMint
class node_perplexity,node_hellaswag,node_gen_eval,node_model_compare toneRose
class node_corpus_source toneIndigo
```

## Components

### Corpus and Tokenizer

- [Corpus Preparation](https://github.com/maagdeveloper/neolm/blob/main/notebooks/corpus/00_prepare_corpus.ipynb): `notebooks/corpus/00_prepare_corpus.ipynb`
- [Corpus Publishing](https://github.com/maagdeveloper/neolm/blob/main/notebooks/corpus/01_publish_corpus.ipynb): `notebooks/corpus/01_publish_corpus.ipynb`
- [Corpus Loading](https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/00_load_corpus.ipynb): `notebooks/training/00_load_corpus.ipynb`
- [Tokenizer Benchmark](https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/01_tokenizer_benchmark.ipynb): `notebooks/training/01_tokenizer_benchmark.ipynb`
- [Tokenizer Training](https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/02_train_tokenizer.ipynb): `notebooks/training/02_train_tokenizer.ipynb`
- [Token Streams](https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/03_prepare_token_streams.ipynb): `notebooks/training/03_prepare_token_streams.ipynb`

### Pretraining

- [Model Pretraining](https://github.com/maagdeveloper/neolm/blob/main/notebooks/training/04_pretrain.ipynb): `notebooks/training/04_pretrain.ipynb`

### Model Runtime

- [Model Configuration](https://github.com/maagdeveloper/neolm/blob/main/neolm/configuration_neolm.py): `neolm/configuration_neolm.py`
- [Transformer Backbone](https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py): `neolm/modeling_neolm.py`
- [Causal GQA Attention](https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py): `neolm/modeling_neolm.py`
- [SwiGLU Feed-Forward](https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py): `neolm/modeling_neolm.py`
- [Language Model Head](https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py): `neolm/modeling_neolm.py`
- [Classification Head](https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py): `neolm/modeling_neolm.py`
- [Inference Workflow](https://github.com/maagdeveloper/neolm/blob/main/examples/inference.ipynb): `examples/inference.ipynb`
- [Text Generation](https://github.com/maagdeveloper/neolm/blob/main/neolm/modeling_neolm.py): `neolm/modeling_neolm.py`

### Evaluation

- [Perplexity and BPB](https://github.com/maagdeveloper/neolm/blob/main/benchmarks/01_perplexity.ipynb): `benchmarks/01_perplexity.ipynb`
- [HellaSwag Scoring](https://github.com/maagdeveloper/neolm/blob/main/benchmarks/03_hellaswag.ipynb): `benchmarks/03_hellaswag.ipynb`
- [Generation Evaluation](https://github.com/maagdeveloper/neolm/blob/main/benchmarks/02_generation.ipynb): `benchmarks/02_generation.ipynb`
- [Model Comparison](https://github.com/maagdeveloper/neolm/blob/main/benchmarks/05_model_comparison.ipynb): `benchmarks/05_model_comparison.ipynb`

### Other components

- **Corpus Source**
- **NeoCorpus**
- **Hugging Face Model**
- **User**

## Connections

- Corpus Source → Corpus Preparation: collects and prepares (evidence: `README.md`)
- Corpus Preparation → Corpus Publishing: publishes prepared data (evidence: `README.md`)
- Corpus Publishing → NeoCorpus: publishes to (evidence: `README.md`)
- NeoCorpus → Corpus Loading: loads from (evidence: `README.md`)
- Corpus Loading → Tokenizer Benchmark: compares tokenization (evidence: `README.md`)
- Corpus Loading → Tokenizer Training: trains on corpus (evidence: `README.md`)
- Tokenizer Training → Token Streams: encodes documents (evidence: `README.md`)
- Token Streams → Model Pretraining: provides training data (evidence: `README.md`)
- Model Configuration → Transformer Backbone: configures architecture (evidence: `README.md`)
- Transformer Backbone → Causal GQA Attention: contains attention (evidence: `neolm/modeling_neolm.py`)
- Transformer Backbone → SwiGLU Feed-Forward: contains feed-forward (evidence: `neolm/modeling_neolm.py`)
- Transformer Backbone → Language Model Head: feeds language head (evidence: `neolm/modeling_neolm.py`)
- Transformer Backbone → Classification Head: feeds classifier (evidence: `neolm/modeling_neolm.py`)
- Model Pretraining → Model Configuration: initializes model (evidence: `README.md`)
- Model Pretraining → Hugging Face Model: exports model (evidence: `README.md`)
- User → Inference Workflow: provides prompt (evidence: `README.md`)
- Hugging Face Model → Inference Workflow: loads model and tokenizer (evidence: `README.md`)
- Inference Workflow → Text Generation: runs autoregressive generation (evidence: `README.md`)
- Text Generation → User: returns continuation (evidence: `README.md`)
- Hugging Face Model → Perplexity and BPB: evaluates held-out data (evidence: `README.md`)
- Hugging Face Model → HellaSwag Scoring: scores benchmark (evidence: `README.md`)
- Hugging Face Model → Generation Evaluation: evaluates generated text (evidence: `README.md`)
- Hugging Face Model → Model Comparison: compares models (evidence: `README.md`)
