# jubayeronrob/proactive-conversation-assistant architecture

> Architecture diagram of the GitHub repository jubayeronrob/proactive-conversation-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jubayeronrob/proactive-conversation-assistant
- Repository: https://github.com/jubayeronrob/proactive-conversation-assistant

## Overview

#### Purpose and Entry Points
This is a research/training repository for a proactive conversation assistant: Stage 1 detects dialogue moments needing intervention; Stage 2 generates short contextual hints. Primary executable entry points are `experiments/runner.py` for Stage 1, `experiments/stage2_train.py` and `experiments/stage2_eval.py` for generation, plus the end-to-end notebook `Notebooks/inference-full.ipynb`.

#### 1. Corpus Reconstruction and Canonicalization
The dataset layer converts source conversational corpora and marker annotations into tokenizer-independent, character-offset-aligned examples. It supports AMI and ICSI sources, corpus profiles/splits, marker processing, labeling, and output emission.
Paths: `pca/corpora/emit.py`, `pca/corpora/labeling.py`, `pca/corpora/ami.py`, `pca/corpora/icsi.py`.
Dataset-build validation and canonical-index generation sit outside runtime training.
Paths: `analysis/build_canonical_index.py`, `analysis/validate_v3.py`, `orchestration/recon_dataset2.py`.

#### 2. Stage 1 Gating Data and Models
Stage 1 consumes tokenized dialogue windows and binary proactive-activation labels. `pca/data.py` is the dataset/input boundary; `pca/models.py` defines decoder and baseline model integration; `pca/trainer.py` owns training/evaluation control flow. Loss variants—including focal loss for sparse triggers—are isolated in `pca/losses.py`.
Paths: `pca/data.py`, `pca/models.py`, `pca/trainer.py`, `pca/losses.py`.

#### 3. Configured Experiment Runner
Stage 1 runs are configuration-driven: YAML files select model, loss, and run parameters, and `experiments/runner.py` executes them. The experiment matrix compares decoder-only families and RoBERTa, with focal/weighted-CE ablations and resume configurations.
Paths: `experiments/runner.py`, `experiments/configs/e1-llama-32-1b-focal.yaml`, `experiments/configs/e0b-roberta-natural-512.yaml`.
Run metadata is captured through `pca/runinfo.py`; aggregate run state is represented in `results/RUN_MANIFEST.csv`.

#### 4. Retrieval and Memory-Augmented Hint Context
The system has explicit retrieval and memory modules for supplying Stage 2 with relevant conversational context rather than treating generation as a standalone prompt. Retrieval configuration generation and sweeps form the experimentation boundary around this capability.
Paths: `pca/retrieval.py`, `pca/memory.py`, `experiments/rag_sweep.py`, `analysis/make_rag_configs.py`.

#### 5. Stage 2 Hint Generation and Judging
Stage 2 trains and evaluates a generative model on gated contexts, enforcing short hint outputs and measuring generated text quality. `pca/stage2.py` is the shared Stage 2 domain layer; scripts separate training, automatic evaluation, and LLM-rubric judging.
Paths: `pca/stage2.py`, `experiments/stage2_train.py`, `experiments/stage2_eval.py`, `experiments/judge_stage2.py`.
Judge artifacts are persisted separately from model metrics.
Paths: `results/judge/`, `results/s2_model_metrics.json`.

#### 6. Evaluation, Statistical Analysis, and Research Outputs
Core scoring includes conventional evaluation plus fast scoring, rubric definitions, and dataset statistics. Analysis scripts consume results to produce tables, significance tests, diagnostics, and paper-ready figures.
Paths: `pca/evaluate.py`, `pca/fastscore.py`, `pca/rubrics.py`, `analysis/build_all.py`, `analysis/build_stage2_tables.py`.
Generated outputs feed the three LaTeX reports.
Paths: `paper/tier1_report/main.tex`, `paper/tier2_report/main.tex`, `paper/dataset2_report/main.tex`.

#### 7. Compute and External-Service Boundary
The project targets Python 3.10+ with CUDA GPUs; dependencies are declared in `requirements.txt`. Training and evaluation are dispatched to Kaggle T4/P100-style environments and Modal/remote infrastructure, with adapter/checkpoint publishing and upload workflows.
Paths: `orchestration/dispatch.py`, `orchestration/kaggle_t4.py`, `orchestration/modal_stage2.py`, `orchestration/publish_ckpt.py`.
External dependencies include LlamaPIE source data, Hugging Face model ecosystems, Kaggle GPU execution, and Modal; judge result naming also indicates Fireworks-backed judging runs.

