Elamur Research

What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular Languages

Paper · 2024 · Nadav Borenstein, Anej Svete, Robin Chan et al.

Summary

Two systems can agree on which strings are possible and still disagree about which strings are likely. Borenstein and colleagues make that distinction the basis of an experiment on language models. They generate artificial languages whose probabilities are known, train recurrent networks and Transformers on samples, and measure how closely the learned probabilities match the source. The setup makes it possible to ask which properties of a language make its distribution difficult to recover.

The sources are deterministic probabilistic finite-state automata. Each has a finite collection of states, and the current state determines the probabilities of emitting another symbol or ending the string. A state can lead back to itself, so even a small automaton can generate strings of unbounded length. The authors vary the number of states, the alphabet size, and the rank of the matrix of scores used to assign probabilities. Rank measures how many independent directions those scores occupy. Automata can share the same states, symbols, and transition destinations while assigning probabilities through matrices of different ranks.

The experiments use 2100 random automata and sample 20k strings per automaton before splitting the data for training and testing. The paper compares the resulting string distributions using Kullback–Leibler divergence, a measure that discounts the uncertainty already present in the source. Greater rank and longer expected strings are associated with larger divergence for both architectures. Wider hidden representations are associated with smaller divergence. Rank has the largest positive regression coefficient among the recurrent results, while expected length has the largest positive coefficient among the Transformer results. At the mean settings of the regression predictors, fitted divergence is 8.72 for the recurrent networks and 13.5 for the Transformers.

The paper connects the results to a constraint on exact representation. A shared linear output layer can express only as many independent directions as its input width allows. The authors formulate a lower bound in terms of the source rank. Its precise interpretation depends on how logits are defined, because adding a common offset to all the scores for a state leaves its probabilities intact. The experimental result uses rank as a property of the matrices that generated the data. It shows how that property relates to learning under the study’s training conditions, alongside the contribution of string length, which affects both what a learner has to track and how errors accumulate across a complete string.

Deep dive: What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular Languages

Random finite-state languages reveal how matrix rank, string length, and hidden-state size affect learning in recurrent networks and Transformers. · about 35 minutes to read

The problem and its context

From membership to probability

A formal language can be described as a set of strings. A recognizer answers whether a given string belongs to that set. A probabilistic description assigns weight to each complete string, including the decision to end it at that point. Membership tells us whether an outcome is allowed. Probability tells us how frequently it should occur relative to the alternatives. The second question remains informative even when every finite string over the alphabet is allowed.

Consider the automata in this study. Every state offers an outgoing transition for each symbol, and the procedure assigns positive probabilities to those transitions and to stopping. For any proposed string, there is a path that spells it and ends. The same is true of another automaton generated by the procedure, even when its transition destinations and probabilities differ. A membership test would treat both automata alike. A distributional comparison can detect a discrepancy in how frequently they stop, which symbols they favor, or how their preferences change after a particular prefix.

The paper takes issue with empirical evaluations that turn next-symbol probabilities into decisions. Some earlier experiments checked whether symbols allowed by a grammar received sufficient probability. Others checked whether the most probable prediction matched a target. The former can miss errors in the relative weights of continuations that all pass the threshold. The latter can give identical credit to predictions with very different confidence. Both tests answer meaningful questions about prediction or recognition. The present question asks how much probability the learner assigns to each outcome the generator can produce. The paper discusses earlier evaluations in this connection, including work on dynamic counting, Transformer recognition, and the Chomsky hierarchy. On the Ability and Limitations of Transformers to Recognize Formal Languages · Neural Networks and the Chomsky Hierarchy

Stopping makes the difference particularly concrete. A predictor could give a good account of which symbol comes next whenever a string happens to continue. If it regularly assigns too little probability to ending, it will still put too much probability on long strings. Conversely, a predictor could reproduce the overall length distribution yet choose the wrong symbols within it. A score based on the probability of a complete string accounts for both kinds of error, because continuation and termination enter the same calculation.

Why use a known generator?

Studies of naturally occurring text can investigate whether a predictor tracks a syntactic dependency or whether its internal representations carry linguistic information. Borenstein and colleagues describe these studies as valuable evidence about linguistic competence. Their experiment needs a different kind of access. A corpus gives examples of what was written, while the distribution from which those examples should be understood to arise remains open to interpretation. A finite-state source lets the researchers specify the probability of an observed string and derive aggregate properties of the generator from its parameters. Assessing the Ability of LSTMs to Learn Syntax-Sensitive Dependencies · A Structural Probe for Finding Syntax in Word Representations

The paper describes a closely related study by Jumelet and Zuidema that also makes the generating distribution available. Their experiments use probabilistic context-free grammars based on human language, and the grammar permits questions about how particular constituents are encoded. The finite-state study gives up some of that linguistic specificity in order to vary numerical properties across a broad collection of artificial sources. The unit of comparison becomes a family of distributions sharing some features of construction and differing in others.

Other comparisons in the paper clarify what it means to learn a source. Valvoda and colleagues use finite-state transducers to investigate compositional generalization, where the learner must produce the appropriate output for an input string. White and Cotterell vary an artificial grammar to study preferences related to word order. Akyürek and colleagues instead ask a learner to infer a regular language from examples supplied in its context, with training geared toward handling different generators. In Borenstein and colleagues’ design, the training corpus represents a particular source and the learner’s parameters are fitted to that corpus. Test performance measures how well that fit generalizes to held-out strings from the source.

