PbRL | Preference Transformer:反正感覺 transformer 很強大

MoonOut發表於2024-03-06

  • 論文題目:Preference Transformer: Modeling Human Preferences using Transformers for RL,ICLR 2023,5 6 6 8,poster。
  • pdf:https://arxiv.org/pdf/2303.00957.pdf
  • html:https://ar5iv.labs.arxiv.org/html/2303.00957
  • open review:https://openreview.net/forum?id=Peot1SFDX0
  • 專案網站:https://sites.google.com/view/preference-transformer
  • GitHub:https://github.com/csmile-1006/PreferenceTransformer

內容總結

  • (為什麼感覺挺 A+B 的,有點想不明白為何會中…… 不過 writing 貌似很好)
  • 提出了新的 preference model,σ0>σ1 的機率仍然是 exp / (exp + exp) 的形式,但 exp[] 裡面的內容從 reward 求和(discounted reward 求和)變成 Σ r · w,其中 w 是一個 importance weight。
  • 這裡的 motivation:
    • ① human preference 可能基於 non-Markovian reward,因此用 transformer 建模 trajectory,作為 reward model 的一部分;
    • ② human 可能會關注關鍵幀,因此需要一個 importance weight,為先前提到的 non-Markovian reward 加權。
  • 然後,利用 attention layer 的 key query value 形式,將 value 作為 reward,softmax(key · query) 作為 importance weight。(正好跟 attention 的形式 match 上)

0 abstract

Preference-based reinforcement learning (RL) provides a framework to train agents using human preferences between two behaviors. However, preference-based RL has been challenging to scale since it requires a large amount of human feedback to learn a reward function aligned with human intent. In this paper, we present Preference Transformer, a neural architecture that models human preferences using transformers. Unlike prior approaches assuming human judgment is based on the Markovian rewards which contribute to the decision equally, we introduce a new preference model based on the weighted sum of non-Markovian rewards. We then design the proposed preference model using a transformer architecture that stacks causal and bidirectional self-attention layers. We demonstrate that Preference Transformer can solve a variety of control tasks using real human preferences, while prior approaches fail to work. We also show that Preference Transformer can induce a well-specified reward and attend to critical events in the trajectory by automatically capturing the temporal dependencies in human decision-making.

  • background:
    • PbRL 框架用於在兩種行為之間使用 human preference 來訓練 agent。然而,需要大量 human feedback,來學習與人類意圖一致的 reward model。
  • method:
    • 在本文中,我們介紹了 preference transformer,使用 transformer 架構模擬 human preference。
    • 以前方法假設,人類判斷基於 Markovian reward,而 Markovian reward 對決策的貢獻相同。與先前工作不同,我們引入了一種 preference model,該模型基於 non-Markovian reward 的加權和。
    • 然後,我們在 preference model 的 transformer 設計裡,堆疊 causal self-attention layers 和 bidrectional self-attention layers。
  • results:
    • Preference Transformer 可以使用真實 human feedback 來解決各種控制任務,而以前的方法無法奏效。
    • Preference Transformer 可以透過自動捕獲人類決策中的時間依賴性(temporal dependencies),來得到一個 well-specified reward 並關注軌跡中的關鍵事件。

open review 與專案網站

  • open review:
    • 主要貢獻:① 提出了一個基於 non-Markovian reward 加權和的新 preference model,② 引入 PT 來模擬所提出的 preference model。
    • 如果獎勵實際上是 non-Markovian 的,那麼 Transformer 的想法是有動機的(well motivated)。
    • The paper is well written. 論文寫得很好。
    • scripted evaluation(大概是 scripted teacher)使用 Markovian reward,但 NMR(non-Markovian reward)和 PT 仍能在多個領域優於 MR(Markovian reward)變體。這需要得到更好的解釋和評估。事實上,應該使用 non-Markovian reward 進行評估。
  • 專案網站:
    • Preference Transformer 將 trajectory segment 作為輸入,從而提取與任務相關的歷史資訊。
    • 透過堆疊 bidirectional 和 causal self-attention layers,Preference Transformer 生成 non-Markovian reward 和重要性權重(importance weights)作為輸出。(貌似 importance weight 越高,某幀在整個 trajectory 裡越重要)
    • 我們利用它們來定義 preference model,並發現 PT 可以得到 better-shaped reward,並從 human preference 中關注關鍵事件。
    • 實驗證明,PT 可用於學習複雜的新行為(Hopper 多次後空翻),這很難設計合適的獎勵函式。與單個後空翻相比,這項任務更具挑戰性,因為獎勵函式必須捕獲 non-Markovian 上下文,包括旋轉次數(有必要嘛?)。觀察到,PT agent 在穩定著陸的情況下執行多個後空翻,而基於 MLP 的 Markovian reward 的 agent 很難著陸。

