Title: LEARNING A GENERATIVE MODEL FOR VALIDITY IN COMPLEX DISCRETE STRUCTURES

Abstract: Deep generative models have been successfully used to learn representations for high-dimensional discrete spaces by representing discrete objects as sequences and employing powerful sequence-based deep models. Unfortunately, these sequencebased models often produce invalid sequences: sequences which do not represent any underlying discrete structure; invalid sequences hinder the utility of such models. As a step towards solving this problem, we propose to learn a deep recurrent validator model, which can estimate whether a partial sequence can function as the beginning of a full, valid sequence. This validator provides insight as to how individual sequence elements influence the validity of the overall sequence, and can be used to constrain sequence based models to generate valid sequences -and thus faithfully model discrete objects. Our approach is inspired by reinforcement learning, where an oracle which can evaluate validity of complete sequences provides a sparse reward signal. We demonstrate its effectiveness as a generative model of Python 3 source code for mathematical expressions, and in improving the ability of a variational autoencoder trained on SMILES strings to decode valid molecular structures.

1. INTRODUCTION:

Deep generative modeling has seen many successful recent developments, such as producing realistic images from noise (Radford et al., 2015) and creating artwork (Gatys et al., 2016) . We find particularly promising the opportunity to leverage deep generative models for search in high-dimensional discrete spaces (Gómez-Bombarelli et al., 2016b; Kusner et al., 2017) . Discrete search is at the heart of problems in drug discovery (Gómez-Bombarelli et al., 2016a) , natural language processing (Bowman et al., 2016; Guimaraes et al., 2017) , and symbolic regression (Kusner et al., 2017) .

The application of deep modeling to search involves 'lifting' the search from the discrete space to a continuous space, via an autoencoder (Rumelhart et al., 1985) . An autoencoder learns two mappings: 1) a mapping from discrete space to continuous space called an encoder; and 2) a reverse mapping from continuous space back to discrete space called a decoder. The discrete space is presented to the autoencoder as a sequence in some formal language -for example, in Gómez-Bombarelli et al. (2016b) molecules are encoded as SMILES strings -and powerful sequential models (e.g., LSTMs (Hochreiter & Schmidhuber, 1997) GRUs (Cho et al., 2014) , DCNNs (Kalchbrenner et al., 2014) ) are applied to the string representation. When employing these models as encoders and decoders, generation of invalid sequences is however possible, and using current techniques this happens frequently. Kusner et al. (2017) aimed to fix this by basing the sequential models on parse tree representations of the discrete structures, where externally specified grammatical rules assist the model in the decoding process. This work boosted the ability of the model to produce valid sequences 

(x 1 ) (x 2 ) (x 3 ) (x 4 )

RNN cell sequence inputs:

Figure 1 : The recurrent model used to approximate the Q-function. A hypothetical logistic function activation is shown for each character in C. Here the set of characters is the SMILES alphabet and we use the first 3 characters of the molecule in figure 3 as the input example. The initial character is predicted from the first hidden state, and the LSTM continues until the end of the sequence.

during decoding, but its performance achieved by this method leaves scope for improvement, and the method requires hand-crafted grammatical rules for each application domain.

In this paper, we propose a generative approach to modeling validity that can learn the validity constraints of a given discrete space. We show how concepts from reinforcement learning may be used to define a suitable generative model and how this model can be approximated using sequencebased deep learning techniques. To assist in training this generative model we propose two data augmentation techniques. Where no labeled data set of valid and invalid sequences is available, we propose a novel approach to active learning for sequential tasks inspired by classic mutualinformation-based approaches (Houlsby et al., 2011; Hernández-Lobato et al., 2014) . In the context of molecules, where data sets containing valid molecule examples do exist, we propose an effective data augmentation process based on applying minimal perturbations to known-valid sequences. These two techniques allow us to rapidly learn sequence validity models that can be used as a) generative models, which we demonstrate in the context of Python 3 mathematical expressions and b) a grammar model for character-based sequences, that can drastically improve the ability of deep models to decode valid discrete structures from continuous representations. We demonstrate the latter in the context of molecules represented as SMILES strings.

