Luo Ji, Qi Qin, Ningyuan Xi, Teng Chen, Qingqing Gu, Hongyan Li
| 2026-08-30 | The full versions of CrossFit&UnifedQA and SNI have been uploaded to huggingface. |
| 2026-06-20 | An example model checkpoint is uploaded to huggingface. |
| 2026-06-16 | The camera-ready version has been updated on Arxiv. |
| 2026-06-14 | An example subset of dataset (non-nli->nli) is uploaded to huggingface. |
| 2026-05-01 | Our paper has been accepted by ICML 2026! |
For ease of quick implementation, /data/metaicl/non_nli_to_nli has a small examples of the training set of non-nli-to-nli.
bash train_eval_MetaICL_non-nli-to-nli.shAn exampled model checkpoint is on https://huggingface.co/jiluoaaron/MeGan-R512-CrossFit_UnifiedQA-nn2n-lr1e-6/.
bash eval_MetaICL_non-nli-to-nli.shThis project is implemented on the basis of LlamaFactory 0.8.3. Questions to the basic usage can refer to the original repo: https://github.com/hiyouga/LlamaFactory/tree/v0.8.2.
All the data are converted to the messages format (in .jsonl). The condition has a key called style in the raw dataset due to the histrical reason. More data uploading is incoming.
Task descriptions of CrossFit&UnifedQA are automatically generated by GPT-4o. The full version of generated descriptions are in data/task_descs.yaml.
Our data adheres to the openai format, which is a specific case of the sharegpt format in LlamaFactory. More details can refer to data/README.md.
To accommodate the newly-added condition in the data sample, we add a new type of style_tag to DatasetAttr in the parser.py. There might also be attributes of history or context in DatasetAttr depending on the detailed condition or dataset type. The sample is then processed by the convert_sharegpt function in aligner.py.
During training, the condition content is first converted into a natural expression by get_style_expression in supervised.py, then preprocess_supervised_dataset finally generates the supervision.
We keep a local copy of the official llama model code with the implementation of beta-SwiGLU and the hypernetwork in meta_swiglu_shared_modeling_llama.py. We also implement another version of model code which has layer-wise hypernetworks in meta_swiglu_modeling_llama.py.
One of the above model objects (LlamaForCausalLM_sharedHyper or LlamaForCausalLM) is loaded by loader.py, depending on the configuration of meta_swishglu_shared_hyper.
To automatically customize the model architecture by script configurations, one need to execute the setattr method within the patch_config function in patcher.py, to pass the running config (e.g., meta_swishglu_attn_key) to model_args.
We create a new model object called LlamaForCausalLM_sharedHyper in meta_swiglu_shared_modeling_llama.py, which has the following hierarchy:
- LlamaForCausalLM_sharedHyper
- LlamaModel
- LlamaDecoderLayer
- LlamaMLP
- HyperStyle2Beta
in which HyperStyle2Beta is the hypernetwork which is fed into the text expression of condition and the layer index, and outputs the layer-specific beta.
We have uploaded two datasets:
- CrossFit&UnifedQA: https://huggingface.co/datasets/jiluoaaron/CrossFit-and-UnifiedQA
- SNI: https://huggingface.co/datasets/jiluoaaron/SNI-meta-learning/
Training of MeGan is based on the template script: run_meta_swiglu_sft_template.sh.
| category | name | values | expaination |
| finetuning_args | finetuning_type | "meta_swiglu", "meta_swiglu_full" | if `full`: also finetune the original LLM parameter |
| model_args | meta_swishglu_shared_hyper | 1, 0 | if use the standalone hypernetwork (layer-independent) |
| model_args | meta_swishglu_attn_key | `x` | the key of cross-attention in hypernetwork (x means using the block input) |
| model_args | meta_swishglu_attn_head_num | int | the number of cross-attention heads in hypernetwork; default 4 |
| model_args | meta_swishglu_beta_num_layer | int | the number of cross-attention layers in hypernetwork; default 1 |
| model_args | meta_swishglu_mlp_bias | 1, 0 | if include the bias in MLP of hypernetwork; default 0 |
| model_args | meta_swishglu_beta_hidden_dim | int | the hidden dimension of hypernetwork (`R` in the paper); set to 128 or 512 |
| data_args | style_prompt_type | "None", "inSystem", "inQuery" | if also include the instruction (with the **condition**) in the system prompt or query; default inSystem |
| data_args | style_expression_type | "None", "withInstruction" | if use a full expression of instruction including the **condition**; default withInstruction |
Besides the above project-specific configurations, we also inherit all the original configurations from the official LlamaFactory. Refer to the original repo for their detailed usages.
Evaluations on different conditions are integrated into this single script: evaluate_style.py. Currently, only a single machine (up to 8 GPUs) is supported.
| name | values | expaination |
| model_type | 0, 1, 2 | 0: the standard LLM; 1: LLM with layer-wise hypernetworks; 2: LLM with a single, layer independent hypernetwork (the main method) |
| model_path | string | the checkpoint absolute path to evalulate |
| output_dir | string | the output folder to save the evaluated metrics and detaild results |
| data_path | string | the absolute path of the test dataset |
| num_gpus | int | the number of GPUs to evaulate (up to 8) |
| eval_form | string | "gen": ca, "gen_choice": calculate automatic metrics direclty based on the generated responses; "PPL_choice": calculate the accurary for multi-choice question (by PPL comparison of options); "gen_math": calculate the accuracy for math questions (e.g., GSM8K); "gen_code": calculate the pass-1 for coding questions (e.g., HumanEval, MBPP) |
| eval_mode | string | "case_include", "strict", "case_strict" when eval_form="gen_choice", the principle of response correctness judgement: if strictly equaling or include; if case-sensitive or not |
| sample_format | string | "qa_domain": for the condition type of `domain`, inlcuding datasets AdaptSum; "qa_persona": for the condition type of `persona`, such as Persona-Chat; "qa_task": for the condition type of `task description`, inlcuding datasets SNI, CrossFit&UnifiedQA; "qa_style": for the condition type of `style`, inlcuding datasets GYAFC, MIC; "qa_sentiment": for the condition type of `sentiment`, such as SST |
| style_prompt_type | "None", "inSystem", "inQuery" | if also include the instruction (with the **condition**) in the system prompt or query; default inSystem |
| style_expression_type | "None", "withInstruction" | if use a full expression of instruction including the **condition**; default withInstruction |
| style_domain | string | the detailed evaluation domain which differentite the output subfolder (e.g., when evaludating a specific domain of AdaptSum) |
The following script trains an exampled SFT: run_sft_test.sh based on the template script run_llama_sft_template.sh.
For LoRA, switch the finetuning type from full to lora; after training, LlamaFactory will save the adapter weights; use convert_lora_model.sh to convert it into the full checkpoint.
https://icml.cc/virtual/2026/poster/63102
For questions, please email: jiluoaaron@hotmail.com
If you find this work useful, please cite our paper:
@inproceedings{ji2026MeGan,
title={Learn-to-learn on Arbitrary Textual Conditioning: A Hypernetwork-Driven Meta-gated {LLM}},
author={Luo Ji and Qi Qin and Ningyuan Xi and Teng Chen and Qingqing Gu and Hongyan Li},
booktitle={Forty-third International Conference on Machine Learning},
year={2026},
url={https://openreview.net/forum?id=a7LaDjVpTC}
}