The gap between capacity and learning

The paper draws a distinction between existence and training. A representational result can establish that some parameter setting implements a target distribution or that a given architecture, under stated assumptions, lacks sufficient capacity to do so. It leaves open whether ordinary training on samples finds suitable parameters. An experiment can establish how much divergence remains after a particular training procedure. A high divergence can reflect insufficient capacity, inadequate evidence in the sample, or difficulty finding good parameters.

Prior results give more direct connections between recurrent networks and finite-state machines than between Transformers and those machines. A recurrent update carries a state forward as it reads symbols, which gives it a natural analogue of a finite-state transition. The paper recounts results establishing equivalence between certain finite-precision recurrent language models and deterministic probabilistic automata. It also recounts a worst-case result in which the size of a recurrent representation needed for equivalence scales with the state count and alphabet size. Such a result concerns families of potentially demanding automata. It leaves room for individual automata whose output probabilities have a compact structure.

A Transformer uses self-attention to compute representations of prefixes. Its computation need not maintain an explicit state that is updated by the same mechanism as a finite automaton. The authors describe theoretical connections involving extra sequential computation or increasing depth, many of which address recognition. For a direct result about probabilities, they cite a construction that gives a hard-attention Transformer equivalent to any n-gram language model. An n-gram source uses a bounded suffix to determine its next-symbol distribution. A finite-state source can maintain distinctions that cannot be read from a bounded suffix in that way. The construction therefore establishes a capability for a particular family. The Parallelism Tradeoff · Attention Is All You Need

A recurrent learner and a Transformer can nonetheless share the same kind of probability-producing output layer. This offers a way to study a constraint that applies regardless of how a prefix representation was computed. The experiment uses both architectures to ask how that shared output constraint, the sequential properties of the source, and the width available to the learner relate to empirical difficulty.

The method, step by step

How the source generates a string

A deterministic probabilistic finite-state automaton starts in a designated state. At each step, it draws an outcome from that state’s distribution. If it draws an ordinary symbol, it emits the symbol and follows the corresponding transition. If it draws the end marker, generation finishes. A transition can return to a state that the automaton has already visited. Every visit to that state offers the same distribution of next outcomes, regardless of how the automaton got there.

Determinism concerns the destination after a symbol is chosen. The choice of symbol is random, but the combination of the current state and the chosen symbol determines the next state. As a result, observing the prefix identifies the current state when the start state and transitions are known. Several different prefixes can identify the same state, in which case they have identical probabilities for the next outcome. Recovering the distribution means learning when that kind of equivalence holds, or at least making predictions consistent with it.

The paper illustrates path probabilities with strings over the alphabet containing a and b. A path for a string of the form abⁿabᵐ includes stretches where a state and transition are reused. Repeating a symbol multiplies the path weight by the relevant transition probability each time. The final factor comes from the state reached after all ordinary symbols have been read. A string of the form bbᵐ begins with a different transition and can reach a state where the same ending mechanism is available. This kind of sharing lets a finite source specify probabilities for arbitrarily long strings.

From a random automaton to a learning measurement

The steps in order.

From a random automaton to a learning measurementStep 1: Draw the states, alphabet, and transition destinations1. Draw the states, alphabet, and transition destinationsStep 2: Build logit matrices at feasible ranks2. Build logit matrices at feasible ranksStep 3: Convert state logits into emission and stopping probabilities3. Convert state logits into emission and stopping probabilitiesStep 4: Filter sources by expected string length4. Filter sources by expected string lengthStep 5: Sample strings and separate training from testing5. Sample strings and separate training from testingStep 6: Train recurrent and Transformer predictors at several widths6. Train recurrent and Transformer predictors at several widthsStep 7: Estimate divergence using test likelihood and source entropy7. Estimate divergence using test likelihood and source entropy

String probabilities and the automaton’s parameters

Let the alphabet be a finite, nonempty collection of ordinary symbols. Its Kleene closure includes every finite sequence of those symbols, including the empty string. The end marker is an extra prediction outcome. It belongs to the vocabulary used for next-symbol prediction and stays outside the alphabet of complete strings.

p(y) = p(EOS ∣ y) ∏ₜ₌₁ᵀ p(yₜ ∣ y₍₍ₜ)

Here p is the probability distribution, y is a complete string of length T, and yₜ is its symbol at position t. The notation y₍₍ₜ denotes the prefix strictly before position t, and ∣ reads as “given.” The product ∏ multiplies the conditional probabilities from the first ordinary symbol through position T. The factor p(EOS ∣ y) gives the probability of ending after the entire string. For the empty string, the product is empty and the stopping probability supplies the string’s weight.

A = (Σ, Q, δ, λ, ρ)

Here A is an automaton, Σ its alphabet, Q its finite set of states, and δ the set of weighted transitions. The function λ assigns initial probabilities to states, and ρ assigns probabilities of stopping in those states. A transition specifies a starting state, a symbol, a non-negative weight, and a destination. Initial probabilities sum to one. At any state, the outgoing transition weights and the stopping probability also sum to one. In the deterministic case, exactly one state has positive initial probability, and each state and symbol has at most one destination with positive weight.

w(π) = λ(s₁) (∏ₙ₌₁ᴺ wₙ) ρ(sₙ₊₁)