2. A MODEL FOR SEQUENCE VALIDITY:

To formalise the problem we denote the set of discrete sequences of length T by X = {(x 1 , . . . , x T ) :

x t ∈ C} using an alphabet C = {1, . . . , C} of size C. Individual sequences in X are denoted x 1:T . We assume the availability of a validator v : X → {0, 1}, an oracle which can tell us whether a given sequence is valid. It is important to note that such a validator gives very sparse feedback: it can only be evaluated on a complete sequence. Examples of such validators are compilers for programming languages (which can identify syntax and type errors) and chemo-informatics software for parsing SMILES strings (which identify violations of valence constraints). Running the standard validity checker v(x 1:T ) on a partial sequence or subsequence (e.g., the first t < T characters of a computer program) does not in general provide any indication as to whether the complete sequence of length T is valid.

We aim to obtain a generative model for the sequence set X + = {x 1:T ∈ X : v(x 1:T ) = 1}, the subset of valid sequences in X . To achieve this, we would ideally like to be able to query a more-informative function ṽ(x 1:t ) which operates on prefixes x 1:t of a hypothetical longer sequence x 1:T and outputs ṽ(x 1:t ) = 1 if there exists a suffix x t+1:T such that v([x 1:t , x t+1:T ]) = 1, 0 otherwise (1)

where [x 1:t , x t+1:T ] concatenates a prefix and a suffix to form a complete sequence. The function ṽ(x 1:t ) can be used to determine whether a given prefix can ever successfully yield a valid outcome.

Note that we are indifferent to how many suffixes yield valid sequences. With access to ṽ(x 1:t ), we could create a generative model for X + which constructs sequences from left to right, a single character at a time, using ṽ(x 1:t ) to provide early feedback as to which of the next character choices will surely not lead to a "dead end" from which no valid sequence can be produced.

We frame the problem of modeling X + as a Markov decision process (Sutton & Barto, 1998) for which we train a reinforcement learning agent to select characters sequentially in a manner that avoids producing invalid sequences. At time t = 1, . . . , T , the agent is in state x <t = x 1:t-1 and can take actions x t ∈ C. At the end of an episode, following action x T , the agent receives a reward of v(x 1:T ).

Since in practice we are only able to evaluate v(x 1:T ) in a meaningful way on complete sequences, the agent does not receive any reward at any of the intermediate steps t < T . The optimal Q-function Q (s, a) (Watkins, 1989), a function of a state s and an action a, represents the expected reward of an agent following an optimal policy which takes action a at state s. This optimal Q-function assigns value 1 to actions a = x t in state s = x <t for which there exists a suffix x t+1:T such that [x 1:t , x t+1:T ] ∈ X + , and value 0 to all other state/action pairs. This behaviour exactly matches the desired prefix validator in (1), that is, Q (x <t , x t ) = ṽ(x 1:t ), and so for the reinforcement learning environment as specified, learning ṽ(x 1:t ) corresponds to learning the Q-function.

Having access to Q would allow us to obtain a generative model for X + . In particular, an agent following any optimal policy π (x <t ) = argmax xt∈C Q (x <t , x t ) will always generate valid sequences. If we sample uniformly at random across all optimal actions at each time t = 1, . . . , T , we obtain the joint distribution given by

EQUATION

where Z(x <t ) = xt Q (x <t , x t ) are the per-timestep normalisation constants. This distribution allows us to sample sequences x 1:T in a straightforward manner by sequentially selecting characters x t ∈ C given the previously selected ones in x <t .

