[Paper Review] Neuro-Symbolic Language Modeling with Automaton-augmented Retrieval
This paper introduces RETOMATON, a neuro-symbolic framework that accelerates retrieval-based language modeling by constructing a weighted finite automaton from a datastore using unsupervised clustering and inter-entry pointers. By traversing this automaton during inference, RETOMATON reduces kNN search frequency by up to 83% while maintaining or improving perplexity, offering a scalable, training-free alternative to kNN-LM with strong gains in efficiency and domain adaptation.
Retrieval-based language models (R-LM) model the probability of natural language text by combining a standard language model (LM) with examples retrieved from an external datastore at test time. While effective, a major bottleneck of using these models in practice is the computationally costly datastore search, which can be performed as frequently as every time step. In this paper, we present RetoMaton - retrieval automaton - which approximates the datastore search, based on (1) saving pointers between consecutive datastore entries, and (2) clustering of entries into "states". This effectively results in a weighted finite automaton built on top of the datastore, instead of representing the datastore as a flat list. The creation of the automaton is unsupervised, and a RetoMaton can be constructed from any text collection: either the original training corpus or from another domain. Traversing this automaton at inference time, in parallel to the LM inference, reduces its perplexity by up to 1.85, or alternatively saves up to 83% of the nearest neighbor searches over $k$NN-LM (Khandelwal et al., 2020) without hurting perplexity. Our code and trained models are available at https://github.com/neulab/retomaton .
Motivation & Objective
- Address the high inference cost of retrieval-based language models (R-LMs), which require expensive kNN searches at every generation step.
- Reduce reliance on repeated, computationally heavy nearest-neighbor searches during inference without retraining the base language model.
- Enable efficient, scalable retrieval in both in-domain and out-of-domain settings through unsupervised construction of a symbolic automaton over the datastore.
- Explore the synergy between neural language models and symbolic automata to improve inference efficiency and model interpretability.
Proposed method
- Construct a weighted finite automaton (WFA) on top of an external datastore using unsupervised clustering of datastore entries based on their hidden representations.
- Encode each datastore entry as a 3-tuple: (key = LM hidden state, value = target token, pointer = next entry in the corpus).
- Use inter-entry pointers to form state transitions in the automaton, enabling path traversal that approximates future kNN results.
- At inference, perform kNN search only sporadically and traverse the automaton in parallel to predict tokens, reducing search frequency.
- Leverage both clustering (for state abstraction) and pointer propagation (for temporal continuity) to guide automaton traversal.
- Integrate the automaton’s output with the base language model via interpolation, maintaining model accuracy while reducing search overhead.
Experimental results
Research questions
- RQ1Can we reduce the frequency of kNN searches in retrieval-based language models without sacrificing performance?
- RQ2To what extent can unsupervised clustering and pointer-based transitions in a weighted finite automaton approximate the results of kNN retrieval?
- RQ3How does the proposed automaton-based retrieval compare to kNN-LM in terms of perplexity and inference efficiency?
- RQ4Can RETOMATON be effectively applied to domain adaptation tasks without retraining the base model?
- RQ5What is the relative contribution of clustering versus pointer propagation in the automaton’s performance?
Key findings
- RETOMATON reduces kNN search frequency by up to 83% in the WIKITEXT-103 benchmark while maintaining the same perplexity as kNN-LM.
- When used without search reduction, RETOMATON improves perplexity by 1.85 absolute points over kNN-LM on WIKITEXT-103 using only the original training data.
- Constructing a RETOMATON on a fine-tuned language model leads to a 17% or greater perplexity reduction compared to fine-tuning alone, demonstrating strong domain adaptation capability.
- Ablation studies show that both clustering and pointer propagation contribute significantly to performance, with coarse-grained clustering offering better efficiency and fine-grained clustering yielding higher accuracy.
- The method is completely unsupervised and does not require additional training data or model fine-tuning, making it highly data-efficient.
- The approach generalizes to other retrieval-based models and is publicly released with code, data, and trained models.
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.