Here π is a path of N transitions, s₁ is its starting state, wₙ is the weight of transition n, and w(π) is the probability weight of the whole path. In the final factor, sₙ₊₁ denotes the state following the last transition, with n there taking its terminal value N. That last factor is required because arriving at a state and ending there are distinct events. A path with no transitions starts and stops in the same state.

A(y) = ∑π∈Π(A,y) w(π)

Here A(y) is the probability assigned to string y, and Π(A,y) is the set of paths π in A whose ordinary symbols spell y. The summation adds the path weights w(π). A nondeterministic automaton can have several paths for the same string. The deterministic full-support sources used in the experiment have a single such path. A regular language model is any string distribution equivalent to one defined by a probabilistic finite-state automaton. Equivalence requires agreement on the probability of every complete string.

A minimal deterministic automaton is one for which no equivalent deterministic automaton uses fewer states. Its state names can be changed without altering the distribution. Minimality matters for the capacity argument because a representation containing unreachable or redundant states can make the matrix look larger without introducing new prediction behavior. The experimental generator begins with randomly wired graphs. The theorem is stated for a minimal source, and the generation procedure does not describe a minimization step.

How both predictors turn a prefix into probabilities

The source has an explicit state for each prefix. The neural learner computes a vector. In a recurrent network, the representation is updated as successive symbols are read. In a Transformer, it is computed from the prefix using self-attention. The paper uses a shared mathematical description of the output in both cases. A linear transformation produces a score for each possible outcome. Softmax converts those scores, called logits, to probabilities by exponentiating and normalizing them.

q(a ∣ u) = exp((E h(u))ₐ) / ∑ᵦ∈Σ̄ exp((E h(u))ᵦ)

Here q is the neural distribution, u is the observed prefix, and h(u) is its hidden representation. The vector h(u) has dimension D, the hidden width relevant to the output. The matrix E maps it to a vector with a coordinate for each outcome in Σ̄, the alphabet Σ with EOS added. The subscript a selects the outcome whose probability is being evaluated. In the denominator, b ranges over all the outcomes, and exp is the exponential function. The fraction is the a coordinate of the softmax of E h(u).

The paper writes the automaton in a corresponding form. The vector for a state is one-hot, meaning that the coordinate for that state has value one and all other coordinates have value zero. Multiplying by a matrix of state scores then simply selects the column associated with the current state. The automaton’s transition rule computes the state. The linear map and softmax supply the distribution for that state.

p(a ∣ u) = softmax(T hₐ(u))ₐ

Here p is the source distribution, u the prefix, and a the next outcome, which can be an ordinary symbol or EOS. The vector hₐ(u) denotes the one-hot state encoding for automaton A after reading u. The matrix T has a column for every state and a row for every outcome. The subscript on the softmax selects outcome a. All the outcomes need positive probabilities for this finite-logit expression to be exact. The generator ensures that positivity through its choice of topology and weights.

Many states can have different probability distributions even when their logits lie in a low-dimensional space. A single direction in score space can be used at several magnitudes, which changes the probabilities after normalization. Rank thus captures a different kind of complexity from state count. The state count concerns distinctions between prefixes that the automaton can retain. Rank concerns the geometry of the scores by which those distinctions affect predictions. A compact output geometry can coexist with a complicated procedure for deciding which state a prefix reaches.

Building sources with controlled rank

The researchers draw the number of states and the alphabet size independently and uniformly from 2, 4, 6, 8, 10, 12, 16. They then choose a destination uniformly for every combination of state and ordinary symbol. A single destination can receive several transitions, each bearing its own symbol. With exactly one outgoing transition for each symbol at each state, the total number of transitions is the number of states multiplied by the alphabet size. Stopping is represented by a final weight instead of a transition to another ordinary state.

They sample a matrix of logits with normally distributed entries. The normal distribution in the experimental specification has mean 0 and variance 4. Starting from this matrix, they construct versions at feasible ranks from 1, 2, 4, 6, 8, 10, 12, 16. A rank is feasible only up to the smaller of the matrix’s row and column counts, with the rows corresponding to the output vocabulary including termination. The result is a family of possible weight assignments for a single unweighted transition graph.

Tᴿ = argmin { ‖B − T‖²ꜰ ∣ rank(B) = R }

Here T is the original random matrix, R is the requested rank, and B ranges over matrices with the same dimensions as T. The expression rank(B) is the number of independent directions in the columns of B. The squared Frobenius norm ‖B − T‖²ꜰ sums squared differences between corresponding entries. The operator argmin selects a matrix achieving the smallest value subject to the rank constraint, and Tᴿ denotes that selected matrix. The paper constructs it using a singular value decomposition, retaining the directions associated with the largest singular values.

w(s,a) = softmax(Tᴿ₍∶,s₎)ₐ

Here s is a source state and a is an ordinary alphabet symbol. The notation Tᴿ₍∶,s₎ means the entire column of the rank-controlled matrix corresponding to s. The softmax normalizes that column, and its a coordinate gives the weight w(s,a) of the outgoing transition labeled by a. The destination comes from the already sampled graph.

ρ(s) = softmax(Tᴿ₍∶,s₎)ₑₒₛ

Here ρ(s) is the final weight at state s, and the subscript ₑₒₛ selects the end-of-sequence outcome. The two formulas use the same normalization, so termination competes with every outgoing symbol in a single distribution. A source with a larger final weight at a often visited state gives more probability to stopping during visits to that state.

