This repository contains the official implementation of GIFT, a framework that leverages game-based informal training to improve the generalization of large language models.
2026.5.28: We release the official implementation of GIFT paper.
GIFT studies how informal learning from interactive environments (games) can complement formal learning and yield more generalizable LLM behaviors.
Key ideas:
- Games as informal training: interaction, practice, and feedback in multi-step environments.
- Coordinated Subtask Training: replace coarse mixed updates with sequential subtask-specific updates, preserving task-local RL signals and introducing implicit cross-task gradient coordination.
- Generalization focus: evaluate on general abilities in addition to in-domain math and game success.
- Formal learning: structured, goal-oriented tasks (e.g., math).
- Informal learning: learning in rich environments via interaction, practice, and feedback (e.g., games).
Mixed training can blur task-specific learning signals and provides no explicit guidance for coordinating task-gradient directions.
Coordinated Subtask Training replaces a single mixed update with sequential subtask-specific updates, separating heterogeneous RL signals while implicitly promoting coordination among subtasks.
gift-llm/
├── images/ # Figures used in README/docs
├── cases/ # Figures for case study
├── config/ # Hydra/YAML configs for training
├── external/ # Optional: WebShop Environments
├── ragen/ # Main Training Codes
├── reason_test/ # Evaluation scripts
├── scripts/ # Entry-point scripts (train/convert/eval)
├── verl/ # Base VeRL packages
├── requirements.txt
└── README.md
Please refer to setup_gift.md to set up the gift environment.
Scripts for training, convertion and evaluation are in scripts directory.
We use the EnvPlayer class in ragen/env/base.py to initialize and call opponents. Add api-keys.json to make api calls. The data structure in api-keys is as following:
{
"deepseek":["Your-API-Keys in official deepseek website"],
"openrouter":["Your-API-Keys in openrouter website"],
"dmx":["Your-API-Keys in dmxapi website"],
}Environments for training each task are in ragen/env/ directory, including:
- formal learning: math env
math_lv3to5. - informal learning: Matrix Games
nash_new, TicTacToetictactoe, and Who's the Spyundercover. - CST environment
batch.
The mixed training can be constructed directly in yaml configs, such as config/_14_FI1_mixed.yaml.
Training scripts in scripts directory includes:
- single tasks: formal learning, math
math.sh, informal learning, matrix gamesnash.sh, TicTacToetictactoe.sh, and Who's the Spyundercover.sh. -
$\text{F+I}_1$ tasks: mixed trainingFI1_mixed.shand CSTFI1_CST.sh. -
$\text{F+I}_2$ tasks: mixed trainingFI2_mixed.shand CSTFI2_CST.sh. -
$\text{F+I}_3$ tasks: mixed trainingFI3_mixed.shand CSTFI3_CST.sh. -
$\text{I}_2$ tasks in ablation study: mixed trainingI2_mixed.shand CSTI2_CST.sh.
For example, run ./scripts/math.sh in GIFT-LLM directory to train the model on the math task.
To convert the fsdp2 checkpoint models to huggingface format, please use the merge.sh script.
We also provide the
monitor.shscript to iteratively convert the old checkpoint files to huggingface models. Change the path inmonitor.shandmerge_dl.shto run this.
Evaluate codes in reason_test directory includes:
- in-domain task MATH500
lv3to5_dl.py, Matrix Gamesnash-new.py, TicTacToetictactoe.py, and Who's the Spyundercover.py - MMLU
mmlu_dl.py, and MMLU-Prommlu_pro_dl.py - Creative writing CommonGen
common.py. - Social abilities SocialIQA
social.py.
After running this scripts, the evaluation results will be added to reason_test/ directory and some cases will be saved in reason_test/results/ directory.
Please download huggingface datasets to evaluate.
- MATH500: https://huggingface.co/datasets/hkust-nlp/SimpleRL-Zoo-Data
- MMLU: https://huggingface.co/datasets/cais/mmlu
- MMLU-Pro: https://huggingface.co/datasets/TIGER-Lab/MMLU-Pro
- SocialIQA: https://huggingface.co/datasets/allenai/social_i_qa
- CommonGen: https://huggingface.co/datasets/allenai/commongen_lite_eval
To add new games or tasks, please add this in ragen/env/ directory, including __init__.py, config.py, and env.py.
Then please log this new env in ragen/env/__init__.py and config/envs.yaml.
Optional: Run
python -m ragen.env.[Your ENV Name].envto test your env codes.
The CST framework is in batch environments. Edit the base_env_list variables to change the CST sub-task.
The k_list variable specifies the number of local update steps for each sub-environment. For example, for F+I3 training with the 7B-base model, setting k_list: [1, 1, 1, 1] updates each sub-environment at every step.
TBD
This project is built on RAGEN framework(https://github.com/mll-lab-nu/RAGEN), based on VeRL framework(https://github.com/volcengine/verl). We change the core algorithms in RAGEN to support GIFT training.
This project is released under the MIT License.
It includes code derived from the RAGEN framework, which is also licensed under the MIT License.