1 基於 non-Markovian reward 的 preference model

  • motivation:
    • 首先,在許多情況下,很難使用 Markovian reward 來給出任務的描述。
    • 此外,由於人類對於非凡的時刻很敏感,因此可能需要在軌跡內分配 credit(大概是權重的意思)。
  • non-Markovian reward function:
    • reward function 的輸入:先前的完整的 sub-trajectory。
    • 同時再整一個權重函式 w = w({s, a, s, ...}),其輸入也是 t 時刻之前的完整 sub-trajectory。
    • 用 r(τ) · w(τ) 來改寫 \(P(\sigma^1\succ\sigma^0)=\bigg[\exp\big(\sum_tr(\tau_t)\cdot w(\tau_t)\big)\bigg]/\bigg[\exp(\sum r\cdot w)_{\sigma^0}+\exp(\sum r\cdot w)_{\sigma^1} \bigg]\) 的公式。

2 PT 的架構

  • 感覺 causal transformer 相對好理解,以及 GPT 具有 causally masked self-attention。
  • preference attention layer:
    • causal transformer 生成的 {x, x, ...} sequence,過一個線性層,會得到它們的 key query value。
    • 認為得到的這個 value 就是 reward,而 key 與 query 相乘再 softmax(保證>0)則是權重。
  • 好像這只是一個 reward model,而非 RL policy(?)
    • 學到 reward model 後,還需要使用 IQL 學 policy…
Refer to caption

3 PT 的訓練與 inference

  • training:最小化 cross-entropy loss \(L=-\mathbb E[(1-y)\log P[\sigma^0\succ\sigma^1]+y\log P[\sigma^1\succ\sigma^0]]\) ,其中 y 是 label,P 是我們訓練的機率。
  • inference:如何得出 agent 的 reward。
    • 好像是直接拿 reward(而非 reward · importance weight)來做。
    • 大致流程:拿 st, at, s, ... 送進 causal transformer,然後得到 xt, ...,送進 preference attention layer,得到 r hat,單獨取出 r hat。

4 experiments

關注的問題:

  • Preference Transformer 能否使用真實的人類偏好解決複雜的控制任務?
  • PT 能否 induce 一致(consistent)的 reward 並關注關鍵事件?
  • PT 在合成偏好(synthetic preferences,即 scripted teacher setting)中的表現如何?

baseline:

  • 技術路線:preference → reward model → IQL。
  • 1 MLP 的 Markovian reward。
  • 2 基於 LSTM 的 non-Markovian reward。

results:

  • PT 在幾乎所有任務中,都始終優於所有 baselines。特別的,只有 PT 幾乎將 IQL 的效能與使用 ground-truth reward 相匹配,而 baselines 在困難的任務中基本不 work。
  • 讓 PT 和 Markovian 或 LSTM agent 分別生成 trajectory,讓 human 評價哪個更好,human 評價 PT 更好。
  • 在所謂的“PT 是否可以誘導(induce)一個明確(well-specified)的獎勵”這一段,好像也只是感性分析了一下…
  • 在比較 scripted teacher 和 human 時,因為 scripted teacher 不能理解 contex,所以 human preference 反而在簡單任務上表現更好;並且,它們的 preference 會在簡單的 grid-world 中發生分歧。
  • 學習複雜的新行為:很炫酷的 hopper 空中多個後空翻的 demo。

5 好像很有道理的 future work

  • 在 RL 或 PbRL 中利用重要性權重,或許可以用於對資訊量更大的 query / samples 進行取樣,這可以提高 sample-efficiency。
  • 使用重要性權重,透過加權更新,來穩定 Q 學習。
  • 與其他偏好模型結合:例如 Knox et al.(2022)的基於 regret 的 preference model(title: Models of human preference for learning reward functions),儘管他們提出的方法基於幾個假設(例如,生成後續特徵(Dayan,1993;Barreto et al., 2017)),與基於遺憾的模型相結合會很有趣。(這個暫時沒看懂如何做)


相關文章