MCPcopy Index your code
hub / github.com/charleshsc/QT

github.com/charleshsc/QT @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
158 symbols 401 edges 14 files 35 documented · 22% updated 18mo ago★ 383 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Q-value Regularized Transformer for Offline Reinforcement Learning

Version License

| 📑 Paper | 🐱 Github Repo |

Shengchao Hu1,2, Ziqing Fan1,2, Chaoqin Huang1,2, Li Shen3,4*, Ya Zhang1,2, Yanfeng Wang1,2, Dacheng Tao5

1 Shanghai Jiao Tong University, 2 Shanghai AI Laboratory, 3 Sun Yat-sen University, 4 JD Explore Academy, 5 Nanyang Technological University.

Contents

Overview

Recent advancements in offline reinforcement learning (RL) have underscored the capabilities of Conditional Sequence Modeling (CSM), a paradigm that learns the action distribution based on history trajectory and target returns for each state. However, these methods often struggle with stitching together optimal trajectories from sub-optimal ones due to the inconsistency between the sampled returns within individual trajectories and the optimal returns across multiple trajectories. Fortunately, Dynamic Programming (DP) methods offer a solution by leveraging a value function to approximate optimal future returns for each state, while these techniques are prone to unstable learning behaviors, particularly in long-horizon and sparse-reward scenarios.

Building upon these insights, we propose the Q-value regularized Transformer (QT), which combines the trajectory modeling ability of the Transformer with the predictability of optimal future returns from DP methods. QT learns an action-value function and integrates a term maximizing action-values into the training loss of CSM, which aims to seek optimal actions that align closely with the behavior policy. Empirical evaluations on D4RL benchmark datasets demonstrate the superiority of QT over traditional DP and CSM methods, highlighting the potential of QT to enhance the state-of-the-art in offline RL.

Quick Start

When your environment is ready, you could run scripts in the "run.sh". For example:

python experiment.py --seed 123 \
    --env hopper --dataset medium   \
    --eta 1.0 --grad_norm 9.0 \
    --exp_name qt --save_path ./save/    \
    --max_iters 500 --num_steps_per_iter 1000 --lr_decay \
    --early_stop --k_rewards --use_discount  \

Citation

If you find this work is relevant with your research or applications, please feel free to cite our work!

@inproceedings{QT,
    title={Q-value Regularized Transformer for Offline Reinforcement Learning},
    author={Hu, Shengchao and Fan, Ziqing and Huang, Chaoqin and Shen, Li and Zhang, Ya and Wang, Yanfeng and Tao, Dacheng},
    booktitle={International Conference on Machine Learning},
    year={2024},
}

Acknowledgments

This repo benefits from DT and Diffusion-QL. Thanks for their wonderful works!

Core symbols most depended-on inside this repo

record_tabular
called by 19
logger.py
log
called by 14
logger.py
step
called by 10
decision_transformer/envs/reacher_2d.py
forward
called by 7
decision_transformer/models/ql_DT.py
_strip_invisible
called by 5
tabulate.py
_build_row
called by 4
tabulate.py
_build_line
called by 4
tabulate.py
_add_output
called by 3
logger.py

Shape

Method 92
Function 44
Class 21
Route 1

Languages

Python100%

Modules by API surface

logger.py46 symbols
decision_transformer/models/trajectory_gpt2.py33 symbols
tabulate.py27 symbols
decision_transformer/training/ql_trainer.py10 symbols
experiment.py9 symbols
decision_transformer/models/ql_DT.py9 symbols
decision_transformer/envs/reacher_2d.py6 symbols
decision_transformer/training/trainer.py4 symbols
decision_transformer/models/model.py4 symbols
decision_transformer/models/decision_transformer.py4 symbols
decision_transformer/training/seq_trainer.py2 symbols
decision_transformer/training/act_trainer.py2 symbols

For agents

$ claude mcp add QT \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact