Low-Rank Constraints for Fast Inference in Structured Models
Abstract
Structured distributions, i.e. distributions over combinatorial spaces, are commonly used to learn latent probabilistic representations from observed data. However, scaling these models is bottlenecked by the high computational and memory complexity with respect to the size of the latent representations. Common models such as Hidden Markov Models (HMMs) and Probabilistic Context-Free Grammars (PCFGs) require time and space quadratic and cubic in the number of hidden states respectively. This work demonstrates a simple approach to reduce the computational and memory complexity of a large class of structured models. We show that by viewing the central inference step as a matrix-vector product and using a low-rank constraint, we can trade off model expressivity and speed via the rank. Experiments with neural parameterized structured models for language modeling, polyphonic music modeling, unsupervised grammar induction, and video modeling show that our approach matches the accuracy of standard models at large state spaces while providing practical speedups.
1 Introduction
When modeling complex sequential spaces, such as sentences, musical scores, or video frames, a key choice is the internal structural representations of the model. A common choice in recent years is to use neural representations (Bengio et al., 2003; Mikolov et al., 2011; Brown et al., 2020; Boulanger-Lewandowski et al., 2012; Huang et al., 2018; Weissenborn et al., 2020) to store a deterministic history. These models yield strong predictive accuracy but their deterministic, continuous forms provide little insight into the intermediate decisions of the model.††Code is available here.
Latent structured models provide an alternative approach where complex modeling decisions are broken down into a series of probabilistic steps. Structured models provide a principled framework for reasoning about the probabilistic dependencies between decisions and for computing posterior probabilities. The structure of the decision processes and the ability to answer queries through probabilistic inference afford interpretability and controllability that are lacking in neural models (Koller and Friedman, 2009; Levine, 2018).
Despite the benefits of structured models, the computational complexity of training scales asymptotically much worse than for neural models, as inference, and therefore training, requires marginalizing over all possible latent structures. For standard general-purpose models like Hidden Markov Models (HMM) and Probabilistic Context-Free Grammars (PCFG), the runtime of inference scales quadratically and cubically in the number of states respectively, which limits the ability to reach a massive scale. Promisingly, recent work has shown that in specific situations these models can be scaled, and that the increased scale results in commensurate improvements in accuracy – without sacrificing the ability to perform exact inference (Dedieu et al., 2019; Chiu and Rush, 2020; Yang et al., 2021).
In this work, we propose an approach for improving the runtime of a large class of structured latent models by introducing a low-rank constraint. We target the family of models where inference can be formulated through a labeled directed hypergraph, which describes a broad class of dynamic-programming based inference (Klein and Manning, 2004; Huang and Chiang, 2005; Zhou et al., 2006; Javidian et al., 2020; Chiang and Riley, 2020). We show how under low-rank constraints these models allow for more efficient inference. Imposing a low-rank constraint allows for a key step of inference to be rewritten as a fast matrix-vector product. This approach is also inspired by recent advances in computationally efficient neural attention attention (Katharopoulos et al., 2020; Peng et al., 2021; Choromanski et al., 2020), a significantly different task and formulation, that rewrites matrix-vector products as fast low-rank products using approximate kernel techniques.
We evaluate this approach by learning low-rank structured models for the tasks of language modeling, polyphonic music modeling, unsupervised grammar induction, and video modeling. For these tasks we use a variety of models including HMMs, PCFGs, and Hidden Semi-Markov Models (HSMMs). As the application of low-rank constraints is nontrivial in high-dimensional structured models due to reduced expressivity, we demonstrate effective techniques for overcoming several practical challenges of low-rank parameterizations. We find that our approach achieves very similar results to unconstrained models at large state sizes, while the decomposition allows us to greatly increase the speed of inference. Results on HMMs show that we can scale to more than 16,000 states; results on PCFGs achieve a significant perplexity reduction from much larger state spaces compared to past work (Kim et al., 2019); and results on HSMMs show that our formulation enables scaling to much larger state spaces for continuous emissions (Fried et al., 2020).
2 Background: Latent Structure and Hypergraphs
We consider the problem of modeling a sequence of observations . These observations can range in complexity from the words in a sentence to a series of co-occurring musical notes, or to features of video frames, and may be discrete or continuous. We assume these observations are generated by an unobserved (latent) structured representation , and therefore model the joint . The structure may be sequential or hierarchical, such as latent trees, and the set of structures is combinatorial, i.e. exponential in size with respect to the input sentence. In order to train these models on observations, we must optimize the evidence by marginalizing over . Scaling this marginalization is the focus of this work.
Hypergraphs are a graphical model formalism for structured distributions that admit tractable inference through dynamic programming (Klein and Manning, 2004; Huang and Chiang, 2005; Zhou et al., 2006; Javidian et al., 2020; Chiang and Riley, 2020).111While the formalism is similar to undirected factor graphs, it allows us to represent more complex distributions: notably dependency structures with unknown topologies, such as latent trees. A labeled, directed, acyclic hypergraph consists of a set of nodes , a set of hyperedges , and a designated root node . Each node has a collection of labels . Each hyperedge has a head node and tuple of tail nodes, , where is the number of tail nodes. For simplicity, we will assume at most 2 tail nodes , and unless noted, a fixed label set throughout. Each hyperedge is associated with a score matrix with a score for all head and tail labels.222This formalism can represent inference in both locally and globally normalized models, although we focus on local normalization in this work. We use the notation to indicate the score for head label and tail labels and . Finally, we assume we have a topological ordering over the edges.
A hypergraph is used to aggregate scores bottom-up through a dynamic programming (belief propagation) algorithm. Algorithm 1 (left) shows the algorithm. It works by filling in a table vector for each node in order, and is initialized to 1 at the leaf nodes.333 The accumulation of scores is denoted by . Multiple hyperedges can have the same head node, whose scores must be added together. It returns the sum over latent structures, . Counting loops, the worst-case runtime complexity is where is the size of the label set and the max hyperedge tail size. Algorithm 1 (right) shows the same algorithm in matrix form by introducing joined tail vectors for each group of nodes . Letting , the joined tail vector contains entries .
To make this formalism more concrete, we show how hypergraphs can be used for inference in several structured generative models: hidden Markov models, probabilistic context-free grammars, and hidden semi-Markov models. Inference in these examples are instances of the hypergraph algorithm.
Example: Hidden Markov Models (HMM) HMMs are discrete latent sequence models defined by the following generative process: first, a sequence of discrete latent states with state size are sampled as a Markov chain. Then each state independently emits an observation , i.e.
(1) |
where is the transition distribution, the emission distribution, and is the initial distribution with distinguished start symbol .
Given a sequence of observations we can compute using a labeled directed hypergraph, with single-tailed edges, nodes corresponding to state positions, labels corresponding to states, and emissions probabilities incorporated into the scoring matrices . There are scoring matrices, , with entries corresponding to transitions.444 The left-most scoring matrix for the HMM has entries . Algorithm 2 (left) shows the approach. This requires time and is identical to the backward algorithm for HMMs.555 In the case of HMMs, the table vectors correspond to the backward algorithm’s values.
Example: Context-Free Grammars (CFG) CFGs are a structured model defined by the 5-tuple , where is the distinguished start symbol, is a set of nonterminals, is a set of preterminals, is the token types in the vocabulary, and is a set of grammar rules. Production rules for start, nonterminals, and preterminals take the following forms:666 We restrict our attention to grammars in Chomsky normal form.
(2) |
A probabilistic context-free grammar (PCFG) additionally has a probability measure on the set of rules. To compute with a hypergraph, we create one node for each contiguous subspan in the sentence. Nodes with have a nonterminal label set . Nodes with have a preterminal label set . The main scoring matrix is , with entries .777We have a separate matrix for terminal production on which we elide for simplicity. Algorithm 2 (right) shows how for every hyperedge we join the scores from the two tail nodes in and into joined tail vector . As there are hyperedges and the largest is of size , the runtime of the algorithm is . This approach is identical to the CKY algorithm.
Example: Hidden Semi-Markov Models (HSMM) HSMMs are extensions of HMMs that allow for generating a variable-length sequence of observations per state. It defines the following generate process: first, we sample a sequence of discrete latent states with a first-order Markov model. We then use them to generate the length of observations per state. For our experiments we generate independent continuous emissions with a Gaussian distribution for . Full details of the inference procedure are given in Appendix E.
3 Rank-Constrained Structured Models
For these structured distributions, hypergraphs provide a general method for inference (and therefore training parameterized versions). However, the underlying algorithms scale poorly with the size of the label sets (quadratic for HMM and HSMM, cubic for CFG). This complexity makes it challenging to scale these models and train versions with very large numbers of states.
In this section, we consider an approach for improving the scalability of these models by reducing the dependence of the computational complexity of inference on the label set size. The main idea is to speed up the matrix-vector product step in inference by using a low-rank decomposition of the scoring matrix . In the next section we show that this constraint can be easily incorporated into parameterized versions of these models.
3.1 Low-Rank Matrix-Vector Products
The main bottleneck for inference speed is the matrix-vector product that must be computed for every edge in the hypergraph. As we saw in Algorithm 1 (left), this step takes time to compute, but it can be sped up by making structural assumptions on . In particular, we focus on scoring matrices with low rank.
We note the following elementary property of matrix-vector products. If the scoring matrix can be decomposed as the product of two smaller matrices , where and , then the matrix-vector products can be computed in time as follows:
(3) |
This reordering of computation exchanges a factor of for a factor of . When , this method is both faster and more memory-efficient.
We enforce the low-rank constraint by directly parameterizing the factors and for scoring matrices that we would like to constrain. We treat both and as embedding matrices, where each row corresponds to an embedding of each value of and a joint embedding of respectively:
(4) |
where and are embedding functions; and are constants (used to ensure proper normalization) or clamped potentials (such as conditional probabilities); and is a function that ensures nonnegativity, necessary for valid probability mass functions. Algorithm 3 shows the role of the low-rank matrix-vector product in marginalization.888 If the normalizing constants are given by , they can be computed from unnormalized as follows: in time , and similarly for .
3.2 Application to Structured Models
As enforcing a low-rank factorization of every scoring matrix limits the expressivity of a model, we explicitly target scoring matrices that are involved in computational bottlenecks.999For a discussion of the expressivity of low-rank models compared to models with fewer labels, see Appendix A. For these key scoring matrices, we directly parameterize the scoring matrix with a low-rank factorization, which we call a low-rank parameterization. For other computations, we utilize a standard softmax parameterization and do not factorize the resulting scoring matrix. We refer to this as a mixed parameterization.
Hidden Markov Models Low-rank HMMs (LHMMs) use the following mixed parameterization, which specifically targets the state-state transition bottleneck by using a low-rank parameterization for the transition distribution, but a softmax parameterization for the emission distribution:
(5) |
where and are (possibly neural) embedding functions. The parameterizations of the embedding functions , as well as the non-negative mapping are detailed in Appendix F. When performing inference, we treat the emission probabilities as constants, and absorb them into .
This allows inference to be run in time , where is the length of a sequence, the size of the label space, and the feature dimension.
Hidden Semi-Markov Models For low-rank HSMM (LHSMM), we similarly target the transition distribution and keep the standard Gaussian emission distribution:
(6) |
where and are state embeddings, while is the Gaussian kernel used to model continuous . The full parameterization of the embeddings is given in Appendix F. The total inference complexity is , where is the maximum length of the observation sequence under any state.
Context-Free Grammars For PCFGs, the inference bottleneck is related to the transition from a nonterminal symbol to two nonterminal symbolss (), and we specifically parameterize it using a low-rank parameterization:
(7) | ||||||
where / is the embedding of when is used as head,/ is the embedding of / when they are used as tail. See Appendix F for the full parameterization, drawn from Kim et al. (2019). Note that we limit the application of low-rank constraints to nonterminal to nonterminal productions. These productions dominate the runtime as they are applied at hyperedges. This allows inference to be run in time , where is the length of a sequence, the size of the label space, and the feature dimension.
4 Experimental Setup
We evaluate the application of low-rank constraints with four experiments: sequential language modeling with HMMs, polyphonic music modeling with a large observation space, hierarchical language modelings with PCFGs, and video modeling with HSMMs.
Data Our first set of experiments evaluate sequential models on Penn Treebank dataset (Ptb) (Marcus et al., 1993) for the task of word-level language modeling. We use the preprocessing from Mikolov et al. (2011). The second set of experiments is on polyphonic music modeling (Boulanger-Lewandowski et al., 2012). We evaluate on four music datasets: Nottingham (Nott), Piano, MuseData (Muse), and JSB chorales (JSB). Each timestep consists of an 88-dimensional binary vector indicating whether a particular note is played. Since multiple notes may be played at the same time, the effective vocabulary size is extremely large. The third set of experiments use PCFGs for language modeling, we also use Ptb, but with the splits and preprocessing used in unsupervised constituency parsing (Shen et al., 2018, 2019; Kim et al., 2019). The last set of experiments use HSMMs for video modeling, where we use CrossTask (Zhukov et al., 2019) with 10% of the training data for validation. We follow the preprocessing steps in Fried et al. (2020) and apply PCA to project features to vectors of size 200. For the full details on datasets, please see Appendix D.
Models and Hyperparameters For language modeling with HMMs, we experiment with a range of state sizes, , and rank . For polyphonic music modeling with HMMs, we experiment with states sizes . For language modeling with PCFGs, we use a set of nonterminals of size and preterminals of twice the number of nonterminals . Our smallest setting (, ) is the one used in Kim et al. (2019). For video modeling with HSMMs, we use the same model setting as Fried et al. (2020), but we don’t constrain states to the predefined states per task, and we experiment with state sizes and rank .
We utilize the feature map for the LHMM and LHSMM, and for the LPCFG. We initialize the parameters of feature maps using orthogonal feature projections (Choromanski et al., 2020), and update it alongside the model parameters. For the full hyperparameter and optimization details, see Appendix G.
Baselines and Evaluation The language modeling experiments are evaluated using perplexity. Baselines are neurally parameterized HMM with a standard softmax transition. We also compare to VL-HMM, which makes a strong structural sparsity assumption on the emission distribution (Chiu and Rush, 2020). We include for reference a state-of-the-art language model, the AWD-LSTM (Merity et al., 2017). For polyphonic music modeling, we compare our LHMM against RNN-NADE (Boulanger-Lewandowski et al., 2012) which models the full joint distribution of notes as well as temporal dependencies; as well as autoregressive neural models such as the R-Transformer (Wang et al., 2019) (as reported by Song et al. (2019)) and an LSTM (as reported by Ziegler and Rush (2019)); models with latent continuous dynamics such as the LV-RNN (Gu et al., 2015) and SRNN (Fraccaro et al., 2016); and finally comparable models with latent discrete dynamics, the TSBN (Gan et al., 2015) and the baseline HMM. We evaluate perplexities of our low-rank PCFG (LPCFG) against a softmax PCFG (PCFG) (Kim et al., 2019). For video modeling, we evaluate the negative log likelihoods on the test set and compare low-rank HSMMs to softmax HSMMs.
5 Results
Hidden Markov Models for Language Modeling


