Official Research Code for META-IR
Meta-Introspective Reasoning for Adaptive Safety Alignment in Large Language Models
Caution
META-IR is a meta-introspective reasoning framework designed to improve the safety alignment, reasoning stability, and adaptive robustness of Large Language Models (LLMs) against evolving jailbreak attacks.
Existing safety alignment approaches often rely on relatively static safety policies and fixed evaluation mechanisms. Consequently, aligned language models may remain vulnerable to adversarial distribution shifts, role-play manipulation, forced-prefix attacks, and disguised harmful intentions.
META-IR addresses these limitations through a dual-loop architecture that integrates structured introspective reasoning, Safety-Informed Monte Carlo Tree Search (SI-MCTS), composite reward optimization, and meta-learning across diverse jailbreak task families.
Rather than relying exclusively on static refusal behavior, META-IR enables models to examine potential risks, refine intermediate reasoning trajectories, and adapt their introspection policies to previously unseen adversarial patterns.
This repository provides the research-oriented source code and implementation resources for the META-IR framework.
2026 IEEE International Conference on Multimedia & Expo (ICME 2026)
- Conference: IEEE ICME 2026
- Location: Bangkok, Thailand
- Paper: META-IR: Meta-Introspective Reasoning for Adaptive Safety Alignment in LLM
- Publication Status: Accepted
META-IR introduces four principal research contributions:
A structured reasoning mechanism that enables LLMs to progressively assess user intent, identify potential safety risks, evaluate policy conflicts, and produce policy-consistent responses.
A safety-aware search mechanism that explores alternative introspective reasoning trajectories, evaluates candidate paths, and prunes unsafe or policy-violating branches.
An adversarial simulation mechanism that exposes the framework to progressively challenging jailbreak prompts and diverse attack strategies.
A meta-learning mechanism that adapts the introspection policy across different jailbreak task families to improve generalization to previously unseen adversarial patterns.
META-IR integrates structured introspection, safety-informed search, reward optimization, and meta-learning into a unified adaptive safety alignment framework.
The architecture consists of the following major components:
The model generates a structured introspective trajectory:
where:
-
$s_i$ : An individual introspective reasoning step. -
$n$ : Number of reasoning steps. -
$f$ : Final model response.
The structured representation supports progressive risk assessment and evaluation of reasoning quality.
SI-MCTS explores alternative introspective reasoning trajectories and evaluates their safety and usefulness.
Candidate trajectories are evaluated using a composite reward:
where:
-
$H$ : Helpfulness. -
$S$ : Safety. -
$I$ : Introspection quality. -
$F(S)$ : Safety-dependent modulation function. -
$\lambda$ : Introspection reward coefficient.
Unsafe or policy-violating reasoning branches are pruned during the search process.
The framework considers diverse adversarial task families, including:
- Role-play framing.
- Forced-prefix injection.
- Disguised harmful intent.
- Narrative camouflage.
- Constrained-output attacks.
These task families support adaptive evaluation and meta-learning.
META-IR separates trajectory refinement from cross-task policy adaptation.
Inner Loop:
- Generates structured introspective trajectories.
- Performs safety-informed search.
- Evaluates helpfulness, safety, and introspection quality.
- Refines candidate reasoning trajectories.
Outer Loop:
- Samples different jailbreak task families.
- Aggregates task-level rewards.
- Updates the introspection policy.
- Improves generalization across adversarial distributions.
The meta-learning objective is:
where:
-
$\theta_r$ : Introspection policy parameters. -
$\mathcal{T}$ : Distribution of jailbreak task families. -
$\tau$ : A sampled jailbreak task. -
$H_\tau$ : Helpfulness score for task$\tau$ . -
$S_\tau$ : Safety score for task$\tau$ . -
$I_\tau$ : Introspection quality score for task$\tau$ .
The dual-loop mechanism enables META-IR to refine introspective reasoning trajectories while adapting its introspection policy across diverse jailbreak task families.
| Feature | Description |
|---|---|
| Structured Introspection | Progressive safety and intent analysis |
| SI-MCTS | Safety-aware reasoning trajectory search |
| Composite Reward | Joint helpfulness, safety, and introspection evaluation |
| Jailbreak Simulation | Evaluation across diverse adversarial strategies |
| Meta-Learning | Adaptation across jailbreak task families |
| Adaptive Safety Alignment | Improved robustness under adversarial distribution shifts |
| Evaluation Framework | Safety, helpfulness, introspection, and generalization evaluation |
The repository is organized into modular components to support implementation, experimentation, evaluation, and future research extensions.
Meta-IR/
│
├── README.md
├── LICENSE
├── NOTICE.md
├── CITATION.cff
├── requirements.txt
├── pyproject.toml
├── .gitignore
│
├── configs/
│ ├── model_config.yaml
│ ├── training_config.yaml
│ ├── search_config.yaml
│ └── evaluation_config.yaml
│
├── src/
│ └── meta_ir/
│ ├── __init__.py
│ │
│ ├── reasoning/
│ │ ├── __init__.py
│ │ └── introspection.py
│ │
│ ├── si_mcts/
│ │ ├── __init__.py
│ │ ├── search.py
│ │ ├── node.py
│ │ └── pruning.py
│ │
│ ├── rewards/
│ │ ├── __init__.py
│ │ └── reward_model.py
│ │
│ ├── jailbreak/
│ │ ├── __init__.py
│ │ └── simulation.py
│ │
│ ├── meta_learning/
│ │ ├── __init__.py
│ │ ├── inner_loop.py
│ │ └── outer_loop.py
│ │
│ ├── generation/
│ │ ├── __init__.py
│ │ └── adaptive_generation.py
│ │
│ └── evaluation/
│ ├── __init__.py
│ ├── safety.py
│ ├── helpfulness.py
│ └── introspection.py
│
├── scripts/
│ ├── train.py
│ ├── evaluate.py
│ └── run_inference.py
│
├── examples/
│ └── basic_inference.py
│
├── tests/
│ ├── test_reasoning.py
│ ├── test_si_mcts.py
│ └── test_rewards.py
│
├── docs/
│ ├── architecture.md
│ ├── installation.md
│ └── reproduction.md
│
└── .github/
└── workflows/
└── tests.yml
The research evaluates META-IR using two LLM backbone families.
| Model | Purpose |
|---|---|
| LLaMA-3.1-8B-Instruct | Main backbone evaluation |
| Qwen-2-7B-Instruct | Cross-backbone evaluation |
The exact Qwen checkpoint identifier should be verified against the experimental configuration before release.
The supplementary experimental setup reports the following configuration:
| Component | Configuration |
|---|---|
| GPU | 8 × NVIDIA A800-SXM4-80GB |
| CUDA | 12.2 |
| Precision | bfloat16 |
| Distributed Training | Distributed Data Parallel |
| Gradient Synchronization | All-Reduce |
| Optimizer | AdamW |
| Learning Rate Scheduling | Cosine scheduling with linear warm-up |
Backbone parameters are kept frozen during the reported meta-training process, while the introspection policy and selected reward-related meta-parameters are optimized.
The experimental framework uses a unified seed corpus constructed from the following safety-related datasets:
| Dataset | Role |
|---|---|
| AdvBench | Harmful instruction evaluation |
| HarmBench | Safety and jailbreak evaluation |
| WildJailbreak | Benign and adversarial prompt coverage |
| DIR | Dedicated structured introspection dataset |
The reported experimental setup includes:
- A 50K-prompt unified seed corpus.
- A 20K-prompt Dedicated Introspection Dataset (DIR).
- 10K safety-oriented prompts.
- 10K helpfulness-oriented prompts.
- Separate meta-training and meta-evaluation task families.
Dataset availability: The original datasets are not included in this source-code repository. Users should obtain them from their respective official sources and comply with their individual licenses and usage requirements.
The DIR dataset should only be redistributed if its contents and underlying data licenses permit redistribution.
- Python version supported by the project configuration.
- PyTorch.
- CUDA-compatible GPU for accelerated experiments.
- Access to the required pretrained model checkpoints.
- Access to the required benchmark datasets.
git clone https://github.com/Miraj-Rahman-AI/Meta-IR.git
cd Meta-IRpython -m venv .venvActivate the environment.
Linux / macOS:
source .venv/bin/activateWindows:
.venv\Scripts\activatepip install --upgrade pip
pip install -r requirements.txtpython --version
python -c "import torch; print(torch.__version__)"
python -c "import torch; print(torch.cuda.is_available())"META-IR uses configuration files to organize model settings, training parameters, search behavior, and evaluation settings.
Example configuration organization:
configs/
│
├── model_config.yaml
├── training_config.yaml
├── search_config.yaml
└── evaluation_config.yaml
The configuration files should specify the following information:
Model Configuration
- Backbone model identifier.
- Tokenizer.
- Precision.
- Maximum sequence length.
- Generation parameters.
Training Configuration
- Learning rates.
- Optimizer.
- Batch size.
- Number of training iterations.
- Meta-learning parameters.
- Gradient accumulation.
SI-MCTS Configuration
- Search depth.
- Candidate expansion.
- Reward calculation.
- Safety evaluation.
- Branch pruning.
Evaluation Configuration
- Dataset paths.
- Evaluation splits.
- Random seeds.
- Evaluation metrics.
- Output directories.
META-IR follows a dual-loop optimization process.
The model is exposed to structured introspection examples to establish the required reasoning format.
SI-MCTS generates and evaluates candidate reasoning trajectories using the composite reward mechanism.
The introspection policy is updated using aggregated feedback across different jailbreak task families.
The trained framework is evaluated against static and adaptive jailbreak scenarios.
Example training entry point:
python scripts/train.py \
--config configs/training_config.yamlThe actual script arguments should follow the released implementation.
The inference component is intended to demonstrate how META-IR processes an input prompt through structured introspection and safety-aware response generation.
Example command:
python scripts/run_inference.py \
--config configs/model_config.yamlA demonstration should report:
- Input prompt.
- Structured introspective analysis.
- Safety assessment.
- Search and refinement information.
- Final model response.
The implementation should expose only appropriate diagnostic information and should not require disclosure of private internal model reasoning.
META-IR is evaluated across multiple dimensions of safety alignment and reasoning reliability.
- Adversarial attack performance.
- Harmfulness-related evaluation.
- Safety Violation Rate (SVR).
- Refusal Stability under Perturbation (RST).
- Benign instruction-following performance.
- Meta-generalization.
- General reasoning performance.
- Introspection Accuracy (IA).
- Risk-Explanation Attribution Recall (REAR).
- Meta-Confusion Rate (MCR).
- Jailbreak-Introspection Failure Rate (JIR).
- Meta-Training Adaptation (MTA).
- Adaptation performance across different jailbreak task families.
Example evaluation entry point:
python scripts/evaluate.py \
--config configs/evaluation_config.yamlEvaluation results should be reported with the corresponding dataset splits, model checkpoints, random seeds, and metric definitions.
Reproducibility is an important objective of this research repository.
The following information should accompany experimental releases:
- Model checkpoint identifiers.
- Dataset versions and preprocessing procedures.
- Training and evaluation configurations.
- Random seeds.
- Optimizer and scheduler settings.
- SI-MCTS search parameters.
- Meta-learning parameters.
- Evaluation scripts.
- Software and hardware configurations.
- Use the same model checkpoint as the corresponding experiment.
- Maintain consistent dataset splits.
- Record all random seeds.
- Use the published configuration settings.
- Report the hardware and software environment.
- Evaluate all methods under consistent experimental conditions.
The reported eight-GPU experimental configuration is the reference setup, not a requirement for running every demonstration. Smaller configurations may require reduced batch sizes, search budgets, or sequence lengths and should not be assumed to reproduce the reported results exactly.
META-IR provides a research framework for investigating:
- Adaptive safety alignment in LLMs.
- Jailbreak robustness.
- Structured introspective reasoning.
- Safety-aware search algorithms.
- Meta-learning for adversarial generalization.
- Reasoning stability under distribution shifts.
- Safety and helpfulness optimization.
- Self-improving language model systems.
The modular architecture also provides opportunities for further research into adaptive reasoning and trustworthy AI systems.
META-IR is a research framework and should not be interpreted as a guarantee of complete protection against jailbreak attacks or harmful model behavior.
Researchers should consider:
- Limitations of the underlying backbone models.
- Potential weaknesses in safety and reward evaluation.
- Distribution shifts beyond the evaluated attack families.
- Computational requirements of SI-MCTS and meta-learning.
- Dataset coverage and benchmark limitations.
- Potential differences between reported and independently reproduced results.
The framework should be evaluated carefully before deployment in safety-critical applications.
This repository is intended to be released under the MIT License.
The MIT License applies to the original source code distributed in this repository, subject to the rights and permissions of the respective code contributors.
Third-party datasets, pretrained models, dependencies, and external resources remain subject to their own licenses and usage policies.
See the LICENSE file for details.
If you use META-IR in your research, please cite our paper:
arXiv Preprint:
@misc{miraj2026metair,
title = {{META-IR}: Meta-Introspective Reasoning for Adaptive Safety Alignment in {LLM}},
author = {
Miraj, Mahabubur Rahman and
Huang, Hongyu and
Mu, Nankun and
Chen, Chao and
Yi, Shanqin
},
year = {2026},
eprint = {2611.10089},
archivePrefix = {arXiv},
primaryClass = {cs.AI},
url = {https://arxiv.org/abs/2611.10089}
}arXiv: https://arxiv.org/abs/2611.10089
This work was supported by the National Natural Science Foundation of China (Grant No. 62322601) and the Fundamental Research Funds for the Central Universities (Grant Nos. 2024IAIS-QN017 and 2025CDJZDG F001).
The authors gratefully acknowledge the financial support provided by these funding programs.
Research Project: META-IR
GitHub Repository: https://github.com/Miraj-Rahman-AI/Meta-IR
Email: miraj.ai.edu.cn@gmail.com
For questions, implementation discussions, reproducibility issues, or research collaboration, please feel free to contact me via email or use the GitHub Issues section of this repository.
Research Code | IEEE ICME 2026