In this work we focus on learning an approximation to (2). For this, we use recurrent neural networks, which have recently shown remarkable empirical success in the modeling of sequential data, e.g., in natural language processing applications (Sutskever et al., 2014) . We approximate the optimal Qfunction with a long-short term memory (LSTM) model (Hochreiter & Schmidhuber, 1997 ) that has one output unit per character in C, with each output unit using a logistic activation function (see figure 1 ), such that the output is in the closed interval [0, 1]. We denote by y(x t |x <t , w) the value at time t of the LSTM output unit corresponding to character x t when the network weights are w the input is the sequence x <t . We interpret the neural network output y(x t |x <t , w) as p(Q (x <t , x t ) = 1), that is, as the probability that action x t can yield a valid sequence given that the current state is x <t .

Within our framing a sequence x 1:T will be valid according to our model if every action during the sequence generation process is permissible, that is, if Q (x <t , x t ) = 1 for t = 1, . . . , T . Similarly, we consider that the sequence x 1:T will be invalid if at least one action during the sequence generation process is not valid1 , that is, if Q (x <t , x t ) = 0 at least once for t = 1, . . . , T . This specifies the following log-likelihood function given a training set

EQUATION

where, following from the above characterisation of valid and invalid sequences, we define

EQUATION

according to our model's predictions. The log-likelihood (3) can be optimised using backpropagation and stochastic gradient descent and, given sufficient model capacity, results in a maximiser ŵ such that y(

x t |x <t , ŵ) ≈ Q (x <t , x t ).

Instead of directly maximising (3), we can follow a Bayesian approach to obtain estimates of uncertainty in the predictions of our LSTM model. For this, we can introduce dropout layers which stochastically zero-out units in the input and hidden layers of the LSTM model according to a Bernoulli distribution (Gal & Ghahramani, 2016) . Under the assumption of a Gaussian prior p(w) over weights, the resulting stochastic process yields an implicit approximation q(w) to the posterior distribution p(w|D) ∝ exp(L(w|D))p(w). We do this to obtain uncertainty estimates, allowing us to perform efficient active learning, as described in section 3.1.

3. ONLINE GENERATION OF SYNTHETIC TRAINING DATA:

One critical aspect of learning w as described above is how to generate the training set D in a sensible manner. A naïve approach could be to draw elements from X uniformly at random. However, in many cases, X contains only a tiny fraction of valid sequences and the uniform sampling approach produces extremely unbalanced sets which contain very little information about the structure of valid sequences. While rejection sampling can be used to increase the number of positive samples, the resulting additional cost makes such an alternative infeasible in most practical cases. The problem gets worse as the length of the sequences considered T increases since |X | will always grow as |C| T , while |X + | will typically grow at a lower rate.

We employ two approaches for artificially constructing balanced sets that permit learning these models in far fewer samples than |C| T . In settings where we do not have a corpus of known valid sequences, Bayesian active learning can automatically construct the training set D. This method works by iteratively selecting sequences in X that are maximally informative about the model parameters w given the data collected so far (MacKay, 1992) . When we do have a set of known valid sequences, we use these to seed a process for generating balanced sets by applying random perturbations to valid sequences.

3.1. ACTIVE LEARNING:

Let x 1:T denote an arbitrary sequence and let y be the unknown binary label indicating whether x 1:T is valid or not. Our model's predictive distribution for y, that is, p(y|x 1:T , w) is given by ( 4). The amount of information on w that we expect to gain by labeling and adding x 1:T to D can be measured in terms of the expected reduction in the entropy of the posterior distribution p(w|D). That is,

EQUATION

where H(•) computes the entropy of a distribution. This formulation of the entropy-based active learning criterion is, however, difficult to approximate, because it requires us to condition on x 1:Teffectively . To obtain a simpler expression we follow Houlsby et al. (2011) and note that α(x 1:T ) is equal to the mutual information between y and w given x 1:T and D

EQUATION

which is easier to work with as the required entropy is now that of Bernoulli predictive distributions, an analytic quantity. Let B(p) denote a Bernoulli distribution with probability p, and with probability mass p z (1p) 1-z for values z ∈ {0, 1}. The entropy of B(p) can be easily obtained as