Our main experimental result is that the low-rank models achieve similar accuracy, as measured by perplexity, as our baselines. Fig. 1 shows that perplexity improves as we increase the scale of the HMM, and that the performance of our LHMM also improves at the same rate. At small sizes, the low-rank constraints slightly hinder accuracy; however once the size is large enough, i.e. larger than , LHMMs with 8:1 state-to-rank ratios perform comparably. 101010 See Appendix H for an analysis of the ranks of HMMs/LHMMs.
Fig. 1 also contains speed comparisons between HMMs and LHMMs. A state-to-rank ratio of 8:1 matches the accuracy of softmax HMMs at larger state sizes and also gives an empirical speedup of more than 3x at . As expected, we only see a speedup when the state-to-rank ratio exceeds 2:1, as we replaced the operation with two ones. This implies that the low-rank constraint is most effective with scale, where we observe large computational gains at no cost in accuracy.
Model | Val | Test |
---|---|---|
AWD-LSTM | 60.0 | 57.3 |
VL-HMM | 128.6 | 119.5 |
HMM | 144.3 | 136.8 |
LHMM | 141.4 | 131.8 |
Model | Train | Val | |
---|---|---|---|
HMM | - | 95.9 | 144.3 |
LHMM | 8 | 97.5 | 141.4 |
LHMM+band | 8 | 101.1 | 143.8 |
LHMM | 16 | 110.6 | 146.3 |
LHMM+band | 16 | 96.9 | 138.8 |
LHMM | 32 | 108.4 | 153.7 |
LHMM+band | 32 | 110.7 | 145.0 |
HMMs are outperformed by neural models, and also by VL-HMMs (Chiu and Rush, 2020) which offer similar modeling advantages to HMMs, as shown in Tbl. 1 (left). This indicates that some aspects of performance are not strictly tied to scale. We posit this is due to the problem-specific block-sparse emission constraint in VL-HMMs. While very effective for language modeling, the VL-HMM relies on a hard clustering of states for constraining emissions. This is difficult to apply to problems with richer emission models (as in music and video modeling).
Hidden Markov Models for Music Modeling We next apply LHMMs on polyphonic music modeling. This has a max effective vocabulary size of , as multiple notes may occur simultaneously. Unlike for language modeling, we use a factored Bernoulli emission model, modeling the presence of each note independently. Fig. 2 (right) shows that HMMs are competitive with many of the models on these datasets, including LSTMs. We find that LHMMs achieve performance slightly worse than but comparable to the unconstrained HMMs overall. Fig. 2 (left) shows that the distinction drops with more states. Both HMMs achieve low negative likelihoods (NLL) on the datasets with shorter sequences, Nottingham and JSB, but relatively poorer NLLs on the datasets with longer sequences (Muse and Piano).

