[Paper Review] Backward and Forward Language Modeling for Constrained Sentence Generation
This paper proposes a backward and forward (B/F) language model that generates sentences containing a specified target word by independently modeling past and future words relative to the target. Using either synchronous or asynchronous RNNs, the model achieves generation quality comparable to standard sequential language models while guaranteeing the target word appears at any desired position.
Recent language models, especially those based on recurrent neural networks (RNNs), make it possible to generate natural language from a learned probability. Language generation has wide applications including machine translation, summarization, question answering, conversation systems, etc. Existing methods typically learn a joint probability of words conditioned on additional information, which is (either statically or dynamically) fed to RNN's hidden layer. In many applications, we are likely to impose hard constraints on the generated texts, i.e., a particular word must appear in the sentence. Unfortunately, existing approaches could not solve this problem. In this paper, we propose a novel backward and forward language model. Provided a specific word, we use RNNs to generate previous words and future words, either simultaneously or asynchronously, resulting in two model variants. In this way, the given word could appear at any position in the sentence. Experimental results show that the generated texts are comparable to sequential LMs in quality.
Motivation & Objective
- Address the challenge of generating natural language sentences that must include a specific, hard-constrained word.
- Overcome limitations of existing language models, which fail to guarantee the presence of a required word despite conditioning on additional information.
- Develop a method that generates fluent, coherent sentences with the target word at any position, not just the beginning.
- Ensure the model maintains generation quality comparable to standard sequential language models while enforcing constraints.
Proposed method
- Propose a backward and forward (B/F) language model that splits the sentence generation process around a given target word.
- Use two RNNs: one to generate words before the target (backward) and one to generate words after (forward), conditioned on the target word.
- Implement two variants: synchronous B/F (syn-B/F), where both RNNs generate in parallel, and asynchronous B/F (asyn-B/F), where generation proceeds sequentially.
- Condition both backward and forward RNNs on the embedding of the target word to ensure its inclusion in the final sentence.
- Train the model to maximize the likelihood of the full sentence, with the target word fixed at a given position.
- Use a joint probability decomposition: p(w₁,…,wₜ₋₁, wₜ, wₜ₊₁,…,wₘ) = p(w₁,…,wₜ₋₁|wₜ) × p(wₜ) × p(wₜ₊₁,…,wₘ|wₜ), where wₜ is the constrained word.
Experimental results
Research questions
- RQ1Can a language model be designed to guarantee the inclusion of a specific target word in generated sentences, regardless of its position?
- RQ2How does the performance of B/F language models compare to standard sequential language models in terms of fluency and perplexity?
- RQ3Does asynchronous generation (asyn-B/F) yield better sentence quality than synchronous or separate generation (sep-B/F) in constrained generation tasks?
- RQ4To what extent does random word splitting affect perplexity, and how does the model handle position-agnostic constraints?
Key findings
- The proposed B/F language model successfully generates sentences containing the target word at any position, overcoming a key limitation of standard language models.
- Perplexity of B/F models is comparable to sequential LMs when the target word is fixed (perplexity < 100), indicating strong modeling capability under constraints.
- Asynchronous B/F (asyn-B/F) produces higher-quality sentences than separate or synchronous variants, achieving fluency and coherence on par with sequential LMs.
- For later positions in sentences (t ≥ 4), B/F models achieve perplexity nearly identical to sequential LMs, indicating strong long-range modeling behavior.
- The model outperforms baselines in generating grammatically correct and topic-relevant sentences for constrained words like 'systems' or 'models', which sequential LMs often fail to include.
- Random word splitting increases perplexity due to uncertainty, but this effect is mitigated when the target word is known in advance (oracle setting).
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.