EQUATION

The expectation with respect to p(w|D) can be easily approximated by Monte Carlo. We could attempt to sequentially construct D by optimising (6). However, this optimisation process would still be difficult, as it would require evaluating α(x 1:T ) exhaustively on all the elements of X . To avoid this, we follow a greedy approach and construct our informative sequence in a sequential manner. In particular, at each time step t = 1, . . . , T , we select x t by optimising the mutual information between w and Q (x <t , x t ), where x <t denotes here the prefix already selected at previous steps of the optimisation process. This mutual information quantity is denoted by α(x t |x <t ) and its expression is given by

EQUATION

)

The generation of an informative sequence can then be performed efficiently by sequentially optimising ( 8), an operation that requires only |C| × T evaluations of α(x t |x <t ).

To obtain an approximation to (8), we first approximate the posterior distribution p(w|D) with q(w) and then estimate the expectations in (8) by Monte Carlo using K samples drawn from q(w). The resulting estimator is given by

EQUATION

where w 1 , . . . , w K ∼ q(w) and g(•) is defined in (7). The nonlinearity of g(•) means that our Monte Carlo approximation is biased, but still consistent. We found that reasonable estimates can be obtained even for small K. In our experiments we use K = 16.

The iterative procedure just described is designed to produce a single informative sequence. In practice, we would like to generate a batch of informative and diverse sequences. The reason for this is that, when training neural networks, processing a batch of data is computationally more efficient than individually processing multiple data points. To construct a batch with L informative sequences, we propose to repeat the previous iterative procedure L times. To introduce diversity in the batch-generation process, we "soften" the greedy maximisation operation at each step by injecting a small amount of noise in the evaluation of the objective function (Finkel et al., 2006) . Besides introducing diversity, this can also lead to better overall solutions than those produced by the noiseless greedy approach (Cho, 2016) . We introduce noise into the greedy selection process by sampling from

EQUATION

for each t = 1, . . . , T , which is a Boltzmann distribution with sampling temperature θ. By adjusting this temperature parameter, we can trade off the diversity of samples in the batch vs. their similarity.

3.2. DATA AUGMENTATION:

In some settings, such as the molecule domain we will consider later, we have databases of knownvalid examples (e.g. collections of known drug-like molecules), but rarely are sets of invalid examples available. Obtaining invalid sequences may seem trivial, as invalid samples may be obtained by sampling uniformly from X , however these are almost always so far from any valid sequence that they carry little information about the boundary of valid and invalid sequences. Using just a known data set also carries the danger of overfitting to the subset of X + covered by the data.

We address this by perturbing sequences from a database of valid sequences, such that approximately half of the thus generated sequences are invalid. These perturbed sequences x 1:T are constructed by setting each x t to be a symbol selected independently from C with probability γ, while remaining the original x t with probability 1γ. In expectation this changes γT entries in the sequence. We choose γ = 0.05, which results in synthetic data that is approximately 50% valid.

4. EXPERIMENTS:

We test the proposed validity checker in two environments. First, we look at fixed length Python 3 mathematical expressions, where we derive lower bounds for the support of our model and compare the performance of active learning with that achieved by a simple passive approach. Secondly, we look at molecular structures encoded into string representation, where we utilise existing molecule data sets together with our proposed data augmentation method to learn the rules governing molecule string validity. We test the efficacy of our validity checker on the downstream task of decoding valid molecules from a continuous latent representation given by a variational autoencoder.

4.1. MATHEMATICAL EXPRESSIONS:

We illustrate the utility of the proposed validity model and sequential Bayesian active learning in the context of Python 3 mathematical expressions. Here, X consists of all length 25 sequences that can be constructed from the alphabet of numbers and symbols shown in table 1. The validity of any given expression is determined using the Python 3 eval function: a valid expression is one that does not raise an exception when evaluated. Measuring model performance Within this problem domain we do not assume the existence of a data set of positive examples. Without a validation data set to measure performance on, we compare the models in terms of their capability to provide high entropy distributions over valid sequences.

