MET molecular embeddings and fine-tuning library.
Project description
mint258-met
mint258-met packages the fine-tuning-facing part of MET as an installable Python library.
The package focuses on:
- loading the released MET pretrained encoder from Hugging Face
- producing atom-level embeddings with shape
[N, D] - fine-tuning on user CSV or XYZ data with built-in dataloaders
- exposing both a default prediction head and custom-head injection
- controlling which encoder blocks remain trainable during fine-tuning
Install
pip install mint258-met
For local development inside this repository:
pip install -e ./PyPI
Core APIs
from met import METEncoder, METFineTuner
Atom Embeddings
encoder = METEncoder.from_pretrained()
atom_embeddings = encoder.embed_smiles("CCO", num_conformers=4)
print(atom_embeddings.shape) # [N, D]
METEncoder returns atom-level embeddings with shape [N, D], where N is the number of atoms and D is the MET embedding dimension from the pretrained checkpoint.
Supported encoder convenience methods:
embed_smiles(smiles, ...)embed_xyz(path, ...)embed_smiles_batch(smiles_list, ...)embed_data(batch_or_graph)
Fine-Tuning
model = METFineTuner.from_pretrained(
output_dim=1,
hidden_dim=256,
layers=2,
dropout=0.1,
pooling_time="after_last_layer",
pooling_method="attention",
normalization="layernorm",
)
model.set_trainable_encoder_blocks(trainable_blocks=1)
history = model.fit_csv(
csv_path="my_dataset.csv",
target_columns=["target"],
smiles_column="smiles",
num_conformers=8,
epochs=5,
batch_size=8,
)
Default Prediction Head
The default head is controlled by the following arguments in METFineTuner.from_pretrained(...) or build_default_head(...):
output_dim: number of downstream targetshidden_dim: hidden width used by the default headlayers: number of feed-forward blocksdropout: dropout used inside the default headpooling_time:"before_head"or"after_last_layer"pooling_method:"attention","mean","sum", or"max"normalization:None,"layernorm", or"batchnorm"
pooling_time="after_last_layer" means node embeddings are transformed first and pooled at the end.
pooling_time="before_head" means raw node embeddings are pooled first and the graph representation is processed afterward.
Choosing Trainable Encoder Layers
METFineTuner exposes three layer-control styles:
freeze_encoder(): train only the downstream headunfreeze_encoder(): fine-tune the full backboneset_trainable_encoder_blocks(trainable_blocks=...): unfreeze the lastkinteraction blocks plus optional projection layersset_trainable_modules([...]): explicitly unfreeze named encoder modules
You can inspect available module names with:
print(model.list_encoder_modules())
Custom Prediction Heads
If you want to replace the default head, pass a custom torch.nn.Module to METFineTuner.from_pretrained(head=...) or later call replace_head(...).
The custom head should accept:
node_embeddings: shape[batch, max_nodes, dim]mask: shape[batch, max_nodes]
and return:
- predictions of shape
[batch, output_dim]
Built-In Fine-Tuning Helpers
For downstream work the package provides:
fit_csv(...)fit_xyz(...)fit_dataset(...)predict_csv(...)predict_xyz(...)predict_smiles(...)evaluate_csv(...)evaluate_xyz(...)evaluate_dataset(...)
CSV Example
from met import METFineTuner
model = METFineTuner.from_pretrained(
output_dim=2,
hidden_dim=256,
layers=3,
dropout=0.1,
pooling_time="after_last_layer",
pooling_method="attention",
normalization="layernorm",
)
model.set_trainable_encoder_blocks(trainable_blocks=2)
history = model.fit_csv(
csv_path="downstream.csv",
smiles_column="smiles",
target_columns=["property_a", "property_b"],
num_conformers=8,
conformer_seed=2024,
use_uff_optimization=True,
epochs=10,
batch_size=16,
learning_rate=1e-4,
)
XYZ Example
from met import METFineTuner
model = METFineTuner.from_pretrained(output_dim=1)
model.set_trainable_encoder_blocks(trainable_blocks=1)
history = model.fit_xyz(
root="data/QM7/train_database_300",
target_columns=["atomization_energy"],
epochs=5,
batch_size=8,
)
Hugging Face Assets
- Dataset:
https://huggingface.co/datasets/Mint258/MET-dateset - Models:
https://huggingface.co/Mint258/MET-models
Project Links
- GitHub:
https://github.com/mint258/MET - Paper DOI:
https://doi.org/10.1039/D5ME00173K
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mint258_met-0.1.0.tar.gz.
File metadata
- Download URL: mint258_met-0.1.0.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6deab1e26d0e92332a2b533a17a065c1c1c8a890c7d930d20677098abb778fca
|
|
| MD5 |
dac0c8dc393cb8abdfa3fbd6e024792b
|
|
| BLAKE2b-256 |
350832ac6a62650758fc800458c57eb1f9794f7ef102beafaef2a3d4bfe3990c
|
File details
Details for the file mint258_met-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mint258_met-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dc888a89ea0b7238bdea6d27fd13bc36c7b22cefec9f47db92616939bffd8f8
|
|
| MD5 |
1177b632cf18d52da5093587355d3135
|
|
| BLAKE2b-256 |
82c6c8f99795452de173525ab730ac662507191296c23371c3eeae3a4897f478
|