Producing several ranks from the same random matrix and graph provides a direct comparison of different weight assignments under shared structural conditions. It also determines what the comparison can isolate. Changing rank changes the columns that pass through softmax. It can therefore change the chance of stopping and the relative frequency of paths, even while every path continues to exist. The study records expected length and entropy to describe some of the other variation introduced by assigning those weights.

The authors discard sources with expected lengths above the median, which in their experiment was 46 symbols. They give a concrete reason for this filter. The Transformer operates with a finite input window, while the generated strings have an unbounded range of possible lengths. By making extremely long strings less prominent, the filter reduces the mismatch that truncation can introduce between the theoretical source and the actual strings used for fitting and scoring. A source with a modest expected length can still occasionally generate a long sample.

The width constraint and the choice of logits

The paper’s theorem concerns a minimal deterministic source with full support. It states a lower bound on the hidden size of a representation-based learner that agrees with the source on every string. The reasoning begins with an observation about matrix multiplication. Whatever computation produces the learner’s vector, its logits lie in the column space of its output matrix. A hidden vector of dimension D can generate at most D independent logit directions through that matrix. If exact agreement requires a certain number of such directions, the output must have enough width to supply them.

Exact equality of the complete-string distributions requires equality of the next-outcome distributions at each prefix with positive probability. The score vectors themselves can differ because softmax is unchanged by shifts that add the same scalar to every coordinate. The paper’s proof expresses this relationship through the two softmax normalization constants.

Z_E(u) = ∑ᵦ∈Σ̄ exp((E h(u))ᵦ)

Here Z_E(u) is the learner’s normalizing constant at prefix u. The output matrix E and prefix representation h(u) produce a logit for each outcome b in the extended alphabet Σ̄. Summing their exponentials gives the denominator of the learner’s conditional distribution.

Z_T(u) = ∑ᵦ∈Σ̄ exp((T hₐ(u))ᵦ)

Here Z_T(u) is the analogous normalizing constant for the automaton, with T its logit matrix and hₐ(u) its one-hot state encoding. The index b again ranges over the ordinary symbols and the end marker.

E h(u) − log Z_E(u) 𝟙 = T hₐ(u) − log Z_T(u) 𝟙

Here log takes the logarithm of each positive normalization constant, and 𝟙 is a vector of ones with a coordinate for every outcome. Each side is the vector of log probabilities obtained by subtracting the same log normalizer from all its logits. The equality is the condition that the two predictors assign identical probabilities at prefix u.

E h(u) = T hₐ(u) + log(Z_E(u) / Z_T(u)) 𝟙

Here the normalizer ratio gives the common offset separating the learner’s scores from the source’s scores. The other symbols retain their meanings from the preceding equality. The offset is allowed to vary with the prefix. This is the step at which the choice of representation of the logits matters for the theorem.

The authors state that the width must be at least R, the rank of the source’s output matrix. Read literally for an arbitrary raw matrix T, that claim requires a qualification. The proof moves from the offset relation to a claim about inclusion of the raw source span in the learner’s span. The relation guarantees agreement of score differences. It allows each source column to be shifted by an outcome-independent constant, which can remove a direction that never affected the probabilities. For example, a column proportional to 𝟙 already yields uniform probabilities, and it can be replaced by the zero vector with the same result.

One way to make the width argument independent of that choice is to subtract the EOS score from each ordinary symbol’s score. This compares all outcomes to the same reference and erases the arbitrary offset. In the resulting coordinates, the source columns give log odds and the learner’s log odds are still obtained by a linear map of its hidden representation. The dimension spanned by the source’s log odds therefore gives a width requirement. The experiment, meanwhile, varies the rank of the sampled logit matrices. That is an identifiable property of the experimental construction, even when some of a matrix’s raw variation can be removed without changing its probabilities.

A width requirement addresses only the output side of exact equivalence. The learner also needs a way of computing a suitable representation for each prefix. An output layer that can express the necessary score directions might receive the wrong representation after a transition, in which case its probabilities will still be wrong. The distinction matters empirically. A wider representation can help by providing more output directions, by making prefix computation easier, or through both routes.

From sampled strings to trained predictors

For each retained source, the authors sample 20k strings, ending each generation when the automaton draws EOS. They split the corpus so that an identical string does not appear in both the train and test sets. The test set contains at least 2k strings. This design preserves a distinction between repeated evidence within training and generalization to a held-out string identity. It does not turn the task into an assessment of unseen symbols. Test strings use the same alphabet and can share many prefixes and transitions with training strings.

The experiment truncates strings to 256 symbols to fit the Transformer’s context. The generative source can still be used to compute entropy over complete strings, so the filtering and truncation choices are relevant to the meaning of the resulting score. The benchmark aims to approximate recovery of the source distribution while taking account of a finite training and evaluation window.

The experimental procedure lists recurrent and Transformer runs for each D in 2, 4, 6, 8, 10, 12, 16. The recurrent configuration uses a unidirectional LSTM with four hidden layers, 64-dimensional internal states, and an embedding size of 64. The Transformer configuration follows GPT-2, with six attention layers, four heads per layer, 128-dimensional representations, an embedding size of 64, and a context length of 256. Those fixed architectural dimensions appear alongside the sweep over D. The paper’s training description leaves the exact connection between the varied width and the fixed internal dimensions underexplained. Its theoretical use of D is the width of the representation supplied to the output map.