We define a generative procedure to sample from the model and measure the validity and entropy of the samples. To sample stochastically, we use a Boltzmann policy, i.e. a policy which samples next actions according to

EQUATION

)

where τ is a temperature constant that governs the trade-off between exploration and exploitation. Note that this is not the same as the Boltzmann distribution used as a proposal generation scheme during active learning, which was defined not on Q-function values but rather on the estimated mutual information.

We obtain samples {x (1) , . . . , x (N ) } τi for a range of temperatures τ i and compute the validity fraction and entropy of each set of samples. These points now plot a curve of the trade-off between validity and entropy that a given model provides. Without a preferred level of sequence validity, the area under this validity-entropy curve (V-H AUC) can be utilised as a metric of model quality. To provide some context for the entropy values, we estimate an information theoretic lower bound for the fraction of the set X + that our model is able to generate. This translates to upper bounding the false negative rate for our model.

Experimental setup and results:

We train two models using our proposed Q-function method: passive, where training sequences are sampled from a uniform distribution over X , and active, where we use the procedure described in section 3.1 to select training sequences. The two models are otherwise identical.

Both trained models give a diverse output distribution over valid sequences (figure 2 ). However, as expected, we find that the active method is able to learn a model of sequence validity much more rapidly than sampling uniformly from X , and the corresponding converged model is capable of generating many more distinct valid sequences than that trained using the passive method. In we present lower bounds on the support of the two respective models. The details of how this lower bound is computed can be found in appendix A. Note that the overhead of the active learning data generating procedure is minimal: processing 10,000 takes 31s with passive versus 37s with active.

4.2. SMILES MOLECULES:

SMILES strings (Weininger, 1970) are one of the most common representations for molecules, consisting of an ordering of atoms and bonds. It is attractive for many applications because it maps the graphical representation of a molecule to a sequential representation, capturing not just its chemical composition but also structure. This structural information is captured by intricate dependencies in SMILES strings based on chemical properties of individual atoms and valid atom connectivities. For instance, the atom Bromine can only bond with a single other atom, meaning that it may only occur at the beginning or end of a SMILES string, or within a so-called 'branch', denoted by a bracketed expression (Br). We illustrate some of these rules, including a Bromine branch, in figure 3 , with a graphical representation of a molecule alongside its corresponding SMILES string. There, we also show examples of how a string may fail to form a valid SMILES molecule representation. The full SMILES alphabet is presented in table 3 . 

B C N O S P F I H Cl Br @ =#/\12345678 -+ ()[]

The intricacy of SMILES strings makes them a suitable testing ground for our method. There are two technical distinctions to make between this experimental setup and the previously considered Python 3 mathematical expressions. As there exist databases of SMILES strings, we leverage those by using the data augmentation technique described in section 3.2. The main data source considered is the ZINC data set Irwin & Shoichet (2005), as used in Kusner et al. (2017) . We also use the USPTO 15k reaction products data (Lowe, 2014) and a set of molecule solubility information (Huuskonen, 2000) as withheld test data. Secondly, whereas we used fixed length Python 3 expressions in order to obtain coverage bounds, molecules are inherently of variable length. We deal with this by padding all molecules to fixed length.

