[Paper Review] Align on the Fly: Adapting Chatbot Behavior to Established Norms
This paper proposes On-the-fly Preference Optimization (OPO), a real-time alignment method that uses an external memory of legal and moral rules to constrain large language model (LLM) behavior without further training. By retrieving relevant norms from a curated corpus and applying them via prompt engineering, OPO significantly improves LLM performance on law and morality benchmarks, with gains up to 11.2% on A-Professional-Morality and consistent improvements across datasets.
In this paper, we aim to align large language models with the ever-changing, complex, and diverse human values (e.g., social norms) across time and locations. This presents a challenge to existing alignment techniques, such as supervised fine-tuning, which internalize values within model parameters. To overcome this, we propose an On-the-fly Preference Optimization (OPO) method, which is a real-time alignment that works in a streaming way. It employs an external memory to store established rules for alignment, which can constrain LLMs' behaviors without further training, allowing for convenient updates and customization of human values. We also introduce a scalable evaluation to assess the proposed method more effectively. Experimental results on both human-annotated and auto-generated questions from legal and moral domains indicate the effectiveness of the proposed OPO method. Our code and data are released at https://github.com/GAIR-NLP/OPO.
Motivation & Objective
- To address the challenge of aligning LLMs with dynamic, diverse, and context-specific human values such as social norms and legal regulations.
- To overcome limitations of parameter-based alignment methods like SFT and RLHF, which are computationally expensive and inflexible to changing values.
- To develop a scalable, real-time alignment framework that allows for easy updates and customization of human values without fine-tuning.
- To design an evaluation protocol that avoids benchmark leakage and increases coverage of aligned rules through automated test generation.
- To demonstrate that externalized rule retrieval can effectively guide LLM behavior in complex, real-world moral and legal reasoning scenarios.
Proposed method
- The OPO framework uses an external memory storing structured legal and moral rules collected from authoritative sources, serving as a dynamic constraint on LLM outputs.
- For each input query, the system retrieves semantically similar rules using dense vector embeddings and FAISS-based retrieval based on cosine similarity.
- The retrieved rules are injected into the LLM’s prompt as context to guide response generation, ensuring alignment with established norms without model fine-tuning.
- A scalable evaluation module automatically generates multi-choice questions from rules using powerful LLMs and prompts, increasing test coverage and reducing leakage risk.
- The method operates in a streaming, real-time manner, enabling on-the-fly adaptation to new or changing norms.
- The framework separates rule storage, retrieval, and inference, allowing modular updates and customization of values without retraining.

Experimental results
Research questions
- RQ1Can an external rule memory effectively align LLMs with evolving human values in real time without fine-tuning?
- RQ2How does retrieval-based rule application compare to internalized alignment methods like SFT and RLHF in terms of performance and adaptability?
- RQ3To what extent can automated test generation improve the coverage and robustness of alignment evaluation?
- RQ4How does retrieval length affect the performance of OPO in complex reasoning tasks?
- RQ5Can OPO generalize across diverse domains such as law, basic morality, and professional ethics?
Key findings
- OPO significantly improves LLM performance on A-Professional-Morality, with XuanYuan-70B achieving 94.16% accuracy at 1500 context tokens, a 10.7% improvement over the base model.
- On H-Social-Morality, all LLMs show notable performance gains with OPO, indicating its effectiveness in handling complex, context-sensitive social norms.
- Performance peaks at intermediate retrieval lengths (e.g., 1000–1500 tokens), suggesting that longer contexts introduce noise that degrades reasoning.
- Auto-generated questions from rules yield better LLM performance than human-annotated ones on A-Law, implying that GPT-4 can effectively simulate benchmark-quality questions in less complex domains.
- The OPO method consistently outperforms base models across all datasets, with gains ranging from 3.4% to 11.2% depending on the task and model.
- The gap between OPO and oracle rule performance indicates room for improvement in retrieval models, highlighting a key bottleneck in the current pipeline.

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.