> For the complete documentation index, see [llms.txt](https://docs.neurolabai.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neurolabai.io/engineering-and-scientific-assurance/model-training-overview.md).

# Model Training

This page describes how the **known-compound B0 model** was constructed. The novel-structure retriever and mechanism reasoner use separately packaged serving artifacts and have a distinct evaluation boundary.

## Training representation

For each in-KG compound, the model combines three chemical feature families:

| Feature family                   | Dimensions |
| -------------------------------- | ---------: |
| ChemBERTa-zinc representation    |        768 |
| Morgan fingerprint               |      2,048 |
| RDKit molecular descriptors      |         22 |
| **Total compound feature width** |  **2,838** |

These features enter the heterogeneous graph alongside checkpoint-selected relations among compounds, receptors, genes, regions, and ontology concepts.

## B0 backbone

The production architecture is `HGNNMultiHeadEdgeFeat`, implemented as a two-layer `HeteroConv(TransformerConv)` network with hidden width 128, four attention heads, and dropout 0.3.

```mermaid
flowchart TB
    Chemistry["2,838-d compound features"] --> GNN["B0 heterogeneous graph backbone"]
    Graph["Checkpoint KEEP relation projection"] --> GNN
    GNN --> Compound["128-d compound embedding"]
    GNN --> Receptor["128-d receptor embeddings"]
    Compound --> Attn["Receptor-attention heads"]
    Receptor --> Attn
    Compound --> Direct["Direct compound heads"]
    Attn --> Cog["Cognition"]
    Attn --> MoA["Mechanism of action"]
    Attn --> SE["Side effects"]
    Direct --> Usage["Reported usage"]
    Direct --> ATC["ATC class"]
    Direct --> Brain["392-parcel brain ranking"]
```

## Objectives and optimization

The five categorical heads—cognition, reported usage, side effects, ATC, and MoA—use InfoNCE objectives over their label spaces with temperature `0.3`. The brain head uses mean-squared error.

The frozen training recipe specifies:

* 250 full-graph epochs;
* AdamW optimizer;
* learning rate `5e-4`;
* weight decay `1e-4`; and
* independent seeds 42, 123, and 777.

The original v43.262 recipe excluded its nominal validation and test compounds from fitting. Later audit work found four chemistry-family overlaps across the historical train/test boundary, so that split must not be described as scaffold-disjoint.

## Leakage controls

The v43.262 DE-LEAK release explicitly separates message-passing relations from supervision targets. Cognition, usage, side-effect, and ATC answer relations that previously leaked target information into held-out compound embeddings are now supervision-only. Target-proxy relations are also governed by the integrity gate.

This is why older, higher cognition headlines are retired. A lower honest metric after leakage removal is a more rigorous result than a higher contaminated one.

## Integrity gates

Training-time checks cover areas such as:

* required KG release and graph invariants;
* feature and node-index alignment;
* ordered head vocabularies and supervision masks;
* split and scaffold behavior;
* forbidden target relations in the message-passing feed;
* source and license contracts; and
* content hashes for required artifacts.

Passing an integrity gate shows that the artifact obeyed the declared construction contract. It does not establish clinical validity or biological correctness.

## Chemistry-component split builder

A deterministic chemistry-component split builder supports future experiments without changing the current production checkpoint. It:

1. normalizes compounds and hashes ordered inputs;
2. groups 1,366 feature-eligible compounds by achiral Murcko scaffold;
3. connects chemistry groups when Morgan/ECFP4 Tanimoto similarity is at least 0.65; and
4. assigns whole connected components to train, validation, or test.

The recorded split contains 956 train, 204 validation, and 206 test compounds across 913 connected components and 994 raw scaffolds. Its maximum train/test Tanimoto is 0.640625. Validation and test remain separate, and split-integrity checks are required for any future model release.

This builder improves the rigor of future experiments. It does not retroactively change v43.262 metrics or create a new production model.

## Reproducibility status

The reproducibility package binds prepared data, ordered label vocabularies, runtime layout, split identity, feature statistics, and required artifact hashes. Its evaluation path separates validation, test, and held diagnostics and includes frequency and nearest-neighbor controls plus bootstrap estimates.

The currently served three-seed model remains the v43.262 family. Observational adverse-event records are not relabeled as causal side effects, incidence, or individual risk, and any future replacement requires its own release-specific evaluation.

Current serving metrics are bound to the versioned validation report distributed with the served model. Historical evaluation material does not override that artifact or represent the supported current evaluation workflow.

## Relationship to the structure route

The known-route GNN does not train a new node embedding at request time for an unseen SMILES. Structure-to-receptor estimation, chemical-neighbor retrieval, mechanism composition, and their gates use separately versioned novel-route artifacts. They require their own cohorts, calibration, and end-to-end evaluation.

***

**Current production recipe:** v43.262 DE-LEAK. New split and evaluation tooling does not retroactively change the served checkpoints or their historical metrics.

Next: [Evaluation Methods](/engineering-and-scientific-assurance/evaluation-methods.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.neurolabai.io/engineering-and-scientific-assurance/model-training-overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
