I am wondering if anyone has experience with generating molecules using machine learning in Mathematica. There are a bunch of papers these days with such applications/developments. For example, https://pubs.acs.org/doi/10.1021/acs.jcim.0c01496. Another example on Medium is https://medium.com/@sunitachoudhary103/generating-molecules-using-a-char-rnn-in-pytorch-16885fd9394b

I know about Molecule and associated chemistry functions. I am interested in how SMILES strings could be generated, perhaps, by adapting some neural networks that work for such kinds of applications.

If someone's aware of examples/tutorials that cover this, it would be great, if you could share.


  • 3
    $\begingroup$ A challenge with SMILES is guaranteeing semantic structure. Arguably, methods for representing molecular graphs like SELFIES github.com/aspuru-guzik-group/selfies might be easier to implement, as ANY generated string is valid. (These can always be translated into a corresponding SMILES) It should be straightforward to implement SELFIES using MMA term replacement (or just import the python library). Back when the paper was first posted, to understand it better I sketched out a rough demo from the appendix wolframcloud.com/obj/jschrier0/Published/… $\endgroup$ Mar 1, 2022 at 13:40
  • $\begingroup$ Thanks a lot! Do you think you could post this as an answer? $\endgroup$
    – bhopshang
    Mar 2, 2022 at 22:27
  • 1
    $\begingroup$ There is this example, Generating Molecules With SELFIES. It doesn't use machine learning explicitly, but rather shows the raw tools you would use in a ML application. $\endgroup$
    – Jason B.
    Feb 7 at 22:31

1 Answer 1


A great paper that covers this topic can be found here:

Machine Learning Methods in Chemistry

The Author uses a Markovian text generator to generate SMILES strings that are variations on a theme. The invalid SMILES are culled with a Mathematica function. The code requires Mathematica 10 or later.

  • 2
    $\begingroup$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review $\endgroup$
    – corey979
    Sep 10, 2023 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.