Both configurations train for two epochs using batches of 32 and a learning rate of 0.001. They minimize cross-entropy. The LSTM uses Adam with default optimizer settings and the Transformer uses AdamW with default settings. In both configurations, the input embeddings and output weights are untied. These choices give the architecture comparison a common objective, corpus, and training duration, with separate architecture and optimizer specifications. Adam: A Method for Stochastic Optimization

Measuring the gap to the source

The evaluation uses forward Kullback–Leibler divergence. Each complete string contributes according to its probability under the source, with the log probability ratio measuring how the learner weights that string relative to the source. This direction of the comparison matters. Strings that the source frequently generates contribute more prominently than very rare strings. Giving too much probability to an outcome also takes probability away from other outcomes because the learner’s probabilities must sum to one.

D_KL(p ∥ q) = ∑ᵧ∈Σ* p(y) log(p(y) / q(y))

Here D_KL denotes Kullback–Leibler divergence, p is the source distribution, and q is the trained learner’s distribution. The symbol ∥ marks the order of the two distributions. The set Σ* contains every finite string over Σ, y ranges over those strings, and log converts a ratio of probabilities into a difference of log probabilities. A smaller divergence means the learner is closer to the source by this measure. Swapping p and q generally yields a different value.

D_KL(p ∥ q) = H(p,q) − H(p)

Here H(p,q) is cross-entropy, the expected negative log probability assigned by q to a string drawn from p. The term H(p) is the source entropy, the expected negative log probability when the same draw is scored by p itself. Subtracting it removes the source’s own uncertainty from the comparison. A source that spreads its probability widely can have large cross-entropy even when the learner is close to it. A source that strongly favors a smaller group of strings can have lower cross-entropy while the learner misses important preferences.

Ĥ(p,q) = −(1/N) ∑ₙ₌₁ᴺ [ log q(EOS ∣ y⁽ⁿ⁾) + ∑ₜ₌₁^|y⁽ⁿ⁾| log q(yₜ⁽ⁿ⁾ ∣ y⁽ⁿ⁾₍₍ₜ) ]

Here Ĥ(p,q) estimates cross-entropy, N is the number of test strings, and y⁽ⁿ⁾ is test string n. The vertical bars in |y⁽ⁿ⁾| give its length. The inner sum adds the log probability of each ordinary symbol yₜ⁽ⁿ⁾, conditioned on the prefix y⁽ⁿ⁾₍₍ₜ preceding position t. The separate term scores the decision to end after the full string. The outer sum averages the negative total over strings. Each position contributes to the score, and the divisor counts strings rather than symbols.

The entropy term can be calculated directly from the source. Even with finitely many states, a source can have infinitely many paths, so direct enumeration of all complete strings would be unsuitable. Determinism helps because each generated string corresponds to one path. The expected contribution from a visit to a state can be computed from the distribution of outcomes there, then accumulated over all possible visits through a matrix calculation. The authors relate this use of finite-state structure to earlier dynamic programming methods. Parameter Estimation for Probabilistic Finite-State Transducers

H(A) = −∑ᵧ∈Σ* A(y) log A(y)

Here H(A) is the entropy of the full string distribution induced by automaton A. The sum covers complete strings y in Σ*, each with probability A(y). In the deterministic case, the summation can equivalently be written over paths π using their weights w(π), since a complete string’s full probability is the weight of its unique path.

Mᵢⱼ = ∑ₐ∈Σ 𝟙{δ(sᵢ,a) = sⱼ} p(a ∣ sᵢ)

Here M is the matrix of probabilities for moving between ordinary states of A. Its entry Mᵢⱼ is the probability of moving from state sᵢ to state sⱼ while emitting an ordinary symbol. The index a ranges over those symbols. In this deterministic notation, δ(sᵢ,a) gives the destination specified by the transition relation, and the indicator 𝟙{…} is one if that destination is sⱼ and zero otherwise. The term p(a ∣ sᵢ) is the emission probability at the starting state. Summing over symbols allows multiple labels to contribute to the same destination. The row excludes the probability of ending.

ξᵢ = −∑ₐ∈Σ̄ p(a ∣ sᵢ) log p(a ∣ sᵢ)

Here ξᵢ is the entropy of the next-outcome distribution at state sᵢ. The extended alphabet Σ̄ includes EOS, so p(a ∣ sᵢ) covers the stopping decision as well as ordinary emission. The minus sign puts the expression in the standard entropy convention. The vector ξ collects these local entropy values for all states.

H(A) = αᵀ(I − M)⁻¹ ξ

Here α is the vector of initial probabilities, with an entry λ(sᵢ) for state sᵢ, and αᵀ writes that vector as a row. The identity matrix is I, M is the matrix for continuing through ordinary transitions, and ⁻¹ denotes matrix inversion. The product weights each state’s local entropy ξᵢ by its expected number of visits. Those visits include the starting state and the final visit when stopping is chosen. The result accumulates the expected log-probability cost of a whole generation.

The same visit calculation gives expected length. After n ordinary transitions, the row vector αᵀMⁿ describes the probability of reaching each state while generation has survived that far. Its entries sum to the chance of emitting at least n symbols. Summing over n therefore counts how long generation continues. The term for the starting visit must be treated separately when length means the number of ordinary symbols.