Main entry points: [`pca/trainer.py`](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/trainer.py) (Stage 1 trainer), [`pca/corpora/emit.py`](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/corpora/emit.py) (Canonical emitter), [`experiments/stage2_eval.py`](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/stage2_eval.py) (Stage 2 evaluation), [`orchestration/dispatch.py`](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/orchestration/dispatch.py) (Remote dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_corpus["Corpus pipeline"]
  node_corpora["Corpus adapters<br/>corpus ingestion<br/>[ami.py]"]
  node_canonicalization["Canonical emitter<br/>dataset builder<br/>[emit.py]"]
  node_labeling["Marker labeling<br/>[labeling.py]"]
  node_dataset_validation["Canonical validation<br/>offline validation<br/>[validate_v3.py]"]
end

subgraph group_stage1["Stage 1 gating"]
  node_stage1_data["Gating dataset<br/>data boundary<br/>[data.py]"]
  node_stage1_models["Detector models<br/>model integration<br/>[models.py]"]
  node_losses["Trigger losses<br/>loss variants<br/>[losses.py]"]
  node_trainer["Stage 1 trainer<br/>training control<br/>[trainer.py]"]
  node_runner{{"Experiment runner<br/>CLI entry point<br/>[runner.py]"}}
  node_run_manifest[("Run manifest<br/>experiment registry<br/>[RUN_MANIFEST.csv]")]
end

subgraph group_stage2["Retrieval and Stage 2"]
  node_retrieval_memory["Retrieval and memory<br/>context augmentation<br/>[retrieval.py]"]
  node_rag_sweeps["RAG sweeps<br/>experiment driver<br/>[rag_sweep.py]"]
  node_stage2_domain["Stage 2 domain<br/>generation domain<br/>[stage2.py]"]
  node_stage2_train{{"Stage 2 training<br/>CLI entry point<br/>[stage2_train.py]"}}
  node_stage2_eval{{"Stage 2 evaluation<br/>CLI entry point<br/>[stage2_eval.py]"}}
  node_judge{{"LLM rubric judge<br/>judging entry point<br/>[judge_stage2.py]"}}
end

subgraph group_research["Evaluation and research outputs"]
  node_evaluation["Scoring and rubrics<br/>evaluation layer<br/>[evaluate.py]"]
  node_analysis["Analysis builders<br/>research analysis<br/>[build_all.py]"]
  node_reports["LaTeX reports<br/>research output<br/>[main.tex]"]
end

subgraph group_compute["Compute boundary"]
  node_dispatch{{"Remote dispatch<br/>compute orchestration<br/>[dispatch.py]"}}
end

node_corpora -->|"source conversations"| node_canonicalization
node_labeling -->|"marker labels"| node_canonicalization
node_canonicalization -->|"canonical dataset"| node_dataset_validation
node_canonicalization -->|"dialogue examples"| node_stage1_data
node_stage1_data -->|"windows and labels"| node_trainer
node_stage1_models -->|"model"| node_trainer
node_losses -->|"loss selection"| node_trainer
node_runner -->|"YAML-configured run"| node_trainer
node_trainer -->|"run metadata"| node_run_manifest
node_trainer -->|"gated dialogue moments"| node_retrieval_memory
node_rag_sweeps -->|"retrieval configurations"| node_retrieval_memory
node_retrieval_memory -->|"relevant context"| node_stage2_domain
node_stage2_domain -->|"training domain"| node_stage2_train
node_stage2_domain -->|"generation evaluation"| node_stage2_eval
node_stage2_eval -->|"generated hints"| node_judge
node_stage2_eval -->|"model outputs"| node_evaluation
node_judge -->|"rubric results"| node_evaluation
node_evaluation -->|"scores and metrics"| node_analysis
node_run_manifest -->|"experiment results"| node_analysis
node_analysis -->|"tables and figures"| node_reports
node_dispatch -->|"Stage 1 GPU jobs"| node_runner
node_dispatch -->|"Stage 2 GPU jobs"| node_stage2_train
node_dispatch -->|"remote evaluation"| node_stage2_eval

click node_corpora "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/corpora/ami.py"
click node_canonicalization "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/corpora/emit.py"
click node_labeling "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/corpora/labeling.py"
click node_dataset_validation "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/analysis/validate_v3.py"
click node_stage1_data "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/data.py"
click node_stage1_models "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/models.py"
click node_losses "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/losses.py"
click node_trainer "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/trainer.py"
click node_runner "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/runner.py"
click node_run_manifest "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/results/RUN_MANIFEST.csv"
click node_retrieval_memory "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/retrieval.py"
click node_rag_sweeps "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/rag_sweep.py"
click node_stage2_domain "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/stage2.py"
click node_stage2_train "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/stage2_train.py"
click node_stage2_eval "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/stage2_eval.py"
click node_judge "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/judge_stage2.py"
click node_evaluation "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/evaluate.py"
click node_analysis "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/analysis/build_all.py"
click node_reports "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/paper/tier1_report/main.tex"
click node_dispatch "https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/orchestration/dispatch.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_corpora,node_canonicalization,node_labeling,node_dataset_validation toneBlue
class node_stage1_data,node_stage1_models,node_losses,node_trainer,node_runner,node_run_manifest toneAmber
class node_retrieval_memory,node_rag_sweeps,node_stage2_domain,node_stage2_train,node_stage2_eval,node_judge toneMint
class node_evaluation,node_analysis,node_reports toneRose
class node_dispatch toneIndigo
```

## Components

### Corpus pipeline

Reconstructs canonical dialogue examples from AMI and ICSI.

- [Corpus adapters](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/corpora/ami.py): corpus ingestion · AMI and ICSI source conversion. · `pca/corpora/ami.py`
- [Canonical emitter](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/corpora/emit.py): dataset builder · Emits character-offset-aligned examples and labels. · `pca/corpora/emit.py`
- [Marker labeling](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/corpora/labeling.py): labeling · `pca/corpora/labeling.py`
- [Canonical validation](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/analysis/validate_v3.py): offline validation · Builds indices and validates reconstructed data. · `analysis/validate_v3.py`

### Stage 1 gating

Trains proactive-activation detectors.

- [Gating dataset](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/data.py): data boundary · Tokenized dialogue windows with binary activation labels. · `pca/data.py`
- [Detector models](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/models.py): model integration · Decoder-only and baseline model families. · `pca/models.py`
- [Trigger losses](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/losses.py): loss variants · Includes focal loss and weighted cross-entropy. · `pca/losses.py`
- [Stage 1 trainer](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/trainer.py): training control · Owns detector training and evaluation flow. · `pca/trainer.py`
- [Experiment runner](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/runner.py): CLI entry point · Executes YAML-configured Stage 1 runs. · `experiments/runner.py`
- [Run manifest](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/results/RUN_MANIFEST.csv): experiment registry · `results/RUN_MANIFEST.csv`

### Retrieval and Stage 2

Builds context and generates short hints.

- [Retrieval and memory](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/retrieval.py): context augmentation · Selects relevant conversational context for hint generation. · `pca/retrieval.py`
- [RAG sweeps](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/rag_sweep.py): experiment driver · Generates and executes retrieval configurations. · `experiments/rag_sweep.py`
- [Stage 2 domain](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/stage2.py): generation domain · Shared gated-context and short-hint logic. · `pca/stage2.py`
- [Stage 2 training](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/stage2_train.py): CLI entry point · `experiments/stage2_train.py`
- [Stage 2 evaluation](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/stage2_eval.py): CLI entry point · Automatically evaluates generated hints. · `experiments/stage2_eval.py`
- [LLM rubric judge](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/experiments/judge_stage2.py): judging entry point · Persists judge artifacts separately from model metrics. · `experiments/judge_stage2.py`

### Evaluation and research outputs

Scores experiments and produces reports.

- [Scoring and rubrics](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/pca/evaluate.py): evaluation layer · Conventional, fast, and rubric-based scoring. · `pca/evaluate.py`
- [Analysis builders](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/analysis/build_all.py): research analysis · Builds tables, significance tests, diagnostics, and figures. · `analysis/build_all.py`
- [LaTeX reports](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/paper/tier1_report/main.tex): research output · Tier and dataset reports consume generated findings. · `paper/tier1_report/main.tex`

### Compute boundary

Dispatches GPU and remote runs.

- [Remote dispatch](https://github.com/jubayeronrob/proactive-conversation-assistant/blob/main/orchestration/dispatch.py): compute orchestration · Kaggle, Modal, checkpoint publishing, and upload workflows. · `orchestration/dispatch.py`

## Connections

- Corpus adapters → Canonical emitter: source conversations
- Marker labeling → Canonical emitter: marker labels
- Canonical emitter → Canonical validation: canonical dataset
- Canonical emitter → Gating dataset: dialogue examples
- Gating dataset → Stage 1 trainer: windows and labels
- Detector models → Stage 1 trainer: model
- Trigger losses → Stage 1 trainer: loss selection
- Experiment runner → Stage 1 trainer: YAML-configured run
- Stage 1 trainer → Run manifest: run metadata
- Stage 1 trainer → Retrieval and memory: gated dialogue moments
- RAG sweeps → Retrieval and memory: retrieval configurations
- Retrieval and memory → Stage 2 domain: relevant context
- Stage 2 domain → Stage 2 training: training domain
- Stage 2 domain → Stage 2 evaluation: generation evaluation
- Stage 2 evaluation → LLM rubric judge: generated hints
- Stage 2 evaluation → Scoring and rubrics: model outputs
- LLM rubric judge → Scoring and rubrics: rubric results
- Scoring and rubrics → Analysis builders: scores and metrics
- Run manifest → Analysis builders: experiment results
- Analysis builders → LaTeX reports: tables and figures
- Remote dispatch → Experiment runner: Stage 1 GPU jobs
- Remote dispatch → Stage 2 training: Stage 2 GPU jobs
- Remote dispatch → Stage 2 evaluation: remote evaluation