Model | Nott | Piano | Muse | JSB |
---|---|---|---|---|
RNN-NADE | 2.31 | 7.05 | 5.6 | 5.19 |
R-Transformer | 2.24 | 7.44 | 7.00 | 8.26 |
LSTM | 3.43 | 7.77 | 7.23 | 8.17 |
LV-RNN | 2.72 | 7.61 | 6.89 | 3.99 |
SRNN | 2.94 | 8.20 | 6.28 | 4.74 |
TSBN | 3.67 | 7.89 | 6.81 | 7.48 |
HMM | 2.43 | 8.51 | 7.34 | 5.74 |
LHMM | 2.60 | 8.89 | 7.60 | 5.80 |
Context-Free Grammars For syntactic language modeling on Ptb, our low-rank PCFG (LPCFG) achieves similar performance to PCFGs, as shown in Table 2 (left), with an improvement in computational complexity. The complexity of inference in PCFGs models is cubic in the number of nonterminals, so even models with nonterminals are relatively costly. Our approach achieves comparable results with features. As we scale up the number of nonterminals to , LPCFG stays competitive with a lower computational complexity (since ). These experiments also demonstrate the importance of scale in syntactic language models with more than 50 point gain in perplexity over a strong starting model.
CFG Speed Once the model is large enough, i.e. nonterminals and preterminals, the LPCFG is faster than PCFG, as shown in Tbl. 2 (left). Note that the LPCFG is faster than the CFG even when the number of features , in contrast to the HMM case where a speedup can only be obtained when . This is due to the scoring matrix being rectangular: Recall the low-rank matrix product , where, when specialized to PCFGs, the left-hand side takes time and the right-hand side takes . For PCFGs, the term dominates the runtime. This contrasts with HMMs, where both and the subsequent multiplication by take the same amount of time, .
Hidden Semi-Markov Models for Video Modeling Table 2 (right) shows the results of video modeling using HSMMs. In addition to using a different hypergraph for inference, these experiments use a continuous Gaussian emission model. By removing the state constraints from tasks, our HSMM baselines get better video-level NLLs than that from Fried et al. (2020) at the cost of more memory consumption. Due to GPU memory constraints, we can only train HSMMs up to states. However, the low-rank parameterization allows models to scale to states, yielding an improvement in NLL. Absolute results could likely be improved with more states and by an improved emission parameterization for all models.
Improving Rank Assumptions One potential limitation of all low-rank models is that they cannot learn high-rank structures with low . We began to see this issue at a ratio of 16:1 states to features for large HMMs. To explore the effects of this limitation, we perform an additional experiment that combines low-rank features with a sparse component. Specifically we add an efficient high-rank sparse banded transition matrix. The full details are in Appendix I. Tbl. 1 (right) shows that combination with the band structure allows for larger ratios than just the low-rank structure alone, while only adding another operation that costs .
Model | PPL | Secs | |||
---|---|---|---|---|---|
30 | 60 | PCFG | - | 252.60 | 0.23 |
LPCFG | 8 | 247.02 | 0.27 | ||
LPCFG | 16 | 250.59 | 0.27 | ||
60 | 120 | PCFG | - | 234.01 | 0.33 |
LPCFG | 16 | 217.24 | 0.28 | ||
LPCFG | 32 | 213.81 | 0.30 | ||
100 | 200 | PCFG | - | 191.08 | 1.02 |
LPCFG | 32 | 203.47 | 0.64 | ||
LPCFG | 64 | 194.25 | 0.81 |
Model | NLL | Secs | ||
HSMM111111We report the NLL of the baseline model taken from Fried et al. (2020), where every label corresponds to one of 151 possible actions. | 151 | - | - | |
HSMM | - | 0.78 | ||
HSMM | - | 2.22 | ||
HSMM | - | 7.69 | ||
LHSMM | 4.17 | |||
LHSMM | 5.00 | |||
LHSMM | 5.56 | |||
LHSMM | 10.0 |
6 Related Work
Similar to our work, other approaches target matrix or tensor operations in inference, and impose structural model constraints to improve computational complexity. Many of the works on HMMs in particular take advantage of the transition structure. The Dense-mostly-constant (DMC) HMM assigns a subset of learnable parameters per row of the transition matrix and sets the rest to a constant, leading to a sub-quadratic runtime (Siddiqi and Moore, 2005). Other structures have also been explored, such as aligning the states of an HMM to underlying phenomena that allows inference to be sped up (Felzenszwalb et al., 2004; Roweis, 2000). Additionally, other methods take advantage of emission structure in HMMs in order to scale, such as the Cloned HMM (Dedieu et al., 2019) and VL-HMM (Chiu and Rush, 2020). Compared to these approaches, our method is more flexible and generic, since it can be applied in a non-application-specific manner, and even extended with high-rank components (such as banded structure).
Low-rank structure has been explored in both HMMs (Siddiqi et al., 2009), a generalization of PCFGs called weighted tree automata (Rabusseau et al., 2015), and conditional random fields (Thai et al., 2018). The reduced-rank HMM (Siddiqi et al., 2009) has at most 50 states, and relies on spectral methods for training. The low-rank weighted tree automata (Rabusseau et al., 2015) also trains latent tree models via spectral methods. We extend the low-rank assumption to neural parameterizations, which have been shown to be effective for generalization (Kim et al., 2019; Chiu and Rush, 2020), and directly optimize the evidence via gradient descent. Finally, Thai et al. (2018) do not take advantage of the low-rank parameterization of their CRF potentials for faster inference via low-rank matrix products, a missed opportunity. Instead, the low-rank parameterization is used only as a regularizer, with the full potentials instantiated during inference.
Concurrent work in unsupervised parsing uses a tensor decomposition to scale PCFGs to large state spaces (Yang et al., 2021). Our low-rank decomposition of the flattened head-tail scoring matrix is more general, resulting in worse scaling for the PCFG setting but with wider applicability, as shown by experiments with HMMs and HSMMs.
7 Conclusion
This work improves the scaling of structured models by establishing the effectiveness of low-rank constraints for hypergraph models. We show that viewing a key step of inference in structured models as a matrix-vector product, in combination with a low-rank constraint on relevant parameters, allows for an immediate speedup. Low-rank inference allows us to obtain a reduction in the asymptotic complexity of marginalization at the cost of a constrained model. Our approach applies to a wide class of models, including HMMs, HSMMs, and PCFGs. Through our experiments on language, video, and polyphonic music modeling, we demonstrate an effective approach for overcoming the practical difficulty of applying low-rank constraints in high dimensional, structured spaces by targeting and constraining model components that bottleneck computation. Future work includes exploration of other structural constraints for speeding up matrix-vector products (Dao et al., 2020) performed in inference, as well as application to models where exact inference is intractable.
Acknowledgments and Disclosure of Funding
We thank Nikita Kitaev for the discussion that sparked this project. We thank Sam Wiseman, Jack Morris, and the anonymous reviewers for valuable feedback. Yuntian Deng is sponsored by NSF 1704834, Alexander Rush by NSF CAREER 1845664, and Justin Chiu by an Amazon research award.
References
- Bayer and Osendorfer (2015) Justin Bayer and Christian Osendorfer. Learning stochastic recurrent networks, 2015.
- Bengio et al. (2003) Yoshua Bengio, Réjean Ducharme, Pascal Vincent, and Christian Janvin. A neural probabilistic language model. J. Mach. Learn. Res., 3:1137–1155, March 2003. ISSN 1532-4435.
- Boulanger-Lewandowski et al. (2012) Nicolas Boulanger-Lewandowski, Yoshua Bengio, and Pascal Vincent. Modeling temporal dependencies in high-dimensional sequences: Application to polyphonic music generation and transcription. In Proceedings of the 29th International Coference on International Conference on Machine Learning, ICML’12, page 1881–1888, Madison, WI, USA, 2012. Omnipress. ISBN 9781450312851.
- Brown et al. (2020) Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners, 2020.
- Chiang and Riley (2020) David Chiang and Darcey Riley. Factor graph grammars. arXiv preprint arXiv:2010.12048, 2020.
- Chiu and Rush (2020) Justin Chiu and Alexander Rush. Scaling hidden Markov language models. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 1341–1349, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.103. URL https://www.aclweb.org/anthology/2020.emnlp-main.103.
- Choromanski et al. (2020) Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, David Belanger, Lucy Colwell, and Adrian Weller. Rethinking attention with performers, 2020.
- Dao et al. (2020) Tri Dao, Nimit Sohoni, Albert Gu, Matthew Eichhorn, Amit Blonder, Megan Leszczynski, Atri Rudra, and Christopher Ré. Kaleidoscope: An efficient, learnable representation for all structured linear maps. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=BkgrBgSYDS.
- Dedieu et al. (2019) Antoine Dedieu, Nishad Gothoskar, Scott Swingle, Wolfgang Lehrach, Miguel Lázaro-Gredilla, and Dileep George. Learning higher-order sequential structure with cloned hmms, 2019.
- Felzenszwalb et al. (2004) Pedro Felzenszwalb, Daniel Huttenlocher, and Jon Kleinberg. Fast algorithms for large-state-space hmms with applications to web usage analysis. In S. Thrun, L. Saul, and B. Schölkopf, editors, Advances in Neural Information Processing Systems, volume 16. MIT Press, 2004. URL https://proceedings.neurips.cc/paper/2003/file/9407c826d8e3c07ad37cb2d13d1cb641-Paper.pdf.
- Fraccaro et al. (2016) Marco Fraccaro, Søren Kaae Sønderby, Ulrich Paquet, and Ole Winther. Sequential neural models with stochastic layers, 2016.
- Fried et al. (2020) Daniel Fried, Jean-Baptiste Alayrac, Phil Blunsom, Chris Dyer, Stephen Clark, and Aida Nematzadeh. Learning to segment actions from observation and narration. arXiv preprint arXiv:2005.03684, 2020.
- Gan et al. (2015) Zhe Gan, Chunyuan Li, Ricardo Henao, David Carlson, and Lawrence Carin. Deep temporal sigmoid belief networks for sequence modeling, 2015.
- Glorot and Bengio (2010) Xavier Glorot and Yoshua Bengio. Understanding the difficulty of training deep feedforward neural networks. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, pages 249–256. JMLR Workshop and Conference Proceedings, 2010.
- Gu et al. (2015) Shixiang Gu, Zoubin Ghahramani, and Richard E. Turner. Neural adaptive sequential monte carlo, 2015.
- Huang et al. (2018) Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Noam Shazeer, Curtis Hawthorne, Andrew M. Dai, Matthew D. Hoffman, and Douglas Eck. An improved relative self-attention mechanism for transformer with application to music generation. CoRR, abs/1809.04281, 2018. URL http://arxiv.org/abs/1809.04281.
- Huang and Chiang (2005) Liang Huang and David Chiang. Better k-best parsing. In Proceedings of the Ninth International Workshop on Parsing Technology, pages 53–64, 2005.
- Javidian et al. (2020) Mohammad Ali Javidian, Zhiyu Wang, Linyuan Lu, and Marco Valtorta. On a hypergraph probabilistic graphical model. Annals of Mathematics and Artificial Intelligence, 88(9):1003–1033, 2020.
- Katharopoulos et al. (2020) A. Katharopoulos, A. Vyas, N. Pappas, and F. Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In Proceedings of the International Conference on Machine Learning (ICML), 2020.
- Kim et al. (2019) Yoon Kim, Chris Dyer, and Alexander Rush. Compound probabilistic context-free grammars for grammar induction. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 2369–2385, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1228. URL https://www.aclweb.org/anthology/P19-1228.
- Kingma and Ba (2017) Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization, 2017.
- Klein and Manning (2004) Dan Klein and Christopher D Manning. Parsing and hypergraphs. In New developments in parsing technology, pages 351–372. Springer, 2004.
- Koller and Friedman (2009) Daphne Koller and Nir Friedman. Probabilistic Graphical Models: Principles and Techniques - Adaptive Computation and Machine Learning. The MIT Press, 2009. ISBN 0262013193.
- Krishnan et al. (2016) Rahul G. Krishnan, Uri Shalit, and David Sontag. Structured inference networks for nonlinear state space models, 2016.
- Levine (2018) Sergey Levine. Reinforcement learning and control as probabilistic inference: Tutorial and review, 2018.
- Liu et al. (2018) Xiaolei Liu, Zhongliu Zhuo, Xiaojiang Du, Xiaosong Zhang, Qingxin Zhu, and Mohsen Guizani. Adversarial attacks against profile hmm website fingerprinting detection model. Cognitive Systems Research, 54, 12 2018. doi: 10.1016/j.cogsys.2018.12.005.
- Loshchilov and Hutter (2017) Ilya Loshchilov and Frank Hutter. Fixing weight decay regularization in adam. CoRR, abs/1711.05101, 2017. URL http://arxiv.org/abs/1711.05101.
- Marcus et al. (1993) Mitchell P. Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated corpus of english: The penn treebank. Comput. Linguist., 19(2):313–330, June 1993. ISSN 0891-2017.
- Merity et al. (2017) Stephen Merity, Nitish Shirish Keskar, and Richard Socher. Regularizing and optimizing LSTM language models. CoRR, abs/1708.02182, 2017. URL http://arxiv.org/abs/1708.02182.
- Mikolov et al. (2011) Tomas Mikolov, Anoop Deoras, Stefan Kombrink, Lukás Burget, and Jan Cernocký. Empirical evaluation and combination of advanced language modeling techniques. pages 605–608, 2011. URL http://dblp.uni-trier.de/db/conf/interspeech/interspeech2011.html#MikolovDKBC11.
- Peng et al. (2021) Hao Peng, Nikolaos Pappas, Dani Yogatama, Roy Schwartz, Noah Smith, and Lingpeng Kong. Random feature attention. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=QtTKTdVrFBB.
- Rabusseau et al. (2015) Guillaume Rabusseau, Borja Balle, and Shay B. Cohen. Weighted tree automata approximation by singular value truncation. CoRR, abs/1511.01442, 2015. URL http://arxiv.org/abs/1511.01442.
- Roweis (2000) Sam Roweis. Constrained hidden markov models. In S. Solla, T. Leen, and K. Müller, editors, Advances in Neural Information Processing Systems, volume 12. MIT Press, 2000. URL https://proceedings.neurips.cc/paper/1999/file/84c6494d30851c63a55cdb8cb047fadd-Paper.pdf.
- Shen et al. (2018) Yikang Shen, Zhouhan Lin, Chin wei Huang, and Aaron Courville. Neural language modeling by jointly learning syntax and lexicon. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=rkgOLb-0W.
- Shen et al. (2019) Yikang Shen, Shawn Tan, Alessandro Sordoni, and Aaron Courville. Ordered neurons: Integrating tree structures into recurrent neural networks. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=B1l6qiR5F7.
- Siddiqi and Moore (2005) Sajid M. Siddiqi and Andrew W. Moore. Fast inference and learning in large-state-space hmms. In Proceedings of the 22nd International Conference on Machine Learning, ICML ’05, page 800–807, New York, NY, USA, 2005. Association for Computing Machinery. ISBN 1595931805. doi: 10.1145/1102351.1102452. URL https://doi-org.proxy.library.cornell.edu/10.1145/1102351.1102452.
- Siddiqi et al. (2009) Sajid M. Siddiqi, Byron Boots, and Geoffrey J. Gordon. Reduced-rank hidden markov models. CoRR, abs/0910.0902, 2009. URL http://arxiv.org/abs/0910.0902.
- Song et al. (2019) Kyungwoo Song, JoonHo Jang, Seungjae Shin, and Il-Chul Moon. Bivariate beta LSTM. CoRR, abs/1905.10521, 2019. URL http://arxiv.org/abs/1905.10521.
- Stoller et al. (2019) Daniel Stoller, Mi Tian, Sebastian Ewert, and Simon Dixon. Seq-u-net: A one-dimensional causal u-net for efficient sequence modelling. CoRR, abs/1911.06393, 2019. URL http://arxiv.org/abs/1911.06393.
- Thai et al. (2018) Dung Thai, Sree Harsha Ramesh, Shikhar Murty, Luke Vilnis, and Andrew McCallum. Embedded-state latent conditional random fields for sequence labeling. In Proceedings of the 22nd Conference on Computational Natural Language Learning, pages 1–10, Brussels, Belgium, October 2018. Association for Computational Linguistics. doi: 10.18653/v1/K18-1001. URL https://aclanthology.org/K18-1001.
- Wang et al. (2019) Zhiwei Wang, Yao Ma, Zitao Liu, and Jiliang Tang. R-transformer: Recurrent neural network enhanced transformer, 2019.
- Weissenborn et al. (2020) Dirk Weissenborn, Oscar Täckström, and Jakob Uszkoreit. Scaling autoregressive video models. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=rJgsskrFwH.
- Yang et al. (2021) Songlin Yang, Yanpeng Zhao, and Kewei Tu. Pcfgs can do better: Inducing probabilistic context-free grammars with many symbols, 2021.
- Yu (2010) Shun-Zheng Yu. Hidden semi-markov models. Artificial intelligence, 174(2):215–243, 2010.
- Zhang et al. (2021) Hongpo Zhang, Ning Cheng, Yang Zhang, and Zhanbo Li. Label flipping attacks against naive bayes on spam filtering systems. Applied Intelligence, pages 1–12, 2021.
- Zhang et al. (2018) Xinyang Zhang, Ningfei Wang, Shouling Ji, Hua Shen, and Ting Wang. Interpretable deep learning under fire. CoRR, abs/1812.00891, 2018. URL http://arxiv.org/abs/1812.00891.
- Zhou et al. (2006) Dengyong Zhou, Jiayuan Huang, and Bernhard Schölkopf. Learning with hypergraphs: Clustering, classification, and embedding. Advances in neural information processing systems, 19:1601–1608, 2006.
- Zhukov et al. (2019) Dimitri Zhukov, Jean-Baptiste Alayrac, Ramazan Gokberk Cinbis, David Fouhey, Ivan Laptev, and Josef Sivic. Cross-task weakly supervised learning from instructional videos. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3537–3545, 2019.
- Ziegler and Rush (2019) Zachary M. Ziegler and Alexander M. Rush. Latent normalizing flows for discrete sequences, 2019.
Appendix A Expressivity of Low-Rank Models
We focus on the simplest case of HMMs for an analysis of expressivity. In the case of Gaussian emissions, a model with more states but low rank is more expressive than a model with fewer states because for a single timestep, a larger mixture of Gaussians is more expressive. In the case of discrete emissions, however, the emission distribution for a single timestep (i.e. ) is not more expressive. Instead, we show that there exists joint marginal distributions of discrete over multiple timesteps that are captured by large state but low-rank HMMs, but not expressible by models with fewer states.
We construct a counter-example with a sequence of length and emission space of . We show that a 3-state HMM with rank 2, HMM-3-2, with manually chosen transitions and emissions, cannot be modeled by any 2-state HMM. The transition probabilities for the HMM-3-2 are given by (rows , columns )
emission probabilities by (rows , columns ):
and starting distribution
This yields the following marginal distribution (row , column ):
Next, we show that there does not exist a 2-state HMM that can have this marginal distribution. Assuming the contrary, that there exists a 2-state HMM that has this marginal distribution, we will first show that there is only one possible emission matrix. We will then use that to further show that the posterior, then transitions also must be sparse, resulting in a marginal emission distribution that contradicts the original assumption.
We start by setting up a system of equations. The marginal distribution over observations is obtained by summing over :
Let the inner term be . In a small abuse of notation, let be a row vector with entries , and similarly for . We then have, first summing over ,
We can determine the first row of the emission matrix, from the second row of this system of equations, rewritten here:
We can deduce that , otherwise . Without loss of generality, assume , then , since . Therefore,
We can similarly determine the second row of the emission matrix, , from the last row of the system of equations:
As we determined that , must be 0, otherwise . Therefore , yielding
Putting it together, the full emission matrix is given by
This allows us to find the posterior distribution via Bayes’ rule:
implying . By similar reasoning, we have and .
Given the sparse emissions and posteriors, we will show that the transitions must be similarly sparse, resulting in an overly sparse marginal distribution over emissions (contradiction). We can lower bound
by the definition of total probability and nonnegativity of probability. Then, substituting , we have
from which we can deduce .
Now, we will show that , which contradicts the marginal distribution. We have
where we obtained the second equality because and . As , we have . As this is a contradiction, we have shown that there exists a marginal distribution modelable with a 3-state HMM with rank 2, but not a 2-state HMM.
Appendix B Low-Rank Hypergraph Marginalization for HMMs and PCFGs
We provide the low-rank hypergraph marginalization algorithms for HMMs and PCFGs in Alg. 4, with loops over labels (and products of labels) and feature dimensions left implicit for brevity. We also assume that the label sets for PCFG are uniform for brevity – in practice, this can easily be relaxed (this was not assumed in Alg. 2). We show how the normalizing constants are explicitly computed using the unnormalized low-rank factors in each algorithm.
Appendix C Extension of the Low-Rank Constraint to Other Semirings
Enforcing low-rank constraints in the scoring matrices leads to a speedup for the key step in the hypergraph marginalization algorithm:
(8) |
where . While the low-rank constraint allows for speedups in both the log and probability semirings used for marginal inference, the low-rank constraint does not result in speedups in the tropical semiring, used for MAP inference. To see this, we first review the low-rank speedup in scalar form. The key matrix-vector product step of marginal inference in scalar form is given by
which must be computed for each . The first line takes computation, while the last line takes computation. The speedup comes rearranging the sum over and , then pulling out the factor, thanks to the distributive propery of multiplication. When performing MAP inference instead of marginal inference, we take a max over instead of a sum. Unfortunately, in the case of the max-times semiring used for MAP inference, we cannot rearrange max and sum, preventing low-rank models from obtaining a speedup:
Appendix D Data Details
For language modeling on Penn Treebank (Ptb) [Marcus et al., 1993] we use the preprocessing from Mikolov et al. [2011], which lowercases all words and substitutes OOV words with UNKs. The dataset consists of 929k training words, 73k validation words, and 82k test words, with a vocabulary of size 10k. Words outside of the vocabulary are mapped to the UNK token. We insert EOS tokens after each sentence, and model each sentence, including the EOS token, independently.
The four polyphonic music datasets, Nottingham (Nott), Piano, MuseData (Muse), and JSB chorales (JSB), are used with the same splits as Boulanger-Lewandowski et al. [2012]. The data is obtained via the following script. Each timestep consists of an 88-dimensional binary vector indicating whether a particular note is played. Since multiple notes may be played at the same time, the effective vocabulary size is extremely large. The dataset lengths are given in Table 3.
Total Length | ||||
---|---|---|---|---|
Dataset | Avg Len | Train | Valid | Text |
Nott | 254.4 | 176,551 | 45,513 | 44,463 |
Piano | 872.5 | 75,911 | 8,540 | 19,036 |
Muse | 467.9 | 245,202 | 82,755 | 64,339 |
JSB | 60.3 | 64,339 | 4,602 | 4,725 |
In experiments with PCFGs for language modeling, we also use Ptb, but with the splits and preprocessing used in unsupervised constituency parsing [Shen et al., 2018, 2019, Kim et al., 2019]. This preprocessing discards punctuation, lowercases all tokens, and uses the 10k most frequent words as the vocabulary. The splits are as follows: sections 2-21 for training, 22 for validation, 23 for test. Performance is evaluated using perplexity.
In experiments with HSMMs for video modeling, we use the primary section of the CrossTask dataset [Zhukov et al., 2019], consisting of about 2.7k instructional videos from 18 different tasks such as “Make Banana Ice Cream” or “Change a Tire”. We use the preprocessing from Fried et al. [2020], where pretrained convolutional neural networks are first applied to extract continuous image and audio features for each frame, followed by PCA to project features to 300 dimensions.121212https://github.com/dpfried/action-segmentation We set aside 10% of the training videos for validation.
Appendix E Generative Process of HSMM
We use an HSMM to model the generative process of the sequence of continuous features for each video. The HSMM defines the following generative process: first, we sample a sequence of discrete latent states with a first-order Markov model. Next, we sample the length of observations under each state from a Poisson distribution truncated at max length . The joint distribution is defined as
(9) |
where the sequence length can be computed as . In this work, we only consider modeling continuous , so we use a Gaussian distribution for .
To compute , we can marginalize using dynamic programming similar to HMMs, except that we have an additional factor of : the overall complexity is (ignoring the emission part since they are usually not the bottleneck). We refer to Yu [2010] for more details.
Appendix F Full Parameterization of HMMs, PCFGs, and HSMMs
In this section, we present more details on the parameterizations of the HMM, PCFG, and HSMM. The main detail is where and how are neural networks used to parameterize state representations.
For low-rank HMMs (LHMMs) we use the following mixed parameterization that specifically targets the state-state bottleneck:
(10) | ||||
where is the embedding of when is used as head, its embedding when used as tail, are MLPs with two residual layers, and feature map .
The PCFG uses a similar mixed parameterization. These probabilities correspond to start (), preterminal (), and standard productions () respectively.
(11) | ||||
where / is the embedding of when is used as head,/ is the embedding of / when they are used as tail, and are MLPs with two residual layers as in Kim et al. [2019]. We use the feature map .
For both HMMs and neural PCFG models, we use the same parameterization of the MLPs and as Kim et al. [2019]:
(12) | ||||
with , and .
For HSMMs, the baseline (HSMM in Table 2) follows the fully unsupervised setting in Fried et al. [2020] except that we don’t apply any state constraints from the prior knowledge of each task.131313We got rid of those constraints to allow for changing the total number of states, since otherwise we can’t make any changes under a predefined state space. The model maintains a log transition probability lookup table for , a lookup table for the log of the parameters of the Poisson distribution . We maintain a mean and a diagonal covariance matrix for the Gaussian distribution for each . For low-rank HSMMs (LHSMMs), we use the same parameterization for as in HMMs:
(13) |
where is the embedding of when is used as head, its embedding when used as tail, and the feature map . The emission parameterization is the same as in baseline HSMMs, a Gaussian kernel.
Appendix G Initialization and Optimization Hyperparameters
We initialize the parameters , in and variants, of feature maps using orthogonal feature projections [Choromanski et al., 2020], and update it alongside the model parameters during training.
HMM parameters are initialized with the Xavier initialization [Glorot and Bengio, 2010].141414 For banded experiments, we initialize the band parameters by additionally adding 30 to each element. Without this the band scores were too small compared to the exponentiated scores, and were ignored by the model. We use the AdamW [Loshchilov and Hutter, 2017] optimizer with a learning rate of , , weight decay 0.01, and a max grad norm of 5. We use a state dropout rate of 0.1, and additionally have a dropout rate of 0.1 on the feature space of LHMMs. We train for 30 epochs with a max batch size of 256 tokens, and anneal the learning rate by dividing by 4 if the validation perplexity fails to improve after 4 evaluations. Evaluations are performed 4 times per epoch. The sentences, which we model independently from one another, are shuffled after every epoch. Batches of sentences are drawn from buckets containing sentences of similar lengths to minimize padding.
For the polyphonic music datasets, we use the same hyperparameters as the language modeling experiments, except a state dropout rate of 0.5 for JSB and Nottingham, 0.1 for Muse and Piano. We did not use feature space dropout in the LHMMs on the music datasets. For Nottingham and JSB, sentences were batched in length buckets, the same as language modeling. Due to memory constraints, Muse and Piano were processed using BPTT with a batch size of 8 for Muse and 2 for Piano, and a BPTT length of 128. We use for all embeddings and MLPs on all datasets, except Piano, which due to its small size required dimensional embeddings and MLPs.
For PCFGs, parameters are initialized with the Xavier uniform initialization [Glorot and Bengio, 2010]. We follow the experiment setting in Kim et al. [2019] and use the Adam [Kingma and Ba, 2017] optimizer with , a max grad norm of 3, and we tune the learning rate from using validation perplexity. We train for 15 epochs with a batch size of 4. The learning rate is not annealed over training, but a curriculum learning approach is applied where only sentences of at most length 30 are considered in the first epoch. In each of the following epochs, the longest length of sentences considered is increased by 1.
For HSMMs, we use the same initialization and optimization hyperparameters as Fried et al. [2020]: The Gaussian means and covariances are initialized with empirical means and covariances (the Gaussian parameters for all states are initialized the same way and they only diverge through training). The transition matrix is initialized to be uniform distribution for baseline HSMMs, and the transition embeddings are initialized using the Xavier initialization for LHSMMs. The log of Poisson parameters are initialized to be 0. We train all models for 4 epochs using the Adam optimizer with initial learning rate of 5e-3, and we reduce the learning rate 80% when log likelihood doesn’t improve over the previous epoch. We clamp the learning rate to be at least 1e-4. We use a batch size of 5 following Fried et al. [2020], simulated by accumulating gradients under batch size 1 in order to scale up the number of states as much as we can. Gradient norms are clipped to be at most 10 before updating. Training take 1-2 days depending on the number of states and whether a low-rank constraint is used.
We use the following hardware for our experiments: for HMMs we run experiments on 8 Titan RTX GPUs with 24G of memory on an internal cluster. For PCFGs and HSMMs we run experiments on 1 Nvidia V100 GPU with 32G of memory on an internal cluster.
Appendix H HMM Rank Analysis
Table 4 contains the empirical ranks of trained HMMs and LHMMs, estimated by counting the number of singular values greater than 1e-5. Note that the feature dimension is the maximum attainable rank for the transition matrix of an LHMM. Although LHMMs often manage to achieve the same validation perplexity as HMMs at relatively small , the ranks of the transition matrices are much lower than both their HMM counterparts as well as . At larger state sizes, the ranks of learned matrices are almost half of their max achievable rank. Interestingly, this holds true for HMMs as well, with the empirical rank of the transition matrices significantly smaller than the number of states. Whether this implies that the models can be improved is left to future investigations.
Model | rank | rank | Val PPL | ||
---|---|---|---|---|---|
HMM | 16384 | - | 9187 | 9107 | 144 |
LHMM | 16384 | 8192 | 2572 | 7487 | 141 |
LHMM | 16384 | 4096 | 2016 | 7139 | 144 |
LHMM | 16384 | 2048 | 1559 | 6509 | 141 |
LMM | 8192 | - | 5330 | 5349 | 152 |
LHMM | 8192 | 4096 | 1604 | 5113 | 149 |
LHMM | 8192 | 2048 | 1020 | 4980 | 153 |
LHMM | 8192 | 1024 | 791 | 5033 | 161 |
HMM | 4096 | - | 2992 | 3388 | 155 |
LHMM | 4096 | 2048 | 1171 | 3300 | 154 |
LHMM | 4096 | 1024 | 790 | 2940 | 156 |
LHMM | 4096 | 512 | 507 | 3186 | 163 |
Appendix I Low-rank and Banded HMM Parameterization
In some scenarios, the low-rank constraint may be too strong. For example, a low-rank model is unable to fit the identity matrix, which would have rank . In order to overcome this limitation, we extend the low-rank model while preserving the computational complexity of inference. We perform experiments with an additional set of parameters which allow the model to learn high-rank structure (the experimental results can be found in Tbl. 1). We constrain to have banded structure, such that if . See Fig. 3 for an illustration of banded structure.
Let band segment . The transition probabilities are then given by
(14) |
with normalizing constants
(15) | ||||
The normalization constant for each starting state can be computed in time .
This allows us to perform inference quickly. We can use the above to rewrite the score matrix , which turns the inner loop of Eqn. 3 (specialized to HMMs) into
(16) |
omitting constants (i.e. emission probabilities and normalizing constants). Since is banded, the banded matrix-vector product takes time . This update, in combination with the low-rank product, takes time total. Each update in the hypergraph marginalization algorithm is now 3 matrix-vector products costing each, preserving the runtime of inference.
Appendix J Music Results
The full results on the polyphonic music modeling task can be found in Tbl. 5, with additional models for comparison. Aside from the RNN-NADE [Boulanger-Lewandowski et al., 2012], which models the full joint distribution of notes as well as temporal dependencies; autoregressive neural R-Transformer [Wang et al., 2019] (as reported by Song et al. [2019]) and LSTM (as reported by Ziegler and Rush [2019]); latent continuous LV-RNN [Gu et al., 2015] and SRNN [Fraccaro et al., 2016]; and latent discrete TSBN [Gan et al., 2015] and the baseline HMM; we additionally include the autoregressive Seq-U-Net Stoller et al. [2019], the continuous latent STORN [Bayer and Osendorfer, 2015], DMM [Krishnan et al., 2016] and LNF [Ziegler and Rush, 2019].
Model | Nott | Piano | Muse | JSB |
---|---|---|---|---|
RNN-NADE | 2.31 | 7.05 | 5.6 | 5.19 |
Seq-U-Net | 2.97 | 1.93 | 6.96 | 8.173 |
R-Transformer | 2.24 | 7.44 | 7.00 | 8.26 |
LSTM | 3.43 | 7.77 | 7.23 | 8.17 |
STORN | 2.85 | 7.13 | 6.16 | 6.91 |
LV-RNN | 2.72 | 7.61 | 6.89 | 3.99 |
SRNN | 2.94 | 8.2 | 6.28 | 4.74 |
DMM | 2.77 | 7.83 | 6.83 | 6.39 |
LNF | 2.39 | 8.19 | 6.92 | 6.53 |
TSBN | 3.67 | 7.89 | 6.81 | 7.48 |
HMM | 2.43 | 8.51 | 7.34 | 5.74 |
LHMM | 2.60 | 8.89 | 7.60 | 5.80 |