Validating grammar model accuracy As a first test of the suitability of our proposed validity model, we train it on augmented ZINC data and examine the accuracy of its predictions on a withheld test partition of that same data set as well as the two unseen molecule data sets. Accuracy is the ability of the model to accurately recognise which perturbations make a certain SMILES string invalid, and which leave it valid -effectively how well the model has captured the grammar of SMILES strings in the vicinity of the data manifold. Recalling that a sequence is invalid if ṽ(x 1:t ) = 0 at any t ≤ T , we consider the model prediction for molecule x 1:T to be T t=1 I [y(x t |x <t , w) ≥ 0.5], and compare this to its true label as given by rdkit, a chemical informatics software. The results are encouraging, with the model achieving 0.998 accuracy on perturbed ZINC (test) and 1.000 accuracy on both perturbed USPTO and perturbed Solubility withheld data. Perturbation rate was selected such that approximately half of the perturbed strings are valid. Integrating with Character VAE To demonstrate the models capability of improving preexisting generative models for discrete structures, we show how it can be used to improve the results of previous work, a character variational autoencoder (CVAE) applied to SMILES strings (Gómez-Bombarelli et al., 2016b; Kingma & Welling, 2013) . Therein, an encoder maps points in X + to a continuous latent representation Z and a paired decoder maps points in Z back to X + . A reconstruction based loss is minimised such that training points mapped to the latent space decode back into the same SMILES strings. The fraction of test points that do is termed reconstruction accuracy. The loss also features a term that encourages the posterior over Z to be close to some prior, typically a normal distribution. A key metric for the performance of variational autoencoder models for discrete structures is the fraction of points sampled from the prior over Z that decode into valid molecules. If many points do not correspond to valid molecules, any sort of predictive modeling on that space will likely also mostly output invalid SMILES strings.

The decoder functions by outputting a set of weights f (x t |z) for each character x t in the reconstructed sequence conditioned on a latent point z ∈ Z; the sequence is recovered by sampling from a multinomial according to these weights. To integrate our validity model into this framework, we take the decoder output for each step t and mask out choices that we predict cannot give valid sequence continuations. We thus sample characters with weights given by f (x t |z) • I [y(x t |x <t , w) ≥ 0.5]. 4 contains a comparison of our work to a plain CVAE and to the Grammar VAE approach. We use a Kekulé format of the ZINC data in our experiments, a specific representation of aromatic bonds that our model handled particularly well. Note that the results we quote for Grammar VAE are taken directly from Kusner et al. (2017) and on non-Kekulé format data. The CVAE model is trained for 100 epochs, as per previous work -further training improves reconstruction accuracy.

Autoencoding benchmarks Table:

We note that the binary nature of the proposed grammar model means that it does not affect the reconstruction accuracy. In fact, some modest gains are present. The addition of our grammar model to the character VAE significantly improves its ability to decode discrete structures, as seen by the order of magnitude increase in latent sample validity. The action of our model is completely post-hoc and thus can be applied to any pre-trained character-based VAE model where elements of the latent space correspond to a structured discrete sequence. The model showed promise on the Python mathematical expressions problem, especially when combined with active learning. In the context of SMILES molecules, the model was able to learn near-perfectly the validity of independently perturbed molecules. When applied to the variational autoencoder benchmark on SMILES strings, the proposed method beat the previous results by a large margin on prior sample validity -the relevant metric for the downstream utility of the latent space. The model is simple to apply to existing character-based models and is easy to train using data produced through our augmentation method. The perturbations used do not, however, capture every way in which a molecule may be mis-constructed. Correlated changes such as the insertion of matching brackets into expressions are missing from our scheme. Applying the model to a more structured representation of molecules, for example, sequences of parse rules as used in the Grammar VAE, and performing perturbations in that structured space is likely to deliver even greater improvements in performance. 

Model:



A COVERAGE ESTIMATION:

Ideally, we would like to check that the learned model y(x t |x <t , w) assigns positive probability to exactly those points which may lead to valid sequences, but for large discrete spaces this is impossible to compute or even accurately estimate. A simple check for accuracy could be to evaluate whether the model correctly identifies points as valid in a known, held-out validation or test set of real data, relative to randomly sampled sequences (which are nearly always invalid). However, if the validation set is too "similar" to the training data, even showing 100% accuracy in classifying these as valid may simply indicate having overfit to the training data: a discriminator which identifies data as similar to the training data needs to be accurate over a much smaller space than a discriminator which estimates validity over all of X .

