# zero-9215/online-cl-llms architecture

> Architecture diagram of the GitHub repository zero-9215/online-cl-llms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zero-9215/online-cl-llms
- Repository: https://github.com/zero-9215/online-cl-llms

## Overview

#### Purpose and entry points
This is an offline research pipeline for parameter-efficient continual learning of LLMs across ordered NLP tasks, supporting Long_Sequence and SuperNI benchmarks. Training starts by generating shell scripts with `gen_script_new_long_llama.py` or `gen_script_new_superni_llama.py`; scoring is invoked through `score.py`. Core model runners are `src/run_llama_new.py` and `src/run_t5_new.py`.

#### Benchmark data boundary
Raw benchmark data is file-backed JSON, separated by task and split. Long_Sequence contains classification-style datasets with explicit label files, e.g. `CL_Benchmark/Long_Sequence/agnews/train.json` and `CL_Benchmark/Long_Sequence/agnews/labels.json`. SuperNI contains instruction/generation tasks, e.g. `CL_Benchmark/SuperNI/task1290_xsum_summarization/train.json`. No serving, database, or remote data service is represented.

#### Continual-task orchestration
Task order/split selection is controlled independently from raw examples through per-task `train_tasks.json`, `dev_tasks.json`, and `test_tasks.json`. Benchmark-specific plans live in `configs/Long_Sequence/agnews/train_tasks.json` and `configs/SuperNI/task002_quoref_answer_generation/train_tasks.json`; combined experiment plans are under `configs/SuperNI_Long_Sequence/`. This configuration layer is the boundary between a benchmark corpus and an ordered continual-learning run.

#### Dataset, batching, and prompt adaptation
The primary training path turns configured task examples into model-ready continual-learning batches through `src/cl_dataset.py` and `src/cl_collator.py`. Model-family prompt formatting is split between `src/llama_prompt_new.py` and `src/t5_prompt_new.py`, keeping dataset/task representation separate from tokenizer/model-specific serialization. A repository-local GPT-2 tokenizer asset is available at `data/gpt2tokenizer/tokenizer.json`.

#### Training and parameter-efficient adaptation
`src/cl_trainer.py` owns the continual-training loop used by the Llama/T5 runners. Generated datasets show separate artifacts for LoRA-based Llama and T5 runs, such as `generated_data/lora_gen_long_llama/Long_Sequence/agnews/train.json` and `generated_data/lora_gen_long_t5/Long_Sequence/agnews/train.json`. The alternate pseudo-data workflow vendors PEFT implementations—including LoRA, AdaLoRA, prompt/prefix tuning—under `pseudo_data/src/peft_1/tuners/lora.py` and `pseudo_data/src/peft_1/tuners/adalora.py`.

#### Pseudo-data / lookback branch
A distinct “Ours_CL” branch stores lookback pseudo-data per prior SuperNI task, e.g. `pseudo_data/CL_Benchmark/Ours_CL/lookback_task002_quoref_answer_generation/train.json`, with matching task configurations in `pseudo_data/configs/Ours_CL_configs/`. Its executable stack is separate: `pseudo_data/src/run_uie_lora.py`, `pseudo_data/src/uie_dataset_lora_ours.py`, and `pseudo_data/src/uie_trainer_lora.py`. This is a meaningful boundary from the main `src/` CL pipeline.

#### Evaluation and runtime infrastructure
`score.py` aggregates continual-learning results into AP, forgetting rate, FWT, and BWT. Task-level metrics are implemented in `src/compute_metrics.py`, with bundled ROUGE code in `src/rouge/rouge.py`; the pseudo branch has parallel evaluation at `pseudo_data/src/evaluation/evaluator.py`. Training infrastructure includes DeepSpeed stage/offload configurations in `configs/ds_configs/stage0.config` through `configs/ds_configs/stage3.config`, including Llama-specific variants. Dependencies are declared in `requirements.txt`; no external runtime services are identified.

