# qai222/llm_organic_synthesis architecture

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

- Interactive diagram: https://gitdiagram.com/qai222/llm_organic_synthesis
- Repository: https://github.com/qai222/llm_organic_synthesis

## Overview

This research repository studies converting organic-synthesis procedure text into structured reaction data with fine-tuned language models. Its main workflow prepares reaction datasets and prompt/completion examples, runs or demonstrates model inference, then evaluates structured outputs. Separate capabilities include ChemDataExtractor comparison, entity-level evaluation, and reaction-role classification. The graph preserves the documented fine-tuning capability, but its implementation was not sampled. Edges are limited to relationships supported by README statements or the source index; some subsystems therefore have no asserted connection to the main workflow.

Main entry points: [`ord/data/data_llm.py`](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/data/data_llm.py) (Prompt datasets), [`ord/evaluation/pair_evaluator.py`](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/evaluation/pair_evaluator.py) (Prediction pairing), [`ord/evaluation/evaluate_functions.py`](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/evaluation/evaluate_functions.py) (Evaluation metrics), [`ord/data/data_reaction.py`](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/data/data_reaction.py) (Reaction normalization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_procedure_sources[("Procedure datasets")]
  node_cre_export["CRE export<br/>[export_from_cre.py]"]
  node_uspto_export["USPTO export<br/>[export_from_pb.py]"]
  node_dataset_prep["Dataset preparation<br/>[prepare_cre.py]"]
  node_cot_prep["COT preparation<br/>[prepare_cot.py]"]
end

subgraph group_models["Model inference"]
  node_finetune["Model fine-tuning"]
  node_openai_format["OpenAI formatting"]
  node_openai_inference["OpenAI inference<br/>[inference.py]"]
  node_dash_demo["Interactive inference demo<br/>[parser.py]"]
  node_static_demo["Static results demo<br/>[onepage.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_cde_compare["ChemDataExtractor comparison<br/>[cde.py]"]
  node_cde_evaluation["CDE evaluation<br/>[evaluate_cde.py]"]
  node_pair_eval["Prediction pairing<br/>[pair_evaluator.py]"]
  node_eval_functions["Evaluation metrics"]
  node_main_eval["Model evaluation<br/>[evaluate_main.py]"]
  node_ner_eval["Entity evaluation<br/>[evaluate_ner.py]"]
  node_role_eval["Reaction-role classification"]
end

subgraph group_ord["Reaction data tools"]
  node_reaction_data["Reaction normalization<br/>[data_reaction.py]"]
  node_llm_data["Prompt datasets<br/>[data_llm.py]"]
  node_diff_engine["Structured diff<br/>[schema.py]"]
  node_diff_report["Diff reports<br/>[report.py]"]
end

node_researcher(("Researcher"))

node_procedure_sources -->|"exports annotations"| node_cre_export
node_procedure_sources -->|"exports reactions"| node_uspto_export
node_cre_export -->|"uses reaction models"| node_reaction_data
node_uspto_export -->|"uses reaction models"| node_reaction_data
node_dataset_prep -->|"builds examples"| node_llm_data
node_cot_prep -->|"builds examples"| node_llm_data
node_llm_data -->|"converts reactions"| node_reaction_data
node_llm_data -.->|"supplies training data"| node_finetune
node_llm_data -.->|"formats examples"| node_openai_format
node_openai_format -.->|"prepares model input"| node_openai_inference
node_researcher -.->|"requests inference"| node_dash_demo
node_researcher -->|"views results"| node_static_demo
node_openai_inference -->|"provides precomputed results"| node_static_demo
node_cde_compare -->|"evaluated by"| node_cde_evaluation
node_main_eval -->|"uses metrics"| node_eval_functions
node_ner_eval -->|"uses metrics"| node_eval_functions
node_role_eval -->|"uses metrics"| node_eval_functions
node_role_eval -->|"builds evaluation pairs"| node_pair_eval
node_eval_functions -->|"evaluates pairs"| node_pair_eval
node_pair_eval -->|"compares structures"| node_diff_engine
node_pair_eval -->|"reports differences"| node_diff_report
node_diff_report -->|"renders differences"| node_diff_engine

click node_procedure_sources "https://github.com/qai222/llm_organic_synthesis/tree/main/workplace_data"
click node_cre_export "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/cre/export_from_cre.py"
click node_uspto_export "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/uspto/export_from_pb.py"
click node_dataset_prep "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/prepare_cre.py"
click node_cot_prep "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/prepare_cot.py"
click node_reaction_data "https://github.com/qai222/llm_organic_synthesis/blob/main/ord/data/data_reaction.py"
click node_llm_data "https://github.com/qai222/llm_organic_synthesis/blob/main/ord/data/data_llm.py"
click node_finetune "https://github.com/qai222/llm_organic_synthesis/tree/main/workplace_finetune"
click node_openai_format "https://github.com/qai222/llm_organic_synthesis/blob/main/hackathon/models_openai/convert_data_to_openai_format.py"
click node_openai_inference "https://github.com/qai222/llm_organic_synthesis/blob/main/hackathon/models_openai/inference.py"
click node_dash_demo "https://github.com/qai222/llm_organic_synthesis/blob/main/demo_apps/dash_app/pages/parser.py"
click node_static_demo "https://github.com/qai222/llm_organic_synthesis/blob/main/demo_apps/github_page/onepage.py"
click node_cde_compare "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_cde/cde.py"
click node_cde_evaluation "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_cde/evaluate_cde.py"
click node_pair_eval "https://github.com/qai222/llm_organic_synthesis/blob/main/ord/evaluation/pair_evaluator.py"
click node_diff_engine "https://github.com/qai222/llm_organic_synthesis/blob/main/ord/diff/schema.py"
click node_diff_report "https://github.com/qai222/llm_organic_synthesis/blob/main/ord/diff/report.py"
click node_eval_functions "https://github.com/qai222/llm_organic_synthesis/blob/main/ord/evaluation/evaluate_functions.py"
click node_main_eval "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_evaluation/evaluate_main.py"
click node_ner_eval "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_evaluation/evaluate_ner.py"
click node_role_eval "https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_rclf/reaction_role_clf.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_procedure_sources,node_cre_export,node_uspto_export,node_dataset_prep,node_cot_prep toneBlue
class node_finetune,node_openai_format,node_openai_inference,node_dash_demo,node_static_demo toneAmber
class node_cde_compare,node_cde_evaluation,node_pair_eval,node_eval_functions,node_main_eval,node_ner_eval,node_role_eval toneMint
class node_reaction_data,node_llm_data,node_diff_engine,node_diff_report toneRose
class node_researcher toneIndigo
```

## Components

### Data preparation

- [Procedure datasets](https://github.com/qai222/llm_organic_synthesis/tree/main/workplace_data): `workplace_data`
- [CRE export](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/cre/export_from_cre.py): `workplace_data/cre/export_from_cre.py`
- [USPTO export](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/uspto/export_from_pb.py): `workplace_data/uspto/export_from_pb.py`
- [Dataset preparation](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/prepare_cre.py): `workplace_data/prepare_cre.py`
- [COT preparation](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_data/prepare_cot.py): `workplace_data/prepare_cot.py`

### Model inference

- [Model fine-tuning](https://github.com/qai222/llm_organic_synthesis/tree/main/workplace_finetune): `workplace_finetune`
- [OpenAI formatting](https://github.com/qai222/llm_organic_synthesis/blob/main/hackathon/models_openai/convert_data_to_openai_format.py): `hackathon/models_openai/convert_data_to_openai_format.py`
- [OpenAI inference](https://github.com/qai222/llm_organic_synthesis/blob/main/hackathon/models_openai/inference.py): `hackathon/models_openai/inference.py`
- [Interactive inference demo](https://github.com/qai222/llm_organic_synthesis/blob/main/demo_apps/dash_app/pages/parser.py): `demo_apps/dash_app/pages/parser.py`
- [Static results demo](https://github.com/qai222/llm_organic_synthesis/blob/main/demo_apps/github_page/onepage.py): `demo_apps/github_page/onepage.py`

### Evaluation

- [ChemDataExtractor comparison](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_cde/cde.py): `workplace_cde/cde.py`
- [CDE evaluation](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_cde/evaluate_cde.py): `workplace_cde/evaluate_cde.py`
- [Prediction pairing](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/evaluation/pair_evaluator.py): `ord/evaluation/pair_evaluator.py`
- [Evaluation metrics](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/evaluation/evaluate_functions.py): `ord/evaluation/evaluate_functions.py`
- [Model evaluation](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_evaluation/evaluate_main.py): `workplace_evaluation/evaluate_main.py`
- [Entity evaluation](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_evaluation/evaluate_ner.py): `workplace_evaluation/evaluate_ner.py`
- [Reaction-role classification](https://github.com/qai222/llm_organic_synthesis/blob/main/workplace_rclf/reaction_role_clf.py): `workplace_rclf/reaction_role_clf.py`

### Reaction data tools

- [Reaction normalization](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/data/data_reaction.py): `ord/data/data_reaction.py`
- [Prompt datasets](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/data/data_llm.py): `ord/data/data_llm.py`
- [Structured diff](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/diff/schema.py): `ord/diff/schema.py`
- [Diff reports](https://github.com/qai222/llm_organic_synthesis/blob/main/ord/diff/report.py): `ord/diff/report.py`

### Other components

- **Researcher**

## Connections

- Procedure datasets → CRE export: exports annotations (evidence: `readme.md`)
- Procedure datasets → USPTO export: exports reactions (evidence: `readme.md`)
- CRE export → Reaction normalization: uses reaction models (evidence: `workplace_data/cre/export_from_cre.py`)
- USPTO export → Reaction normalization: uses reaction models (evidence: `workplace_data/uspto/export_from_pb.py`)
- Dataset preparation → Prompt datasets: builds examples (evidence: `workplace_data/prepare_cre.py`)
- COT preparation → Prompt datasets: builds examples (evidence: `workplace_data/prepare_cot.py`)
- Prompt datasets → Reaction normalization: converts reactions (evidence: `ord/data/data_llm.py`)
- Prompt datasets → Model fine-tuning: supplies training data (evidence: `readme.md`)
- Prompt datasets → OpenAI formatting: formats examples (evidence: `readme.md`)
- OpenAI formatting → OpenAI inference: prepares model input (evidence: `readme.md`)
- Researcher → Interactive inference demo: requests inference (evidence: `readme.md`)
- Researcher → Static results demo: views results (evidence: `readme.md`)
- OpenAI inference → Static results demo: provides precomputed results (evidence: `readme.md`)
- ChemDataExtractor comparison → CDE evaluation: evaluated by (evidence: `workplace_cde/evaluate_cde.py`)
- Model evaluation → Evaluation metrics: uses metrics (evidence: `workplace_evaluation/evaluate_main.py`)
- Entity evaluation → Evaluation metrics: uses metrics (evidence: `workplace_evaluation/evaluate_ner.py`)
- Reaction-role classification → Evaluation metrics: uses metrics (evidence: `workplace_rclf/reaction_role_clf.py`)
- Reaction-role classification → Prediction pairing: builds evaluation pairs (evidence: `workplace_rclf/reaction_role_clf.py`)
- Evaluation metrics → Prediction pairing: evaluates pairs (evidence: `ord/evaluation/evaluate_functions.py`)
- Prediction pairing → Structured diff: compares structures (evidence: `ord/evaluation/pair_evaluator.py`)
- Prediction pairing → Diff reports: reports differences (evidence: `ord/evaluation/pair_evaluator.py`)
- Diff reports → Structured diff: renders differences (evidence: `ord/diff/report.py`)