Instead, we propose to evaluate the trade-off between accuracy on a validation set, and an approximation to the size of the effective support of t y(x t |x <t , w) over X . Let X + denote the valid subset of X . A uniform distribution over N + sequences would have an entropy of log N + . We denote the entropy of output from the model H. If our model was perfectly uniform over the sequences it can generate, it would then be capable of generating N model = e H . As our model at its optimum is extremely not uniform over sequences x ∈ X , this is very much a lower bound a coverage.

:

Note that, once Q (x<t, xt) is zero, all the following values of Q (x<t, xt) in that sequence will be irrelevant to us. Therefore, we can safely assume that a sequence is invalid if Q (x<t, xt) is zero at least once in the sequence.

Figures and Tables:

Figure 2: Experiments with length 25 Python expressions. (Left) Area under validity-entropy curve as training progresses, 10-90 percentiles shaded. Active learning converges faster and reaches a higher maximum. (Right) Entropy versus validity for median active and median passive model after 200k training sequences. Both models have learnt a high entropy distribution over valid sequences.

have too many bonds branch must have atoms SMILES: 'CC1CN(C(=O)C2=CC(Br)=CN2C)CCC1[NH3+]'

Figure 3: Predictions y(x t |x <t , w) of the agent at each step t for the valid test molecule shown in the top left figure, for a subset of possible actions (selecting as next character C, F, ), or ]). Each column shows which actions the trained agent believes are valid at each t, given the characters x <t preceding it. We see that the validity model has learned basic valence constraints: for example the oxygen atom O at position 10 can form at most 2 bonds, and since it is preceded by a double bond, the model knows that neither carbon C nor fluorine F can immediately follow it at position 11; we see the same after the bromine Br at position 18, which can only form a single bond. The model also correctly identifies that closing branch symbols ) cannot immediately follow opening branches (after positions 6, 8, and 17), as well as that closing brackets ] cannot occur until an open bracket has been followed by at least one atom (at positions 32-35). The full output heatmap for this example molecule is shown in Figure 4 in the appendix.

Figure 4: Full heatmap showing predictions y(x t |x <t , w) for the molecule in Figure 3.

Suppose we estimate the valid fraction f + = |X+| /|X | by simple Monte Carlo, sampling uniformly from X . We can then estimate N + = |X + | by f + |X |, where |X | = C T , a known quantity.



Table content: <table><tr><td/><td colspan="2">: Python 3 expression alphabet</td></tr><tr><td>digits</td><td colspan="3">operators comparisons brackets</td></tr><tr><td colspan="2">1234567890 +-* /%!</td><td>=&lt;&gt;</td><td>()</td></tr></table>

Estimated lower bound of coverage N for passive and active models, defined as the size of the set of Python expressions on which the respective model places positive probability mass. Evaluation is on models trained until convergence (800, 000 training points, beyond the scope of figure2). The lower bound estimation method is detailed in Appendix A.

Table content: <table><tr><td>temperature τ</td><td colspan="2">passive model validity N</td><td colspan="2">active model validity N</td></tr><tr><td>0.100 0.025 0.005</td><td>0.850 0.969 1.000</td><td>9.7 × 10 27 2.9 × 10 25 1.1 × 10 22</td><td>0.841 0.995 1.000</td><td>8.2 × 10 28 4.3 × 10 27 1.3 × 10 27</td></tr></table>



Table content: <table><tr><td/><td>: SMILES alphabet</td></tr><tr><td>atoms/chirality</td><td>bonds/ringbonds charges branches/brackets</td></tr></table>