αᵀ(I − M)⁻¹ 𝟙 = ∑ₙ₌₀^∞ Pr(L ≥ n) = 1 + E[L]

Here 𝟙 is now a vector of ones indexed by states, L is the number of ordinary symbols emitted, Pr(L ≥ n) is the probability of emitting at least n symbols, and E[L] is the expected ordinary-symbol length. The sum runs from n = 0 through all later positions. The initial term contributes one because every string has length at least zero. This is the counting convention implied by the paper’s derivation, which includes the initial visit even though its displayed expected-length statement labels the matrix expression as the expected path length. The reported filter threshold and length effects use the paper’s length specification.

The statistical comparison

The authors fit separate linear regressions to the divergence scores for the recurrent and Transformer runs. The source predictors are the number of states, alphabet size, transition count, actual rank, expected length, the upper bound on rank from matrix dimensions, and entropy. The learner contributes its hidden width. Transition count combines two size properties, and the upper bound on rank summarizes a further relationship between matrix dimensions. Including these predictors lets the regressions describe how different aspects of size and shape accompany changes in the outcome.

Each predictor is standardized before fitting. Its mean becomes the origin, and its standard deviation sets the scale. A coefficient expresses the fitted change in divergence for a one-standard-deviation increase in that predictor with the others held fixed in the equation. The intercept is the predicted divergence at the mean settings of the standardized predictors. This makes the coefficients more comparable across properties measured in different units. It also means that, for instance, the rank coefficient is not an estimate of the effect of adding one rank dimension.

Experiments and results

What was trained and compared

The paper reports held-out results from 2100 randomly generated automata and describes the experiment as yielding 15k recurrent and 15k Transformer runs. The learners are trained on sampled strings from each source and tested on held-out strings from that source. Their task is to capture each individual distribution, with a fresh training procedure for the corpus of a different source. The experiment therefore compares how the architectures fare across a collection of learning problems of the same general kind.

The principal empirical comparison is between the LSTM and GPT-2-style Transformer under the training conditions described above. For a given source, the source’s own entropy supplies the reference for evaluating cross-entropy. There is no corresponding leaderboard of recognizers or additional classical sequence predictors in the main experiment. The recurrent and attention-based systems are compared on the same probability estimation task, while the source provides the theoretical expectation used to define the error.

The intercept comparison shows the overall difference using the regressions. Both values refer to estimated held-out divergence with the predictors at their standardized means. They are neither accuracy scores nor direct averages over symbols. The figures describe divergence in bits, with string-level aggregation.

Fitted held-out KL divergence for recurrent and Transformer learners on random automata

The recurrent learner has lower fitted divergence at the mean predictor settings.

Fitted held-out KL divergence for recurrent and Transformer learners on random automataTransformer: 13.5Transformer13.5Recurrent network (this paper): 8.72Recurrent network (this paper)8.72
The numbers
System or settingKL divergence in bits
Transformer13.5
Recurrent network (this paper)8.72

The appendix shows a related comparison using held-out cross-entropy. It groups sources by a complexity measure defined from the state count, alphabet size, and rank. Loss is summed over symbols and divided by the number of test strings. The recurrent networks generally have lower loss in that plot, with a clearer separation for more complex sources. Because the plot uses cross-entropy, the height of a point includes source uncertainty as well as excess loss. The regression intercepts in the chart are specifically for divergence after the entropy term has been subtracted.

What predicts recurrent learning difficulty

For the recurrent runs, rank has a standardized coefficient of 4.10 with a reported p-value below 0.001. Expected string length has a coefficient of 3.21, with a reported p-value below 0.05. Both indicate larger fitted divergence as their predictor increases, conditional on the other variables. The number of states also has a positive coefficient, 0.68, with a p-value below 0.001. Rank gives the largest positive association in this regression and remains prominent after the analysis accounts for the state count and the other size measures.

The negative associations are source entropy and hidden width. The recurrent entropy coefficient is −0.88 and the coefficient for hidden width is −0.63, each with a reported p-value below 0.001. A predictor with greater width tends to assign probabilities closer to the source at a given source complexity. The entropy association describes sources that are less costly to approximate relative to their own uncertainty when the other predictors are taken into account.

The results for alphabet size, transition count, and the rank ceiling are weaker. Their respective coefficients are 0.22, 0.23, and −0.15, with reported p-values of 0.26, 0.07, and 0.58. The transition predictor deserves careful reading because it summarizes the product of state and alphabet counts, which also enter separately. Its coefficient concerns the fitted contribution of that product once the separate size terms are present.

The numbers distinguish sources that are difficult to track from sources that are difficult to score. More states allow more possible distinctions between histories. A higher rank can make the resulting collection of conditional logits harder for a shared output map to approximate. Many states with closely related score vectors can present a different learning problem from a smaller collection with more independent score directions. The recurrent results support treating those as separate properties of the experimental sources.

What predicts Transformer learning difficulty

Every included predictor reaches the paper’s reported significance threshold in the Transformer regression. Expected length has the largest positive coefficient, 11.70, with a p-value below 0.001. Actual rank has a positive coefficient of 2.99, and alphabet size has a positive coefficient of 2.10, both with p-values below 0.001. The transition count and state count have positive coefficients of 0.64 and 0.60. Their reported p-values are below 0.001 and below 0.01, respectively.

