Learning Natural Language Constraints for Safe Reinforcement Learning of Language Agents

Jaymari Chua, Chen Wang, Lina Yao
4/4/2025
cs.CLcs.AI

No confident code implementation found for this paper.

Abstract

Generalizable alignment is a core challenge for deploying Large Language Models (LLMs) safely in real-world NLP applications. Current alignment methods, including Reinforcement Learning from Human Feedback (RLHF), often fail to guarantee constraint satisfaction outside their training distribution due to their reliance on implicit, post-hoc preferences. Inspired by a paradigm shift to first curate data before tuning, we introduce a new framework for safe language alignment that learns natural language constraints from positive and negative demonstrations as a primary step. From inferring both a task-specific reward function and latent constraint functions, our approach fosters adaptation to novel safety requirements and robust generalization under domain shifts and adversarial inputs. We formalize the framework within a Constrained Markov Decision Process (CMDP) and validate it via a text-based navigation environment, demonstrating safe adaptation to changing danger zones. Our experiments show fewer violations upon domain shift when following a safe navigation path, and we achieve zero violations by applying learned constraints to a distilled BERT model as a fine-tuning technique. This work offers a promising path toward building safety-critical and more generalizable LLMs for practical NLP settings.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{chua2025learning,
  title  = {Learning Natural Language Constraints for Safe Reinforcement Learning of Language Agents},
  author = {Jaymari Chua and Chen Wang and Lina Yao},
  year   = {2025},
  eprint = {2504.03185},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2504.03185v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2504.03185.svg)](https://codeofpaper.com/paper/2504.03185)

Discussion