DFA-RAG: Conversational Semantic Router for Large Language Model with Definite Finite Automaton
Yiyou Sun, Junjie Hu, Wei Cheng, Haifeng Chen
TL;DR
DFA-RAG tackles regulated LLM dialogue by embedding a learnable Definite Finite Automaton (DFA) as a semantic router. The DFA is defined as $(Q,\Sigma,\delta,q_0,F)$ and is learned from training dialogues by extracting tag sequences and building a tag-based DFA with state-tracking function $\\mathcal{I}(q)$; similar states are merged using the similarity score $\\phi_{sim}(q,q')$ with threshold $\\lambda$. Retrieval-augmented generation then couples this DFA with context-aware sample retrieval to guide responses, yielding interpretable, domain-specific dialogue with improved win-rates over baselines. Experiments on diverse datasets including MultiWOZ show high Inform and Success scores (e.g., Inform ≈ 93.3, Success ≈ 90.0) and strong generation quality, supporting the practical utility of plug-and-play DFA routing for trustworthy AI assistants.
Abstract
This paper introduces the retrieval-augmented large language model with Definite Finite Automaton (DFA-RAG), a novel framework designed to enhance the capabilities of conversational agents using large language models (LLMs). Traditional LLMs face challenges in generating regulated and compliant responses in special scenarios with predetermined response guidelines, like emotional support and customer service. Our framework addresses these challenges by embedding a Definite Finite Automaton (DFA), learned from training dialogues, within the LLM. This structured approach acts as a semantic router which enables the LLM to adhere to a deterministic response pathway. The routing is achieved by the retrieval-augmentation generation (RAG) strategy, which carefully selects dialogue examples aligned with the current conversational context. The advantages of DFA-RAG include an interpretable structure through human-readable DFA, context-aware retrieval for responses in conversations, and plug-and-play compatibility with existing LLMs. Extensive benchmarks validate DFA-RAG's effectiveness, indicating its potential as a valuable contribution to the conversational agent.
