Use project README as model card
Browse files
README.md
CHANGED
|
@@ -1,113 +1,106 @@
|
|
| 1 |
-
|
| 2 |
-
license: cc-by-nc-4.0
|
| 3 |
-
datasets:
|
| 4 |
-
- the-matter-lab/clari-data
|
| 5 |
-
tags:
|
| 6 |
-
- chemistry
|
| 7 |
-
- materials-science
|
| 8 |
-
- crystal-structure-prediction
|
| 9 |
-
- organic-crystals
|
| 10 |
-
- diffusion-model
|
| 11 |
-
- flow-matching
|
| 12 |
-
- pytorch
|
| 13 |
-
library_name: clari
|
| 14 |
-
---
|
| 15 |
-
|
| 16 |
-
# CLARI
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
| --- | --- | ---: | --- |
|
| 26 |
-
| CLARI-M | `clari-med.ckpt` | ~88M | `clari-m` |
|
| 27 |
-
| CLARI-L | `clari-large.ckpt` | ~173M | `clari-l` |
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
- sampling candidate crystal structures for an organic molecule
|
| 38 |
-
- reproducing CLARI evaluation runs on the paper test splits
|
| 39 |
-
- ranking/exporting generated crystal candidates with the CLARI tooling
|
| 40 |
|
| 41 |
-
##
|
| 42 |
|
| 43 |
-
Install
|
| 44 |
|
| 45 |
```bash
|
| 46 |
-
uv
|
| 47 |
-
--from_hub clari-m \
|
| 48 |
-
--output_dir out/ethanol \
|
| 49 |
-
--smiles 'C([H])([H])([H])C([H])([H])O[H]' \
|
| 50 |
-
--ids ethanol \
|
| 51 |
-
--copies 4 \
|
| 52 |
-
--n_samples 20
|
| 53 |
```
|
| 54 |
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
```
|
| 60 |
|
| 61 |
-
To
|
| 62 |
|
| 63 |
-
```
|
| 64 |
-
uv run
|
| 65 |
-
uv run sample-test clari-l <num_samples> <experiment_dir> --subset oxtal
|
| 66 |
```
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
## Evaluation
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
- collision checks
|
| 86 |
-
- UMA energy computation
|
| 87 |
-
- COMPACK packing similarity
|
| 88 |
-
- summary metrics used in the paper
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
#
|
|
|
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
- Results depend on copy count, molecule representation, checkpoint choice, and sampling settings.
|
| 97 |
-
- The Hub checkpoints are distributed as PyTorch Lightning checkpoint files rather than `safetensors` because they include CLARI-specific training/module state.
|
| 98 |
|
| 99 |
-
#
|
|
|
|
| 100 |
|
| 101 |
-
|
|
|
|
| 102 |
|
| 103 |
-
#
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
|
| 107 |
-
``
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
year = {2026},
|
| 112 |
-
}
|
| 113 |
```
|
|
|
|
| 1 |
+
<div align="center">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Fast Organic Crystal Structure Prediction <br> with Unit Cell Flow Matching
|
| 4 |
|
| 5 |
+
[](https://arxiv.org)
|
| 6 |
+
[](https://huggingface.co/datasets/the-matter-lab/clari-data)
|
| 7 |
|
| 8 |
+
<br>
|
| 9 |
|
| 10 |
+
<img src="https://raw.githubusercontent.com/aspuru-guzik-group/clari/main/data/overview.png" width=600>
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
</div>
|
| 13 |
|
| 14 |
+
<br>
|
| 15 |
|
| 16 |
+
This repository contains code to reproduce the paper: Fast Organic Crystal Structure Prediction with Unit Cell Flow Matching (arXiv).
|
| 17 |
|
| 18 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
## Installation
|
| 21 |
|
| 22 |
+
Install everything needed for training, sampling, ranking, and most of the evaluation pipeline:
|
| 23 |
|
| 24 |
```bash
|
| 25 |
+
uv sync
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
```
|
| 27 |
|
| 28 |
+
⚠️ To generate data and run COMPACK, we require the **CCDC SDK**, whose dependencies conflict with FairChem. Thus, some scripts run as standalone uv scripts that resolve their own isolated environments from the CCDC index. The first invocation of `uv run -s *.py ...` resolves and caches that environment. You will still need a valid CCDC license configured on the machine.
|
| 29 |
|
| 30 |
+
## Data
|
| 31 |
+
|
| 32 |
+
### Generation
|
| 33 |
+
|
| 34 |
+
We expect the final data folder to be structured as follows:
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
+
data/
|
| 38 |
+
raw/
|
| 39 |
+
csd_metadata.parquet
|
| 40 |
+
csd_conquest.parquet
|
| 41 |
+
csd/
|
| 42 |
+
config.json
|
| 43 |
+
metdata.parquet
|
| 44 |
+
{train,val,test}.pt
|
| 45 |
```
|
| 46 |
|
| 47 |
+
To generate the data, first extract the metadata of entries in CSD:
|
| 48 |
|
| 49 |
+
```
|
| 50 |
+
uv run -s scripts/data/0_metadata.py
|
|
|
|
| 51 |
```
|
| 52 |
|
| 53 |
+
This creates the `csd_metadata.parquet` file from above. Next, download **ALL** of CSD in `.mol2` and `.cif` format using ConQuest (not `csd-python-api` since it sanitizes molecules and removes some bond information) into the `csd_conquest.parquet` file. Finally, generate the `data/csd` folder with:
|
| 54 |
|
| 55 |
+
```
|
| 56 |
+
uv run python -m scripts.data.1_process --num_workers=16
|
| 57 |
+
```
|
| 58 |
|
| 59 |
+
For reference, the CSD refcodes we use and our dataset split are uploaded to [HuggingFace](https://huggingface.co/datasets/the-matter-lab/clari-data).
|
| 60 |
|
| 61 |
+
## Usage
|
| 62 |
|
| 63 |
+
The model can be trained with:
|
| 64 |
|
| 65 |
+
```
|
| 66 |
+
uv run train --help
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Checkpoints for Clari-M and Clari-L are uploaded to [HuggingFace](https://huggingface.co/the-matter-lab/clari).
|
| 70 |
+
To run inference, see the [README.md](https://github.com/aspuru-guzik-group/clari/blob/main/clari/inference/README.md) in `clari.inference`.
|
| 71 |
+
We also include a [SKILL.md](https://github.com/aspuru-guzik-group/clari/blob/main/clari/inference/SKILL.md) so that coding agents can run inference.
|
| 72 |
|
| 73 |
## Evaluation
|
| 74 |
|
| 75 |
+
### OXtal and Teaching Test Sets
|
| 76 |
|
| 77 |
+
To reproduce the paper numbers for a Hub model or local checkpoint, run the stages below in order. Each stage writes into the same `<experiment_dir>` and reads what the previous stage produced.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
```bash
|
| 80 |
+
# 0. One-time: build the GT CIF cache the standalone compack script reads
|
| 81 |
+
uv run python clari/evaluation/build_test_cifs_cache.py
|
| 82 |
|
| 83 |
+
# 1. Sample the CSD test set, creates a folder results/experiment_dir.
|
| 84 |
+
# Use clari-m, clari-l, or a local checkpoint path as the first argument.
|
| 85 |
+
uv run sample-test clari-m <num_samples> <experiment_dir> --subset <teaching/oxtal>
|
| 86 |
|
| 87 |
+
# 2. Clash check (writes collision.csv)
|
| 88 |
+
uv run collision <experiment_dir>
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
# 3. UMA energies (writes energies.csv)
|
| 91 |
+
uv run compute-energies <experiment_dir>
|
| 92 |
|
| 93 |
+
# 4. COMPACK packing similarity (writes compack.csv, isolated uv script env)
|
| 94 |
+
uv run -s clari/evaluation/compack.py <experiment_dir> --num_processes n
|
| 95 |
|
| 96 |
+
# 5. Summary table (SolC per subset, all k)
|
| 97 |
+
uv run summarize <experiment_dir>
|
| 98 |
+
```
|
| 99 |
|
| 100 |
+
### Ablations
|
| 101 |
|
| 102 |
+
The exact commands used for to train our ablated and final models can be found in `scripts/train`. After running inference as above, the metrics used for ablations are defined in:
|
| 103 |
+
|
| 104 |
+
```
|
| 105 |
+
from clari.pipelines.utils.metrics import assess_crystals_eval
|
|
|
|
|
|
|
| 106 |
```
|