Entropy again has a negative association and is the largest negative coefficient at −7.89. Hidden width has a coefficient of −2.76, and the upper bound on rank has a coefficient of −1.36. All three have reported p-values below 0.001. The rank ceiling and actual rank answer different statistical questions in the fitted equation. Actual rank records the dimensionality chosen for the source’s weights. The ceiling records how large that dimensionality could be for a matrix of the given shape. Their coefficients describe conditional relationships within a set of predictors that are structurally connected.

The comparison with the recurrent regression is clearest where the signs agree. More states, higher actual rank, and longer expected strings accompany larger divergence in both. Greater source entropy and a wider hidden representation accompany smaller divergence in both. The association with expected length is especially marked in the Transformer results, as is the negative association with entropy. Alphabet size, transition count, and the rank ceiling reach significance in the Transformer regression, whereas their recurrent coefficients have weaker statistical support in this experiment.

These fits describe the studied learners and the sampled region of source complexity. The paper offers two explanations for the overall recurrent advantage. One is the closer alignment between a recurrent update and the process of traversing an automaton. The other is that Transformer training may be more sensitive to hyper-parameters adapted to individual sources. The results directly establish the advantage under the chosen protocol. The paper’s expectation that it would persist with more extensive tuning is a separate claim about what another experiment might find.

What the ablations show

Varying rank while retaining the transition graph

The paper’s controlled comparisons vary properties of the source and the learner through a common training procedure. Among them, the rank comparison has a particularly informative control. The unweighted graph can stay fixed while the authors use different low-rank approximations of the same initial score matrix. A prefix then leads to the same state across those variants. What changes is the probability assigned to each symbol and to stopping. Rank can affect learning even when the computation needed to locate the current state is the same.

This control has a precise scope. A change in rank alters the distribution of training strings. It can increase visits to certain states, reduce evidence about others, or shift the typical stopping point. The rank experiment therefore probes the effect of the rank-controlled weighting procedure. The regression helps ask whether rank predicts divergence alongside measured properties of the resulting distribution. It cannot force the two training corpora to convey identical evidence about the shared graph.

The figures compare rank with state count and with alphabet size. In the state-count comparison, divergence tends to increase as the sources get larger and rank rises, though the state trend is noisier. The alphabet comparison is less uniform, which fits the different regression results for alphabet size across architectures. Presenting these properties jointly matters because a larger source can support more rank settings. A comparison at a rank that only larger matrices can reach does not give the same evidence about size as a comparison within ranges where both small and large matrices are represented.

Varying the representation width

The width sweep pairs each training corpus with recurrent learners and Transformers of several specified widths. Within an architecture and source, it tests whether changing the size available to the representation improves probability estimation. The figures show divergence generally rising with the source rank and falling with the learner’s width. The regression likewise assigns a negative coefficient to width in both architectures.

This pattern is compatible with the output-dimension argument. When the source probabilities require many independent score differences, a narrow representation constrains the output more tightly. Widening the representation can ease that constraint while leaving residual error from prefix computation, finite data, or training. The results show a graded change in divergence. They do not establish a sharp boundary at which matching the source suddenly becomes exact, and the reported regressions do not estimate a rank-by-width interaction.

A learner can also give a good approximate account of the source without reproducing all of its score directions equally well. Frequent states carry more weight in forward divergence than states that are rarely visited. A restricted learner can achieve lower divergence by reproducing common conditional distributions and tolerating larger errors on less probable paths. That feature of the metric helps explain why a theoretical condition for equality across all strings and a curve of empirical divergence address different levels of performance.

Testing the roles of entropy and length

The authors place entropy beside divergence in plots grouped by rank, state count, alphabet size, and hidden width. The comparison checks whether patterns in the learner’s error simply mirror patterns in the source’s uncertainty. An increase in held-out cross-entropy can come from uncertainty already present in the data. The divergence calculation first subtracts that uncertainty, and the regression then includes entropy as a predictor of the remaining variation. The rank association persists in that adjusted analysis.

Higher source entropy accompanies smaller divergence in both fits. The authors suggest that a source approaching simple randomness can be easy to approximate because its next-outcome preferences carry little hidden structure. The explanation applies most directly when different histories lead to similar predictive distributions. Entropy on its own can also be high because generation lasts longer or many outcomes remain possible. The reported coefficient is for entropy conditional on the included predictors, so it gives evidence for an association under the setup while leaving that explanation open to direct testing.

The length analyses show a steeper relationship between expected length and divergence for Transformers. The length effect has at least two plausible contributions within the experiment. A longer prefix can make it harder to recover the state that determines what comes next. A longer string also gives prediction errors more opportunities to enter the sum of log probabilities. The figures show a difference between architectures on a per-string measure. They leave open how much of the increase would remain under a per-symbol measure or under an evaluation that deliberately holds the number of prediction steps fixed.

The analyses thus test properties that could affect different parts of the learning problem. Rank concerns the set of distributions the learner needs to express. Width concerns the representation available to express them. Expected length affects how long the learner must keep making consistent predictions and how its errors are scored. Looking at these properties together gives a more detailed account of the observed divergence than using a single overall measure of automaton size.

Limitations

Limits identified by the authors

The authors restrict the study to deterministic finite-state generators. Such a generator has bounded memory in the sense that every prefix is summarized by one member of a finite collection of states. It can produce long strings, but it lacks the unbounded storage afforded by a stack. The study therefore cannot directly establish the learnability of probability distributions that require a stack or another more expressive memory mechanism.

