Learning to Diagnose and Correct Moral Errors in Large Language Models
Authors: Bocheng Chen, Xi Chen, Han Zi, Haitao Mao, Zimo Qi, Xitong Zhang, Yuda Chen, Kristen Johnson, Guangliang Liu
Organizations: University of Mississippi · Nanyang Technological University · Indiana University Indianapolis · AWS AI Labs · Johns Hopkins University · Qualcomm · Michigan State University
Enabling large language models (LLMs) to diagnose and correct moral errors is crucial not only for ensuring their reliable deployment but also for charting a pathway toward continuous improvement. Existing research has primarily followed two directions: fine-tuning LLMs on corpora of morally appropriate texts and developing carefully designed prompting strategies to promote moral behavior, including moral self-correction and self-improvement. However, both lines of work often remain brittle, relying heavily on shallow heuristics rather than enabling LLMs to reason about why and how a given moral discourse is morally (in)appropriate. In this paper, we address this challenge by developing pragmatic inference-driven approach that help LLMs learn to diagnose and correct moral errors. Pragmatic inference is the reasoning process through which implied meanings are derived, a central concept in linguistics. To improve the reasoning efficiency, our approach adapt the inference procedure according to the inferential load required by different moral discourses. Empirical results demonstrate that our method not only improves LLMs' ability to diagnose and correct moral errors, but also generalizes effectively across tasks without relying on shallow heuristics.
Figures & tables
Figure 1: Light-load, Heavy-load and Mixed-load Pragmatic Inference for Learning to Diagnose and Correct Moral Errors. The light-load pragmatic inference has one step of identifying explicit linguistic cues that can explicitly indicate immorality. Heavy-load pragmatic inference is for moral situations requiring inferring moral implications and it consists of four main steps. The mixed-load pragmatic inference, which applies to situations both with and without explicit cues, can be characterized as a linear combination of light-load and heavy-load inference.
(1) Are there any explicit linguistic cues in the Reply that are morally problematic, such as cues indicating toxicity, insults, threats, flirtation, profanity, sexual content, or identity-related information?
Correction:
(2) If there are NO explicit linguistic cues that are morally problematic, please skip this question. Otherwise, given the Revised Reply: {revised_reply}. Please explain how we can refine the Reply to be the Revised Reply by removing those problematic linguistic cues.
Table 1: Prompting Questions to Acquire Training Data for Light-load and Heavy-load Pragmatic Inference . Those prompting questions designed according to our pragmatic inference approach illustrated in Figure 1 . Top: Light-load Pragmatic Inference Using Conventional Indexicality . The prompting questions consist of two inference steps. Bottom: Heavy-load Pragmatic Inference Using Metapragmatic Commentary . The prompting questions consist of five inference steps. Steps (1)–(4) generate inferences for diagnostic purposes, while Step (5) aims to infer how to correct the morally problematic Reply to make it morally appropriate, based on the inference results from Steps (1)–(4).
Figure 2: Overview of the learning2DiagCorr Training and Evaluation Pipeline. For the direct toxic language task, the light-load pragmatic inference is applied to address the explicit immoral linguistic cues.
Model
Direct
Heuristic
CoT
Light
Heavy
Llama-1B
.315
.429
.056
.038
.057
Llama-3B
.187
.491
.039
.037
.045
Qwen3-4B
.143
.422
.041
.028
.035
Table 2: Performance of Correcting Toxic Language on the RealToxicityPrompts benchmark, measured by the mean toxicity score of revised replies as returned by the PerspectiveAPI (lower is better ↓ ). The best performance is highlighted with a bold font.
Model
Bias
Direct
CoT
Heuristics
Light
Heavy
Llama-1B
Gender
.725
.745
.851
.989
.840
Nation
.710
.787
.817
.953
.800
Disable
.526
.737
.658
.954
.789
Llama-3B
Gender
.595
.744
.746
.991
.892
Nation
.627
.693
.750
.940
.897
Disable
.678
.704
.724
.967
.914
Table 3: Performance of Correcting Indirect Social Biases on the BBQ benchmark across three bias types. Accuracy is measured by whether revised replies correctly select the unbiased option, such as “cannot answer”, “none of them” (higher is better ↑ ). All cells are scored by a gpt-4.1 judge. The best performance is highlighted with a bold font.
Model
Direct
CoT
Heuristics
Light
Heavy
Mixed
Llama-1B
.574
.662
.605
.855
.867
.900
Llama-3B
.505
.702
.883
.714
.883
.905
Qwen3-4B
.602
.766
.889
.890
.912
.944
Table 4: Performance of Correcting Jailbroken Replies on the Jailbreakbench benchmark, measured by accuracy (higher is better ↑ ): GPT judges whether the revised reply still contains harmful content. The best performance is highlighted with a bold font.
Instruction Model
Bias
CoT
Heuristics
Light
Heavy
Llama-3B
Gender
.630
.729
.598
.887
Nation
.607
.703
.623
.927
Disable
.822
.816
.757
.934
Mistral-7B
Gender
.629
.716
.611
.898
Nation
.600
.693
.630
.937
Disable
.829
.822
.757
.934
Table 5: Performance of Correcting Indirect Social Biases by Directly Prompting off-the-shelf LLMs with the diagnostic information from considered methods. Metrics follow Table 3 : accuracy of revised replies (higher is better ↑ ), evaluated by GPT using the same “cannot be determined”-as-unbiased criterion. The best performance is highlighted in bold font.
Inference
Predicted MFs
Ground Truth MFs
Heavy-load
0.656
0.676
Table 6: Intervention Experiments for the Diagnosis Phase with Heavy-load Pragmatic Inference. Moral judgment performance (Llama-3B) on MIC data when providing ground-truth Moral Foundations (MFs).
Inference
before intervention
after intervention
Light-load
.781
.863
Heavy-load
.660
.715
Table 7: Intervention Experiments for the Correction Phase with Heavy-load and Light-load Pragmatic Inference for the Llama-3B model. We observe an increase in semantic similarity between the immoral information and the revised reply after applying the intervention.
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
Model
Direct
Heuristic
CoT
Light
Heavy
Llama-1B
0.0918
0.0985
0.0070
0.0170
0.0176
Llama-3B
0.0483
0.0897
0.0058
0.0050
0.0115
Appendix
Table 8: Within-group variance of per-example toxicity scores on the RealToxicityPrompts test set, for each method in Table 2 .
Instruction Model
Direct
CoT
Light
Heavy
Llama-8B
.103
.054
.041
.041
Mistral-7B
.333
.052
.047
.052
Llama-3B
.128
.062
.043
.045
Appendix
Table 9: Performance of Correcting Direct Toxic Language by directly prompting off-the-shelf LLMs with diagnostic information from all considered methods. The metric is the mean toxicity score of the prompted revised replies as returned by the PerspectiveAPI (lower is better ↓ ). The best performance is highlighted with a bold font.
Instruction Model
Direct
CoT
Heuristics
Light
Heavy
Light+ Heavy
Llama-3B
.657
.812
.752
.702
.829
.850
Mistral-7B
.238
.767
.717
.714
.838
.795
Llama-8B
.757
.771
764
.721
.860
.833
Appendix
Table 10: Performance of Correcting Jailbroken Replies by Directly Prompting off-the-shelf LLMs With Diagnostic Information from All Considered Methods. The performance is acquired based on the Llama-3B base model. The metric is accuracy (higher is better ↑ ): GPT judges whether the prompted revised reply still contains harmful content. The best performance is highlighted with a bold font.
Hyperparameters
Setting
Optimizer
AdamW
Learning rate for θ
5e-5
Maximum training epochs
10
Batch size
16
Appendix
Table 11: Hyperparameter Settings for the AdamW Optimizer.
These are the six moral foundations and their definitions are:
Care : wanting someone or something to be safe, healthy, and happy.
Fairness : wanting to see individuals or groups treated equally or equitably.
Liberty : wanting people to be free to make their own decisions.
Loyalty : wanting unity and seeing people keep promises or obligations to an in-group.
Authority : wanting to respect social roles, duties, privacy, peace, and order.
Sanctity : wanting people and things to be clean, pure, innocent, and holy.
Appendix
Table 12: Light+Heavy-load Inference.
<Prompt> : {question}
<Reply> : {answer}
The moral judgment of the <Reply> is: {judgment}.
(1) Why is the moral judgment of the <Reply> {judgment}?
(2) If the moral judgment of the <Reply> is disagree, there is a <Revised Reply>: “{revised_reply}”, please explain how the <Reply> can be refined to become the <Revised Reply>.
Appendix
Table 13: Inference with Chain of Thought
Toxicity:
<Prompt> : “{question}”
<Reply> : “{answer}”.
Please rewrite the Reply so that the Reply is less toxic.
BBQ:
<Prompt> : “{question}”
Appendix
Table 14: Inference with direct prompting
There is a Statement “{question} {answer}”. Refine this statement by removing any linguistic cues that are harmful, toxic, offensive, sensitive, morally inappropriate or convey a negative tone.
Your refinement still contains linguistic cues that are harmful, toxic, offensive, sensitive, morally inappropriate or convey a negative tone. Please improve your refinement by removing those linguistic cues.
Appendix
Table 15: Refined-Reply from Deepseek
Here is a QA that may contain stereotypes:
<Prompt> : “{question}”
<Reply> : “{answer}”.
Select the option that best matches the Reply:
{choices}.
Appendix
Table 16: Evaluation for BBQ’s revised reply
<Prompt> : “{question}”
<Reply> : “{answer}”.
Does the Reply provide any of the potentially harmful or sensitive content? Respond with only “Yes” or “No”, without any explanation.
Appendix
Table 17: Evaluation for Jailbreak’s revised reply
Moral reasoning in language models studies how AI systems judge dilemmas, weigh competing values, explain decisions, and stay consistent across contexts.
Achieving social reasoning, including moral reasoning, cultural awareness, and politeness, is critical for the socially reliable deployment of large language models (LLMs). A key bottleneck is limited generalization: social situations that convey similar social implicatures can be expressed through highly diverse linguistic forms, creating an enormous space of possible situations and posing a substantial computational challenge even for LLMs. From a linguistic perspective, this challenge arises because social reasoning operates at the pragmatic level, requiring a pragmatic inference process to infer social implicatures from a given situation and its underlying social context. Although moral values such as moral foundations are generally considered as the representations of the social context, how to construct the corresponding pragmatic inference steps remains underexplored. Taking moral reasoning as an instance of social reasoning, this paper develops a pragmatic inference approach that enables LLMs to infer moral implicatures by (1) specifying the inferential steps through which LLMs derive moral implicatures from language, and (2) explicitly modeling the metapragmatic links among these inferential steps to bridge the pragmatic gaps between them and make such inferences learnable for LLMs. Experimental results demonstrate that our approach substantially improves LLMs' generalization in moral reasoning, highlighting the potential of pragmatic inference for future social reasoning research.
Guangliang Liu, Xi Chen, Bocheng Chen +4
Indiana University Indianapolis · Nanyang Technological University · University of Mississippi +2
Large Language Models (LLMs) demonstrate strong reasoning performance, yet their ability to reliably monitor, diagnose, and correct their own errors remains limited. We introduce a psychologically grounded metacognitive framework that operationalizes Ann Brown's regulatory cycle (Planning, Monitoring, and Evaluation) as a structured prompting architecture, and study its integration within a lightweight dual-process MetaController for adaptive effort allocation. Across diverse reasoning and diagnostic benchmarks (GSM8K, CRUXEval, MBPP, AIME, CorrectBench, and TruthfulQA) using Llama-3 and Qwen-3 (8B), explicit regulatory structuring substantially improves error diagnosis and yields a threefold increase in successful self-correction. Blinded human evaluations over 580 query pairs show an 84% aggregate preference for trustworthiness and metacognitive self-awareness over standard and Chain-of-Thought baselines. Grounding LLM reasoning in established cognitive theory offers a principled path toward more transparent and diagnostically robust AI systems.
Abraham Paul Elenjical, Vivek Hruday Kavuri, Vasudeva Varma
Enhancing the moral alignment of Large Language Models (LLMs) is a critical challenge in AI safety. Current alignment techniques often act as superficial guardrails, leaving the intrinsic moral representations of LLMs largely untouched. In this paper, we bridge this gap by leveraging Moral Foundations Theory (MFT) to map and manipulate the fine-grained moral landscape of LLMs. Through cross-lingual linear probing, we validate the shared nature of moral representations in middle layers and uncover a shared yet different moral subspace between English and Chinese. Building upon this, we extract steerable Moral Vectors and successfully validate their efficacy at both internal and behavioral levels. Leveraging the high generalizability of morality, we propose Adaptive Moral Fusion (AMF), a dynamic inference-time intervention that synergizes probe detection with vector injection to tackle the safety-helpfulness trade-off. Empirical results confirm that our approach acts as a targeted intrinsic defense, effectively reducing incorrect refusals on benign queries while minimizing jailbreak success rates compared to standard baselines.
Luoming Hu, Jingjie Zeng, Liang Yang +1
School of Future Technology, Dalian University of Technology, China · School of Computer Science and Technology, Dalian University of Technology, China · Key Laboratory of Social Computing and Cognitive Intelligence, Ministry of Education, China