Skip to content

Commit 169858e

Browse files
jandomjnwei
andauthored
docs: how to get model embeddings (s_i, z_ij) (#105)
* docs: how to get model embeddings (s_i, z_ij) * update inference.md * Add runner.yml settings for outputing model embeddings Added documentation for saving model embeddings * Update docs/source/Inference.md Co-authored-by: Jennifer Wei <[email protected]> --------- Co-authored-by: Jennifer Wei <[email protected]>
1 parent 359e6fd commit 169858e

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

docs/source/Inference.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Coming soon:
7171
- Polymeric ligands such as glycans
7272

7373

74-
## 2. Pre-requisites:
74+
## 2. Pre-requisites
7575

7676
- OpenFold3 Conda Environment. See {ref}`OpenFold3 Installation <openfold3-installation>` for instructions on how to build this environment.
7777
- OpenFold3 Model Parameters. See {ref}`OpenFold3 Parameters <openfold3-parameters>` for how to download these parameters.
@@ -258,6 +258,16 @@ output_writer_settings:
258258

259259
---
260260

261+
(output-model-embeddings)=
262+
#### 📦 Output single and pair model embeddings
263+
To save model embeddings, add the field `write_latent_outputs` to the `output_writer_settings` i.e.:
264+
```yaml
265+
output_writer_settings:
266+
write_latent_outputs: True
267+
```
268+
269+
---
270+
261271
(inference-low-memory-mode)=
262272
#### 🧠 Low Memory Mode
263273
To run inference on larger queries to run on limited memory, add the following to apply the [model presets](https://github.com/aqlaboratory/openfold-3/blob/main/openfold3/projects/of3_all_atom/config/model_setting_presets.yml) to run in low memory mode.
@@ -512,6 +522,16 @@ When processing multimer inputs (e.g., hemoglobin α + β chains), OpenFold3 aut
512522
- Stores raw alignments in `raw/paired/` temporarily
513523
- Converts them into per-chain `.npz` alignments in [`paired/`](https://huggingface.co/OpenFold/OpenFold3/tree/main/examples/output_multimer_with_colabfold_msas/colabfold_msas/paired)
514524

525+
### 4.5 Embeddings
515526

527+
At inference you can instruct the model to produce the pair-rep and single-rep embeddings by {ref}`adjusting the output_writer_settings in your runner.yaml <output-model-embeddings>`.
516528

529+
This will cause the model to produce a `*_latent_output.pt`, which can be loaded like so and has the following shape.
530+
531+
```python
532+
output = torch.load("*_latent_output.pt")
533+
print(output.keys())
534+
["si_trunk", "zij_trunk", "atom_positions_predicted"]
535+
```
517536

537+
If you want to change these outputs, the code is in the [model.py](../../openfold3/projects/of3_all_atom/model.py#L384-L388)

0 commit comments

Comments
 (0)