Performance metrics for VAE-based molecule model trained for 100 epochs on ZINC (train) data, with and without the proposed validity model overlaid at test time, and the Grammar VAE method. Sample validity is the fraction of samples from the prior over Z that decode into valid molecules.5 DISCUSSIONIn this work we proposed a modeling technique for learning the validity constraints of discrete spaces. The proposed likelihood makes the model easy to train, is unaffected by the introduction of padding for variable length sequences and, as its optimum is largely independent of the training data distribution, it allows for the utilisation of active learning techniques. Through experiments we found that it is vital to show the model informative examples of validity constraints being validated. Thus, where no informative data sets exist, we proposed a mutual-information-based active learning scheme that uses model uncertainty to select training sequences. We used principled approximations to make that learning scheme computationally feasible. Where data sets of positive examples are available, we proposed a simple method of perturbations to create informative examples of validity constraints being broken.

Table content: <table><tr><td/><td colspan="2">reconstruction accuracy sample validity</td></tr><tr><td>CVAE + Validity Model</td><td>50.2%</td><td>22.3%</td></tr><tr><td>Grammar VAE</td><td>53.7%</td><td>7.2%</td></tr><tr><td>Plain CVAE</td><td>49.7%</td><td>0.5%</td></tr></table>

Peer review (iclr2018):
 The authors use a recurrent neural network to build generative models of sequences in domains where the vast majority of sequences is invalid. The basic idea, outlined in Eq. 2, is moderately straightforward: at each step, use an approximation of the Q function for subsequences of the appropriate length to pick a valid extension. There are numerous details to get right. The writing is mostly clear, and the examples are moderately convincing. I wish the paper had more detailed arguments and discussions. I question the appropriateness of Eq. 2 as a target. A correctly learned model will put positive weight on valid sequences, but it may be an arbitrarily slow way to generate diverse sequences, depending on the domain. For instance, imagine a domain of binary strings where the valid sequences are the all 1 sequence, or any sequence beginning with a 0. Half the generated sequences would be all 1*s in this situation, right? And it*s easy to construct further examples that are much worse than this? The use of Bayesian active learning to generate the training set feels like an elegant idea. However, I wish there were more clarity about what was ad hoc and what wasn*t. For instance, I think the use of dropout to get q is suspect (see for instance https://arxiv.org/abs/1711.02989), and I*d prefer a little more detail on statements like "The nonlinearity of g(·) means that our Monte Carlo approximation is biased, but still consistent." Do we have any way of quantifying the bias? Is the statement about K=16 being reasonable a statement about bias, variance, or both? For Python strings: - Should we view the fact that high values of tau give a validity of 1.0 as indicative that the domain*s constraints are fairly easy to learn? - "The use of a Boltzmann policy allows us to tune the temperature parameter to identify policies which hit high levels of accuracy for any learned Q-function approximation." This is only true to the extent the domain is sufficiently "easy" right? Is the argument that even in very hard domains, you might get this by just having an RNN which memorized a single valid sequence (assuming at least one could be found)? - What*s the best explanation for *why* the active model has much higher diversity? I understand that the active model is picking examples that tell us more about the uncertainty in w, but it*s not obvious to me that means higher diversity. Do we think this is a universal property of domains? - The highest temperature active model is exploring about half of valid sequences (modulo the non-tightness of the bound)? Have you tried gaining some insight by generating thousands of valid sequences manually and seeing which ones the model is rejecting? - The coverage bound is used only for for Python expressions, right? Why not just randomly sample a few thousand positives and use that to get a better estimate of coverage? Since you can sample from the true positive set, it seems that your argument from the appendix about the validation set being "too similar to the training set" doesn*t apply? - It would be better to see a comparison to a strong non-NN baseline. For instance, I could easily make a PCFG over Python math expressions, and use rejection sampling to get rid of those that aren*t exactly length 25, etc.? I question how easy the Python strings example is. In particular, it might be that it*s quite an easy example (compared to the SMILES) example. For SMILES, it seems like the Bayesian active learning technique is not by itself sufficient to create a good model? It is interesting that in the solubility domain the active model outperforms, but it would be nice to see more discussion / explanation. Minor note: The incidence of valid strings in the Python expressions domain is (I believe) > 1/5000, although I guess 1 in 10,000 is still the right order of magnitude. If I could score between "marginal accept" and "accept" I would.