molecule-generation icon indicating copy to clipboard operation
molecule-generation copied to clipboard

Decode more than one molecule from one latent

Open cankobanz opened this issue 1 year ago • 1 comments

Hello, thank you for sharing your work.

I have a question regarding the decoding process. I'm curious about how to decode more than one molecule from a specific latent space, especially those that are neighbors with high log likelihood relative to the returned molecule.

Currently, it seems that for the same latent input, the decoded output remains unchanged, and the sampling process doesn't seem to support starting from a specified latent position:

https://github.com/microsoft/molecule-generation/blob/48d532f7e95dff822a84ffd603f41253ac07dbdd/molecule_generation/wrapper.py#L156-L165

I was considering customizing the sample method of the GeneratorWrapper to initiate from a specific latent point instead of starting from zeros. However, the provided checkpoint (GNN_Edge_MLP_MoLeR__2022-02-24_07-16-23_best.pkl) is configured for the VaeWrapper, not the GeneratorWrapper.

Note: I have taken into consideration your suggestion to add small noise to address this issue, as discussed in issue 40. However, my primary interest lies in exploring a more refined solution, specifically through adjusting the num_samples parameter here:

https://github.com/microsoft/molecule-generation/blob/48d532f7e95dff822a84ffd603f41253ac07dbdd/molecule_generation/utils/moler_decoding_utils.py#L64-L72

Thank you in advance for your assistance.

cankobanz avatar Feb 21 '24 12:02 cankobanz

Sorry, I somehow missed your question!

I was considering customizing the sample method of the GeneratorWrapper to initiate from a specific latent point instead of starting from zeros.

Given that a generator-style model was trained always receiving an all-zeros input, this may not work. I would rather use the vae-style model which has been more thoroughly validated.

As you said, you could either go with perturbing the latent code, or make decoding randomized so that it can return different results from a single latent code. The latter option is not exposed in the model wrapper, but you could modify the sampling_mode argument in MoLeRInferenceServer directly (see here). However, I'm not sure if this would give better results than the perturbation-based approach; it would be best to try both and see which one works better empirically for your usecase.

kmaziarz avatar Aug 22 '24 18:08 kmaziarz