Command Palette
Search for a command to run...
CantTalkAboutThis: Aligning Language Models to Stay on Topic in Dialogues
CantTalkAboutThis: Aligning Language Models to Stay on Topic in Dialogues
Makesh Sreedhar Traian Rebedea Shaona Ghosh Jiaqi Zeng Christopher Parisien
CantTalkAboutThis Topic Control
Abstract
Recent advancements in instruction-tuning datasets have predominantly focused on specific tasks like mathematical or logical reasoning. There has been a notable gap in data designed for aligning language models to maintain topic relevance in conversations - a critical aspect for deploying chatbots to production. We introduce the CANTTALKABOUT-THIS dataset to help language models remain focused on the subject at hand during taskoriented interactions. It consists of synthetic dialogues on a wide range of conversation topics from different domains. These dialogues are interspersed with distractor turns that intentionally divert the chatbot from the predefined topic. Fine-tuning language models on this dataset helps make them resilient to deviating from the assigned role and improves their ability to maintain topical coherence compared to generalpurpose instruction-tuned LLMs like GPT-4-TURBO and MIXTRAL-INSTRUCT. Additionally, preliminary observations suggest that training models on this dataset also enhance their performance on fine-grained instruction following tasks, including safety alignment.
One-sentence Summary
NVIDIA researchers introduce the CANTTALKABOUT-THIS dataset of synthetic task-oriented dialogues with distractor turns, fine-tuning on which makes language models resilient to topic deviation and improves topical coherence over general-purpose LLMs like GPT-4-TURBO and MIXTRAL-INSTRUCT, with preliminary gains in fine-grained instruction following and safety alignment as well.
Key Contributions
-
The paper introduces topic-following as a fundamental instruction-tuning task and contributes the CANTTALKABOUT-THIS dataset, which combines synthetic on-topic dialogues from diverse domains with deliberate distractor turns that derail the chatbot. The dataset is generated through dialogue inpainting, and multiple versions are released, including one suitable for commercial use.
-
Fine-tuning language models on this dataset makes them resilient to off-topic deviations, and evaluations on a small human-annotated distractor set show that the resulting models outperform strong instruction-tuned baselines such as GPT-4-TURBO and MIXTRAL-INSTRUCT at maintaining topical coherence in task-oriented interactions.
-
The work shows that topic-following training also improves the model's overall instruction-following ability and enables zero-shot safety alignment with effectiveness comparable to LLAMAGUARD, based on preliminary observations.
Introduction
Instruction tuning is central to aligning large language models (LLMs) with human expectations, but existing alignment methods focus largely on safety, such as avoiding toxic or biased outputs. This leaves a gap: models struggle to follow user-defined topical constraints, especially in extended dialogues. The authors introduce the concept of "topic-following," a form of instruction tuning combined with moderation where the model learns when to respond and when to steer conversation back or refuse off-topic requests. Unlike prior approaches like NeMo Guardrails that rely on domain-specific languages, topic-following uses natural language instructions, making it more accessible. To enable this, they build CANTTALKABOUTTHIS, a small synthetic dataset of 1,080 dialogues using a three-step prompting approach with dialogue inpainting and injected distractors. While fine-tuning on this data significantly improves models’ ability to stay on topic and enhances overall instruction following, the synthetic distractors are often simplistic. They address this with a human-crafted distractor benchmark for more rigorous evaluation. The authors also show that topic-following training yields zero-shot safety alignment performance comparable to LLAMAGUARD, offering a dual benefit: better complex instruction adherence and improved helpfulness.
Dataset
Dataset Description: CANTTALKABOUTTHIS
The authors introduce CANTTALKABOUTTHIS, a dataset designed to improve the ability of LLMs and LLM-powered chatbots to maintain topical focus during interactions. The dataset construction pipeline involves generating scenarios, creating system instructions, producing on-topic dialogues, and incorporating off-topic user turns called distractors.
Composition and Sources
- The dataset covers nine domains: health, banking, insurance, travel, taxes, legal, education, computer troubleshooting, and real estate.
- It is generated using two LLM backbones: OpenAI gpt-4-turbo-1106 and Mixtral-Instruct 8x7B. Using two different LLMs allows the authors to compare model bias toward distractors, demonstrate that smaller open models can produce high-quality data, and ensure the Mixtral-generated subset is commercially usable.
Scenario Design
- For each domain, the authors prompt an LLM in a few-shot setting to generate 10 relevant scenarios. To prevent repetition, previously generated scenarios are included in subsequent prompts.
- Generated scenarios are filtered for diversity using two criteria on all scenario pairs: a lexical similarity threshold (ROUGE-L F-measure lower than 0.7) and a semantic similarity threshold (MiniLM cosine score lower than 0.9). Pairs flagged as similar are manually evaluated and discarded if deemed too alike. The thresholds were chosen empirically.
Conversation Generation and Scale
- The primary LLM for scenario and instruction creation is gpt-4-turbo-1106, which generates 60 scenarios for each of the nine domains. The filtering metrics show high diversity, with less than 2% of pairs flagged as similar.
- For each scenario, only two conversations are generated, resulting in a dataset of 1080 dialogues total.
- A manual review of 100 randomly selected samples confirms that conversations from both LLMs are high quality, stay on-topic, and align with the system instructions.
Incorporating Distractors
- Distractors are user utterances designed to divert the conversation from its intended course or operational scope.
- To generate them, the authors prompt an LLM with the topical instruction and the generated on-topic conversation, asking it to produce a user utterance that is off-topic and to specify a bot turn after which the distractor should be inserted. Five distractors are created for each conversation.
- A manual review found that gpt-4-turbo generates more appropriate distractors than Mixtral-Instruct, which often produced false positives (on-topic turns incorrectly labeled as distractors). To fix this, the authors use a model trained on GPT-4 generated distractors to filter out such false positives, significantly reducing noise in the Mixtral dataset.
Data Usage
- The dataset is designed to train chatbots to recognize and avoid off-topic engagement, with the distractors serving as test cases that the model should refuse to engage with.
Method
The authors present a data-centric approach to improving the topic‑following ability of large language models (LLMs) and their chatbot applications. The method encompasses the construction of a high‑quality alignment dataset, CANTTALKABOUTTHIS, and the subsequent fine‑tuning of base models to create topic‑adherent chatbots. The pipeline is composed of five sequential stages: scenario design, topical system instruction creation, on‑topic conversation generation, distractor incorporation, and alignment dataset curation.
Scenario Design The process begins with generating realistic, task‑oriented scenarios across nine domains: health, banking, insurance, travel, taxes, legal, education, computer troubleshooting, and real estate. For each domain, an LLM is prompted in a few‑shot manner to produce ten scenarios simultaneously. To enhance diversity and avoid repetition, previously generated scenarios are appended to subsequent prompts. The generated scenarios undergo a filtering step where a Cartesian product of scenario pairs is evaluated using two similarity metrics: lexical similarity measured by ROUGE‑L F‑measure and semantic similarity computed via a MiniLM cosine score. Pairs with a ROUGE‑L below 0.7 and a cosine score below 0.9 are flagged for manual review, and any redundant scenarios are discarded. These thresholds were determined empirically.
Crafting Topical System Instructions For each accepted scenario, the authors prompt the LLM to generate detailed system instructions that define the expected dialogue flow. These instructions explicitly specify allowed discussion topics, prohibited content, and directives for handling edge cases. The resulting topical instructions serve as the binding constraint for the subsequent conversation generation, ensuring that the interaction remains within the scope of the intended task.
Constructing On‑topic Conversations Two approaches are explored to generate conversations that adhere to the topical instructions. The first uses a dual‑agent simulation built on Autogen, where separate LLM agents role‑play the user and the chatbot, receiving the system instruction and mimicking a natural exchange. The second approach relies on a single LLM call that produces the entire dialogue in one generation pass. Manual evaluation of samples from both strategies reveals comparable quality; consequently, the single‑call method is chosen for its simplicity and reduced orchestration overhead.
Incorporating Distractors To train a chatbot to avoid off‑topic engagement, the authors generate distractor utterances that are designed to divert the conversation from its intended course. An LLM is provided with the topical instruction and the generated on‑topic conversation, and is asked to produce a user utterance that is clearly unrelated to the scenario. The LLM also selects a specific bot turn after which this distractor should be placed. For each conversation, five such distractors are created, yielding a balanced set of positive (on‑topic) and negative (off‑topic) examples.
Alignment Dataset Curation The final stage compiles training samples suitable for alignment. A standard conversation in the dataset is an alternating sequence of user and agent turns, denoted as [u1,a1,…,un,an]. Each distractor utterance is inserted into this sequence immediately after its designated agent turn ai. The chatbot’s response to a distractor is initialized to a fixed template refusal: “I am sorry! I can only answer questions related to the scenario.” This template teaches the model to gracefully decline to engage with off‑topic requests. As an ablation, the authors also explore replacing the template with more natural mitigations, but the default approach uses the template.
Model Alignment Training The curated dataset is then used to fine‑tune two base models. The first is an in‑house 43B‑parameter decoder‑only GPT architecture trained on 1.1 trillion tokens, with 48 layers, a vocabulary of 256k, RoPE positional embeddings, and SwiGLU activation. This model is initially aligned with general‑purpose instruction data. Using LoRA (low‑rank adaptation) with a batch size of 128, adapter dimension of 32, and a learning rate of 1e‑4, the authors train it for 5 epochs with early stopping, yielding the STAY‑ON‑TOPIC‑43B model. A second, more accessible model is produced by applying the same LoRA‑based fine‑tuning procedure to LLAMA3‑8B, using a batch size of 4, adapter dimension of 32, and a learning rate of 1e‑4 for 5 epochs, resulting in STAY‑ON‑TOPIC‑8B. This smaller model is open‑sourced to facilitate community adoption.
The entire pipeline is designed to systematically create a diverse and challenging set of scenarios, generate coherent on‑topic dialogues, and inject realistic off‑topic distractions. The resulting alignment dataset, when used in fine‑tuning, effectively teaches models to recognize and reject unsolicited divergences, thereby maintaining topical focus during real‑world interactions.
Experiment
The evaluation setup splits train and test sets by domain to prevent overfitting, using travel for validation and banking for testing, plus a smaller human-annotated test set with distractors. Results show that fine-tuning with LoRA on the CANTTALKABOUTTHIS dataset substantially improves topic-following and distractor rejection for both 43B and 8B models, outperforming general-purpose LLMs on unseen domains, though all models struggle more with human-annotated distractors that involve subtle topic shifts. Additional analyses reveal that human distractors are more evenly distributed across rule types and exhibit higher similarity to preceding turns, making them harder to detect. Out-of-domain evaluations demonstrate that the tuned model gains helpfulness, competes with LLAMAGUARD in content moderation, and significantly improves rule-following on the RuLES benchmark, indicating broad benefits beyond the original task.
The synthetic topic-following evaluation shows that fine-tuning a base model on domain-specific data yields a large advantage over general-purpose LLMs, achieving near-perfect accuracy on both identifying distractors and responding to relevant turns. In contrast, untuned models exhibit weak performance, particularly in recall for on-topic responses, while GPT-3.5 and GPT-4 provide intermediate results. Fine-tuned STAY-ON-TOPIC-43B achieves the best results across all metrics, with near-perfect F1 scores for both on-topic and distractor detection. Among general-purpose LLMs, GPT-3.5-TURBO and GPT-4-TURBO show decent but inferior performance compared to the fine-tuned model. Untuned models like 43B-ALIGNED and MIXTRAL-INSTRUCT have notably low recall on on-topic turns, indicating difficulty in staying focused when distractors are present.
On the topic-following task with human-annotated distractors, general-purpose LLMs show moderate precision but low recall, indicating difficulty in detecting subtle off-topic turns. Fine-tuned models like STAY-ON-TOPIC-43B and 8B outperform all baselines by a large margin, though all models exhibit reduced effectiveness compared to synthetic distractors, highlighting the increased challenge of human-crafted distractors. GPT-4-TURBO achieves the best overall distractor F1 among general-purpose LLMs, driven by high precision but limited recall. Fine-tuned STAY-ON-TOPIC models substantially outperform all baselines on the human-annotated distractor set. Human-annotated distractors are more challenging than synthetic ones, causing a notable performance drop across all models.
The distribution of topical rules is heavily skewed toward conversation flow, which accounts for the majority of rules, while topic/subject allowed and conversation tone/style each make up roughly a quarter of the remaining share. Topic/subject disallowed rules are extremely rare, suggesting that the system's rule-based mechanisms prioritize maintaining natural conversational dynamics over enforcing strict topic boundaries. Conversation flow rules dominate the rule type distribution, being more than twice as common as the next highest category. Topic/subject disallowed rules are nearly negligible, making up only a small fraction of all rules.
Synthetic distractors predominantly violate the allowed topic category, making them relatively easy to detect, while human distractors are more evenly spread across all rule types, presenting a more challenging scenario. This distribution difference highlights the increased difficulty of identifying subtle topic shifts in human-generated distractors. Synthetic distractors heavily favor the allowed topic rule type at about two-thirds, whereas human distractors are more balanced across categories. Human distractors show notably higher proportions of disallowed topic and tone violations compared to synthetic ones, roughly quadrupling and more than quintupling respectively. Conversation flow violations remain similar across both datasets, while the synthetic set underrepresents tone and disallowed topic violations.
Across both synthetic and human-annotated topic-following evaluations, fine-tuned domain-specific models consistently outperform general-purpose LLMs, achieving near-perfect accuracy on synthetic distractors and substantial gains on the more challenging human-crafted ones, while untuned models struggle with toppic adherence. Human distractors, which are more evenly distributed across rule types, prove harder than synthetic ones, which predominantly violate allowed-topic rules, and this difficulty is reflected in all models' performance drops. The rule distribution further shows a heavy reliance on conversation flow rules, with disallowed-topic violations rarely used, underscoring that maintaining natural interaction dynamics is prioritized over strict topic constraints.