Nondeterministic sources require a different treatment even within finite-state computation. After a prefix, several states can have positive probability. The next-symbol distribution is then a weighted mixture of their individual probability distributions. That combination takes place after the conversion from logits to probabilities, so the deterministic argument that an observed prefix selects a single logit column is no longer available. The paper proposes probabilistic pushdown automata as another extension. Such automata can have infinitely many configurations, making the design of an analogous rank comparison a distinct problem.

The authors also identify a limit on their training investigation. The corpus size is fixed by the data-generation procedure, so there is no learning curve showing how the rank and length effects change as more strings become available. Computational cost constrained the size of the neural systems and prevented language-specific hyper-parameter searches. The authors expect the observed trends to survive improved training, while the evidence directly supports the reported configurations. In particular, the recurrent advantage was measured under a comparison with different internal architectures and optimizer settings.

Limits of the empirical design

The sampled sources cover a specific region of regular distributions. The generator uses a fixed list of alphabet and state sizes, uniformly sampled destinations, normally distributed logits, and rank reductions derived from those logits. The expected-length filter further selects which resulting sources are retained. These choices are valuable because they make the study reproducible at the level of its design and give the statistical comparisons clear inputs. They also mean that the resulting regression describes this family of sources. It does not supply a frequency estimate for similar patterns among regular languages in general or among the distributions found in human writing.

Truncation and the split by string identity matter for the evaluation. The derivation of the cross-entropy estimate invokes independent draws from the source. The implemented test corpus comes from a split that keeps string identities on one side and a procedure that truncates at the context limit. Keeping identical strings out of both sets makes the reported performance more informative about generalization. Depending on how the partition allocates repeated strings, it can also change how the test set represents highly probable outcomes. Truncation can further change the string being scored. The analytic entropy remains that of the source. These details make the reported divergence an approximation whose interpretation depends on the sampling and partition procedure.

The per-string metric gives length an important role even for a predictor that makes errors of similar size at individual positions throughout a sequence. Longer strings allow those errors to accumulate. The data also supply a finite context window, and the filter selects against sources with high expected length. The length findings characterize difficulty in those conditions. They cannot distinguish context limitations from all other reasons for rising per-string loss, or establish performance on strings substantially beyond the training and evaluation window.

The regression coefficients summarize conditional associations. The transition count is determined by state count and alphabet size in this design, the rank ceiling follows from matrix dimensions, and feasible values of actual rank depend on those dimensions. The coefficients for those terms are useful descriptions of a joint fit, but their interpretation as independent interventions is limited. Some sampled sources also share graphs and underlying random matrices, while several runs share the same source corpus. The reported significance values come from the specified regression analysis. The dependence among runs is relevant when interpreting that precision as evidence about a newly sampled family of automata.

The training specification leaves an implementation detail unresolved. The paper names a sweep of values for D, yet gives fixed internal representation sizes in its architecture descriptions without fully specifying the intervening projection or other mechanism linking those sizes to D. The direction of the width association is reported in both architecture fits. A reproduction needs to know where that width is applied to establish which aspects of the learner’s capacity the sweep changed.

Finally, the stated theorem and the experiment use rank in related senses that require care. Reachability and minimality determine which source states yield distinct predictive behavior. The arbitrary offsets permitted by softmax determine which matrix directions affect probabilities. The experiment assigns ranks before normalization and measures the practical consequences of that construction. A lower bound on exact equivalence should concern directions that survive in score differences across reachable states. The association between experimental rank and divergence remains a result about the sampled sources. Exact equality of two string distributions is a stronger condition than achieving low estimated divergence on their typical strings.

What came after

Yang and colleagues’ Anything Goes? cites the paper and takes up a related question at a crosslinguistic scale. Its stated subject is whether language models can learn patterns characterized as possible or impossible across languages. Borenstein and colleagues organize their comparison around measurable properties of known finite-state distributions. The connection is the use of learning behavior to ask what kinds of structure pose difficulty, with the later work framed around linguistic possibility across languages. Anything Goes? A Crosslinguistic Study of (Im)possible Language Learning in LMs

The citation establishes a connection between the studies, and the later title identifies the direction of inquiry. It does not establish that Yang and colleagues adopted the random-automaton generator, its rank manipulation, or the divergence calculation. Those are specific choices in Borenstein and colleagues’ experiment. Their value for the wider learnability question lies in making the generating probabilities available for inspection, so that difficulty can be related to properties of the target distribution as well as to the behavior of the learner.

Cite

Cite as Nadav Borenstein, Anej Svete, Robin Chan, Josef Valvoda, Franz Nowak, Isabelle Augenstein, Eleanor Chodroff and Ryan Cotterell. 2024. What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular Languages. Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2024.acl-long.807

@inproceedings{borenstein2024what,
  title = {{What Languages are Easy to Language-Model? A Perspective from Learning Probabilistic Regular Languages}},
  author = {Nadav Borenstein, Anej Svete, Robin Chan, Josef Valvoda, Franz Nowak, Isabelle Augenstein, Eleanor Chodroff and Ryan Cotterell},
  booktitle = {Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.807},
  url = {https://doi.org/10.18653/v1/2024.acl-long.807}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/borenstein-2024-what-languages-are-easy-language/