Main entry points: [`configs/Long_Sequence/agnews/train_tasks.json`](https://github.com/zero-9215/online-cl-llms/blob/main/configs/Long_Sequence/agnews/train_tasks.json) (Task order and splits), [`src/cl_trainer.py`](https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_trainer.py) (Continual trainer), [`src/cl_collator.py`](https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_collator.py) (Continual batch collator), [`src/cl_dataset.py`](https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_dataset.py) (Continual dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plans["Experiment Planning"]
  node_script_long["Long Sequence script generator<br/>entry point"]
  node_script_superni["SuperNI script generator<br/>entry point"]
  node_task_plans["Task order and splits<br/>experiment configs<br/>[train_tasks.json]"]
  node_combined_plans["Combined benchmark plans<br/>experiment configs"]
end

subgraph group_main["Main Continual Learning"]
  node_dataset["Continual dataset<br/>dataset layer<br/>[cl_dataset.py]"]
  node_collator["Continual batch collator<br/>batching layer<br/>[cl_collator.py]"]
  node_llama_prompts["Llama prompt formatter<br/>prompt adapter"]
  node_t5_prompts["T5 prompt formatter<br/>prompt adapter<br/>[t5_prompt_new.py]"]
  node_tokenizer["GPT-2 tokenizer<br/>local tokenizer asset<br/>[tokenizer.json]"]
  node_llama_runner["Llama runner<br/>model runner<br/>[run_llama_new.py]"]
  node_t5_runner["T5 runner<br/>model runner<br/>[run_t5_new.py]"]
  node_trainer["Continual trainer<br/>training loop<br/>[cl_trainer.py]"]
  node_generated_artifacts[("Generated training data<br/>LoRA artifacts<br/>[train.json]")]
  node_deepspeed["DeepSpeed configs<br/>training infrastructure<br/>[stage0.config]"]
end

subgraph group_pseudo["Pseudo-data Lookback"]
  node_lookback_data[("Lookback pseudo-data<br/>JSON pseudo-data<br/>[train.json]")]
  node_pseudo_configs["Ours_CL task configs<br/>experiment configs"]
  node_pseudo_runner["UIE LoRA runner<br/>pseudo-data runner<br/>[run_uie_lora.py]"]
  node_pseudo_dataset["UIE LoRA dataset<br/>dataset layer"]
  node_pseudo_trainer["UIE LoRA trainer<br/>training loop"]
  node_peft_tuners["Vendored PEFT tuners<br/>adaptation implementations<br/>[lora.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_score["Continual score aggregator<br/>evaluation entry point<br/>[score.py]"]
  node_task_metrics["Task metrics and ROUGE<br/>metrics layer<br/>[compute_metrics.py]"]
  node_pseudo_evaluator["Pseudo branch evaluator<br/>evaluation layer<br/>[evaluator.py]"]
end

node_long_data[("Long Sequence corpus<br/>JSON benchmark data<br/>[train.json]")]
node_superni_data[("SuperNI corpus<br/>JSON benchmark data<br/>[train.json]")]

node_script_long -->|"generates runs from"| node_task_plans
node_script_superni -->|"generates runs from"| node_task_plans
node_combined_plans -->|"combines task sequences"| node_task_plans
node_task_plans -->|"selects tasks from"| node_long_data
node_task_plans -->|"selects tasks from"| node_superni_data
node_long_data -->|"examples"| node_dataset
node_superni_data -->|"examples"| node_dataset
node_task_plans -->|"task order and splits"| node_dataset
node_dataset -->|"task examples"| node_collator
node_llama_prompts -->|"serializes prompts"| node_collator
node_t5_prompts -->|"serializes prompts"| node_collator
node_tokenizer -->|"tokenization"| node_collator
node_collator -->|"continual batches"| node_trainer
node_llama_runner -->|"runs"| node_trainer
node_t5_runner -->|"runs"| node_trainer
node_deepspeed -.->|"runtime configuration"| node_trainer
node_trainer -->|"writes generated data"| node_generated_artifacts
node_pseudo_configs -->|"configures"| node_pseudo_runner
node_lookback_data -->|"lookback examples"| node_pseudo_dataset
node_pseudo_dataset -->|"batches"| node_pseudo_trainer
node_pseudo_runner -->|"runs"| node_pseudo_trainer
node_peft_tuners -->|"parameter-efficient tuning"| node_pseudo_trainer
node_trainer -->|"predictions"| node_task_metrics
node_task_metrics -->|"task results"| node_score
node_pseudo_trainer -->|"predictions"| node_pseudo_evaluator
node_pseudo_evaluator -->|"continual results"| node_score

click node_script_long "https://github.com/zero-9215/online-cl-llms/blob/main/gen_script_new_long_llama.py"
click node_script_superni "https://github.com/zero-9215/online-cl-llms/blob/main/gen_script_new_superni_llama.py"
click node_task_plans "https://github.com/zero-9215/online-cl-llms/blob/main/configs/Long_Sequence/agnews/train_tasks.json"
click node_long_data "https://github.com/zero-9215/online-cl-llms/blob/main/CL_Benchmark/Long_Sequence/agnews/train.json"
click node_superni_data "https://github.com/zero-9215/online-cl-llms/blob/main/CL_Benchmark/SuperNI/task1290_xsum_summarization/train.json"
click node_dataset "https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_dataset.py"
click node_collator "https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_collator.py"
click node_llama_prompts "https://github.com/zero-9215/online-cl-llms/blob/main/src/llama_prompt_new.py"
click node_t5_prompts "https://github.com/zero-9215/online-cl-llms/blob/main/src/t5_prompt_new.py"
click node_tokenizer "https://github.com/zero-9215/online-cl-llms/blob/main/data/gpt2tokenizer/tokenizer.json"
click node_llama_runner "https://github.com/zero-9215/online-cl-llms/blob/main/src/run_llama_new.py"
click node_t5_runner "https://github.com/zero-9215/online-cl-llms/blob/main/src/run_t5_new.py"
click node_trainer "https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_trainer.py"
click node_generated_artifacts "https://github.com/zero-9215/online-cl-llms/blob/main/generated_data/lora_gen_long_llama/Long_Sequence/agnews/train.json"
click node_deepspeed "https://github.com/zero-9215/online-cl-llms/blob/main/configs/ds_configs/stage0.config"
click node_lookback_data "https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/CL_Benchmark/Ours_CL/lookback_task002_quoref_answer_generation/train.json"
click node_pseudo_runner "https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/run_uie_lora.py"
click node_pseudo_dataset "https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/uie_dataset_lora_ours.py"
click node_pseudo_trainer "https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/uie_trainer_lora.py"
click node_peft_tuners "https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/peft_1/tuners/lora.py"
click node_score "https://github.com/zero-9215/online-cl-llms/blob/main/score.py"
click node_task_metrics "https://github.com/zero-9215/online-cl-llms/blob/main/src/compute_metrics.py"
click node_pseudo_evaluator "https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/evaluation/evaluator.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_script_long,node_script_superni,node_task_plans,node_combined_plans toneBlue
class node_dataset,node_collator,node_llama_prompts,node_t5_prompts,node_tokenizer,node_llama_runner,node_t5_runner,node_trainer,node_generated_artifacts,node_deepspeed toneAmber
class node_lookback_data,node_pseudo_configs,node_pseudo_runner,node_pseudo_dataset,node_pseudo_trainer,node_peft_tuners toneMint
class node_score,node_task_metrics,node_pseudo_evaluator toneRose
class node_long_data,node_superni_data toneNeutral
```

## Components

### Experiment Planning

Defines ordered tasks independently of raw benchmark examples.

- [Long Sequence script generator](https://github.com/zero-9215/online-cl-llms/blob/main/gen_script_new_long_llama.py): entry point · `gen_script_new_long_llama.py`
- [SuperNI script generator](https://github.com/zero-9215/online-cl-llms/blob/main/gen_script_new_superni_llama.py): entry point · `gen_script_new_superni_llama.py`
- [Task order and splits](https://github.com/zero-9215/online-cl-llms/blob/main/configs/Long_Sequence/agnews/train_tasks.json): experiment configs · Selects train, development, and test task sequences. · `configs/Long_Sequence/agnews/train_tasks.json`
- **Combined benchmark plans**: experiment configs

### Main Continual Learning

Primary Llama and T5 training pipeline.

- [Continual dataset](https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_dataset.py): dataset layer · `src/cl_dataset.py`
- [Continual batch collator](https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_collator.py): batching layer · `src/cl_collator.py`
- [Llama prompt formatter](https://github.com/zero-9215/online-cl-llms/blob/main/src/llama_prompt_new.py): prompt adapter · `src/llama_prompt_new.py`
- [T5 prompt formatter](https://github.com/zero-9215/online-cl-llms/blob/main/src/t5_prompt_new.py): prompt adapter · `src/t5_prompt_new.py`
- [GPT-2 tokenizer](https://github.com/zero-9215/online-cl-llms/blob/main/data/gpt2tokenizer/tokenizer.json): local tokenizer asset · `data/gpt2tokenizer/tokenizer.json`
- [Llama runner](https://github.com/zero-9215/online-cl-llms/blob/main/src/run_llama_new.py): model runner · `src/run_llama_new.py`
- [T5 runner](https://github.com/zero-9215/online-cl-llms/blob/main/src/run_t5_new.py): model runner · `src/run_t5_new.py`
- [Continual trainer](https://github.com/zero-9215/online-cl-llms/blob/main/src/cl_trainer.py): training loop · `src/cl_trainer.py`
- [Generated training data](https://github.com/zero-9215/online-cl-llms/blob/main/generated_data/lora_gen_long_llama/Long_Sequence/agnews/train.json): LoRA artifacts · Stores model-family-specific generated datasets. · `generated_data/lora_gen_long_llama/Long_Sequence/agnews/train.json`
- [DeepSpeed configs](https://github.com/zero-9215/online-cl-llms/blob/main/configs/ds_configs/stage0.config): training infrastructure · Stage and offload configurations for distributed training. · `configs/ds_configs/stage0.config`

### Pseudo-data Lookback

Separate Ours_CL execution stack.

- [Lookback pseudo-data](https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/CL_Benchmark/Ours_CL/lookback_task002_quoref_answer_generation/train.json): JSON pseudo-data · Stores prior-task examples for Ours_CL. · `pseudo_data/CL_Benchmark/Ours_CL/lookback_task002_quoref_answer_generation/train.json`
- **Ours_CL task configs**: experiment configs
- [UIE LoRA runner](https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/run_uie_lora.py): pseudo-data runner · `pseudo_data/src/run_uie_lora.py`
- [UIE LoRA dataset](https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/uie_dataset_lora_ours.py): dataset layer · `pseudo_data/src/uie_dataset_lora_ours.py`
- [UIE LoRA trainer](https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/uie_trainer_lora.py): training loop · `pseudo_data/src/uie_trainer_lora.py`
- [Vendored PEFT tuners](https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/peft_1/tuners/lora.py): adaptation implementations · Provides LoRA, AdaLoRA, prompt, and prefix tuning variants. · `pseudo_data/src/peft_1/tuners/lora.py`

### Evaluation

- [Continual score aggregator](https://github.com/zero-9215/online-cl-llms/blob/main/score.py): evaluation entry point · Computes AP, forgetting, FWT, and BWT. · `score.py`
- [Task metrics and ROUGE](https://github.com/zero-9215/online-cl-llms/blob/main/src/compute_metrics.py): metrics layer · `src/compute_metrics.py`
- [Pseudo branch evaluator](https://github.com/zero-9215/online-cl-llms/blob/main/pseudo_data/src/evaluation/evaluator.py): evaluation layer · `pseudo_data/src/evaluation/evaluator.py`

### Other components

- [Long Sequence corpus](https://github.com/zero-9215/online-cl-llms/blob/main/CL_Benchmark/Long_Sequence/agnews/train.json): JSON benchmark data · Classification examples and explicit labels are file-backed. · `CL_Benchmark/Long_Sequence/agnews/train.json`
- [SuperNI corpus](https://github.com/zero-9215/online-cl-llms/blob/main/CL_Benchmark/SuperNI/task1290_xsum_summarization/train.json): JSON benchmark data · Instruction and generation tasks are file-backed. · `CL_Benchmark/SuperNI/task1290_xsum_summarization/train.json`

## Connections

- Long Sequence script generator → Task order and splits: generates runs from
- SuperNI script generator → Task order and splits: generates runs from
- Combined benchmark plans → Task order and splits: combines task sequences
- Task order and splits → Long Sequence corpus: selects tasks from
- Task order and splits → SuperNI corpus: selects tasks from
- Long Sequence corpus → Continual dataset: examples
- SuperNI corpus → Continual dataset: examples
- Task order and splits → Continual dataset: task order and splits
- Continual dataset → Continual batch collator: task examples
- Llama prompt formatter → Continual batch collator: serializes prompts
- T5 prompt formatter → Continual batch collator: serializes prompts
- GPT-2 tokenizer → Continual batch collator: tokenization
- Continual batch collator → Continual trainer: continual batches
- Llama runner → Continual trainer: runs
- T5 runner → Continual trainer: runs
- DeepSpeed configs → Continual trainer: runtime configuration
- Continual trainer → Generated training data: writes generated data
- Ours_CL task configs → UIE LoRA runner: configures
- Lookback pseudo-data → UIE LoRA dataset: lookback examples
- UIE LoRA dataset → UIE LoRA trainer: batches
- UIE LoRA runner → UIE LoRA trainer: runs
- Vendored PEFT tuners → UIE LoRA trainer: parameter-efficient tuning
- Continual trainer → Task metrics and ROUGE: predictions
- Task metrics and ROUGE → Continual score aggregator: task results
- UIE LoRA trainer → Pseudo branch evaluator: predictions
- Pseudo branch evaluator → Continual score aggregator: continual results