Appendix K PCFG Analysis
Kernel for | PPL | |||
---|---|---|---|---|
SM | SM | SM | SM | 243.19 |
LR | SM | SM | SM | 242.72 |
LR | LR | LR | SM | 259.05 |
LR | LR | LR | LR | 278.60 |
Figure 4 shows the entropy distribution of the production rules for both using softmax kernel and the approximation. The average entropies of the two distributions are close. Besides, under this setting, are close for both kernels as well (softmax 0.20, linear 0.21), eliminating the possibility that the kernel model simply learns to avoid using (such as by using a right-branching tree).
In Table 6, we consider the effects of the mixed parameterization, i.e. of replacing the softmax parameterization with a low-rank parameterization. In particular, we consider different combinations of preterminal / nonterminal tails , , , and (our main model only factorizes nonterminal / nonterminal tails). Table 6 shows that we get the best perplexity when we only use on , and use softmax kernel for the rest of the space. This fits with previous observations that when the label space is large, a model with a very small rank constraint hurts performance.151515In this particular ablation study, the size of is only one-ninth of the total state space size .
Appendix L Speed and Accuracy Frontier Analysis
We provide plots of the speed and accuracy over a range of model sizes for HMMs and PCFGs, in Figure 5 (left and right respectively). Speed is measured in seconds per batch, and accuracy by perplexity. Lower is better for both.
For HMMs, we range over the number of labels . For softmax HMMs, more accurate models are slower, as shown in Figure 5 (left). However, we find that for any given accuracy for a softmax model, there exists a similarly accurate LHMM that outspeeds it. While we saw earlier in Figure 1 that at smaller sizes the low-rank constrain hurt accuracy, a model with a larger state size but lower rank achieves similar accuracy at better speed compared to a small HMM.
For PCFGs, we range over . We find a similar trend compared to HMMs: accuracy results in slower models, as shown in Figure 5 (right). However, the LPCFG does not dominate the frontier as it did with HMMs. We hypothesize that this is because of the small number of labels in the model. In the case of HMMs, smaller softmax HMMs were more accurate than the faster low-rank versions, but larger LHMMs with low rank were able to achieve similar perplexity at faster speeds. This may be realized by exploring LPCFGs with more state sizes, or simply by scaling further.


Appendix M Potential Negative Impact
While work on interpretable and controllable models is a step towards machine that can more easily be understood by and interact with humans, introducing external-facing components leaves models possibly more vulnerable to adversarial attacks. In particular, the interpretations (in conjunction with the predictions) afforded by interpretable models may be attacked [Zhang et al., 2018]. Additionally, models with simple dependencies may be easier for adversaries to understand and then craft attacks for [Zhang et al., 2021, Liu et al., 2018].