論理タスクにおける深層学習
〜深層学習で算術演算を行う〜
B4 佐藤 裕太
2023 年 06 月 28 日水曜サーベイ
2
● Analysing Mathematical Reasoning Abilities of Neural Models,
d.saxton et al. (DeepMind)[ICLR 2019]
● Neural Sequence to grid Module for Learning Symbolic Rules,
s.kim et al.(Seoul National University)[
AAAI Conference on Artificial Intelligence 2021]
● Transformers discover an elementary calculation system
exploiting local attention and grid-like problem representation,
s.cognolato et al. (University of Padova)[EEEI IJCNN 2022]
Survey on Mathematics in Deep Learning
1. 深層学習 x 数学に関するサーベイ論
文
2. OOD への汎化性能をあげる論文
3. 2. を活用して高速化した論文
3
( 背景 1/2)
●
4
( 背景 2/2)
● 論理タスクにおける深層モデルの問題点は?
● 論理タスクとは,算術演算の学習やコンピュータプログラムの評価などの
記号に対する論理的なタスクのこと
● Transformer などの最新 (2021 年 ) のシーケンスニューラルネットでさえ
も
足し算などの単純な算術に演算に対しても汎化できない
● e.g.) 5000(4 桁 )+1000(4 桁 )=6000 を学習した時( ID )
50000(5 桁 )+100000(6 桁 )=150000 を解けるのか?( OOD )
人間なら簡単に解ける
深層モデルだとあまり解けない or
ほとんど解けない
5
どんなもの?
● データセット作り ( 汎化性能も測定できる )
● Interpolation
● 訓練で使ったデータを分割してテストを行う( ID )
● e.g.) add_or_sub : 整数や小数に対する加算・減算データセット
● Extrapolation
● 訓練で使った桁数とは違うデータなどで検証( OOD )
● e.g.) add_or_sub_big :
訓練中に見たデータより桁の大きい数字に対しての加算・減算データセット
Analysing Mathematical Reasoning Abilities of Neural Models,
d.saxton et al.(DeepMind)[ICLR 2019]
6
どんなもの?
● データセットの概要
● 8 つの分野にそれぞれに 5 〜 10 個ほどのタスクを定義してデータを作成
● ALGEBRA : e.g. solve 2(x − 10) + 3 = 17x + 10 for x.
● ARITHMETIC : 四則演算について
● CALCULUS : e.g. let f(x) = 2 x+3, let g(x) = x 2−17; what is the derivative of f(g(x))
∗ ∗∗
● MEASUREMENT : e.g. how many millilitres are there in 13/8 of a litre?
● NUMBERS : e.g. give 1011001 (base 2) in base 16
● POLYNOMIALS : e.g. calculating 2f(x) + 17g(x) given f and g
● PROBABLITY : 確率に関する文章問題
Analysing Mathematical Reasoning Abilities of Neural Models,
d.saxton et al.(DeepMind)[ICLR 2019]
7
どんなもの?
● 作成したデータセットでのモデルの性能評価
● LSTM, attention LSTM, Transformer において検証
Analysing Mathematical Reasoning Abilities of Neural Models,
d.saxton et al.(DeepMind)[ICLR 2019]
8
考察
●
Analysing Mathematical Reasoning Abilities of Neural Models,
d.saxton et al.(DeepMind)[ICLR 2019]
モデルはそれぞれの演算のやり方を学習し
ているわけではない
9
考察
● Transformer とリカレントモデルの差異
● 基本的に Transformer > non-Transformer
● 同じパラメータ数でも計算回数が多い
● 多項式展開,微分などにおいては Transformer >> リカレントモデル
● 問題内の複数の係数を同時に保持することが可能なため
● 実数学でのパフォーマンス
● 16 歳レベルの数学の問題 40 問に対して 14 問正解
● 現実の試験でいい成績を取る知識をコーディングできる可能性がある
Analysing Mathematical Reasoning Abilities of Neural Models,
d.saxton et al.(DeepMind)[ICLR 2019]
10
どんなもの?
先行研究と比べて何がすごい?
技術の手法やキモは?
どうやって有効だと検証した?
Transformer などで入力とする配列シーケン
スを画像データようなグリット形式に変換す
ることで OOD となる数学の問題も解くことが
できるようになったという内容
seq2grid の変換器も RNN を使用しており,
モデルにとって都合のいい変換方法を学習す
るようになっているため end2end で学習を行
うことができる
既存の深層モデル (Transformer など ) でも解
くことが難しい OOD の問題に対しても解くこ
とができるようになった
Neural Sequence to grid Module for Learning Symbolic Rules,
s. kim et al. (Seoul National University)[AAAI Conference on Artificial Intelligence2021]
11
アーキテクチャ
Neural Sequence to grid Module for Learning Symbolic Rules,
s. kim et al.(Seoul National University)[AAAI Conference on Artificial Intelligence2021]
TLU Top list update
NLP New list push
NOP No op ( 何もしない )
3 つの a (学習パラメータ) それぞれの事象の確率
12
アーキテクチャの利点
● Grid の利点
● 足し算などの算術演算では grid データにし
て桁数を合わせた方が機械の認識しやすい
形になることもある
● 今回のモデルはこの Grid の作り方も自身で
学習できるためより計算のしやすい形に問
題を変換できる
→これが汎化につながったのだろう
Neural Sequence to grid Module for Learning Symbolic Rules,
s. kim et al.(Seoul National University)[AAAI Conference on Artificial Intelligence2021]
13
有効性の検証
Neural Sequence to grid Module for Learning Symbolic Rules,
s. kim et al.(Seoul National University)[AAAI Conference on Artificial Intelligence2021]
数列予測タスク
数列の項を input していって
次の項を予測するタスク
e.g.)input : 7008, -205, 4,
7221
target : 14233
加算・減算タスク
言語命令で算術タスクを解く
タスク
e.g.) input : What is -784518
take away 7323?
Target : -791841
プログラム結果推論タスク
入力となる python スクリプ
トの出力結果を推論するタス
ク
14
どんなもの?
先行研究と比べて何がすごい?
技術の手法やキモは?
どうやって有効だと検証した?
先ほど説明した seq2grid の機構を使用する.
gird デコーダとして Universal Transformer
を使用して,さらに adaptive な計算停止機構
も備えたモデルの提案.
計算停止機構の設計により
最新のモデルより学習を高速化してして行う
ことができ,結果も最新モデルと同程度で
あった.
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
局所的な attention を持つ Universal
Transformer
adaptive な計算停止機構
設定を変えた 2 つのモデルを作成して効果を
検証した.
15
Universal Transformer
● どんなもの?
● Transformer の帰納バイアスが
弱いという欠点を補う
● RNN の機構を Transformer に追加した
● 利点は?
● Transformer の並列計算の効率性と広い
receptive field を維持したまま, RNN
のような再帰的な構造による帰納バイア
スを得る 参考:
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
16
Adaptive Computation Time (ACT)
● どんなもの?
● RNN について提案されたリカレントブロック
をシンボルごとに動的に決定する手法
● 利点は?
● 解釈がはっきりしているシンボルに対しては
リカレントブロックの計算回数を減らし,
逆の場合は増やすことで計算回数の最適化を行
える
通常の Universal Transformer と
ACT を使用した
Universal Transformer
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
17
アーキテクチャ
● Seq2Grid
● 一つの前の論文で出たモジュール
● 本論文では RNN だが,今回は FFN
● Convolutional Universal Transformer
● Grid データから計算結果を出力する (top-row)
● Local Attention は G を複数のグループ( g 個)
に分割して,局所的な Attention を計算する
● 元ネタは SASA という論文
● 次ページに続く
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
18
アーキテクチャ
● Convolutional Universal Transformer
● 1. g 個のグループに分割して Q, K, V を算出
● 2. 一度 concat して Q, K, V を得る
● 3. h 個のヘッドに分割して, local Attention を計算
位置 ij がヘッド m の位置 ab に
対して払う attention を示す
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
19
アーキテクチャ
● Convolutional Universal Transformer
学習できるクエリエンコーディング
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
位置 ij に対する ab の位置の
相対ポジショナルエンコーディング
※ s についてはクエリエンコーディ
ングとしか言及されていない.
メリットについては式 (8) のように
ネットワークが表現豊かなルールを
獲得できると記載されていた
20
アーキテクチャ
●
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
Λ : n ステップ目に計算を停止するかど
うかを 0, 1 で示す.
21
アーキテクチャ
● Halting Mechanism
● PonderNet の損失は式 (11) のようになるものである
● この損失の正則化項 βR( ・ ) を改良したのが
本モデルで使用する正則化項で式 (12) である
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
ここに工夫を施す
PonderNet では KL-divergence
を利用して,リカレントステップ
回数を平均に近づけるようにする
22
提案手法の検証
● Group 化の必要性
● 2 つの大きな整数の和を出すタスクでは意外なことに
noGroups の方がよい性能
● 項数を増やしたタスクでは base-model が優位
● 以下の表は問題インスタンス [1, 4], [1, 10] で学習されたモデルの汎化性能結果
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
23
提案手法の検証
● PonderNet との比較
● 正則化項に KL-divergence を
使用するより提案手法の方が
計算回数を減らせる
● 難しいタスクほどリカレント
ブロックの計算回数が増加しており
最適化できていることが確認できる
Transformers discover an elementary calculation system exploiting local attention and grid-like
problem representation, S.Cognolato et al. (University of Padova)[EEEI IJCNN 2022]
24
考察・これからの論文サーベイ
● 算術演算などの論理タスクには特定の処理 (seq2grid など ) を
与えることで性能が向上することは確認できる
● 暗号などの特定のタスクを解くための前処理・アーキテクチャ等は検討すべきであると感じた
● UT のような帰納バイアスを持つアーキテクチャについて
● 論理タスクにおいて帰納バイアスがあるようなモデルが結果に影響することも考えられる
( Transformer は一般的に Algorithmic なタスクや言語理解のタスクは苦手)
● モデルの検討
● 基本ラインは Transformer を使用することになるが UT や RWKV などの
興味が惹かれるモデルあるためこれらの技術について調査したい
まとめ
25
終
26
寸法や色は場合に応じて調整しましょう
よく使う図形のパターン
1
何かの見出し
27
良く使う図形パターン
①
ひとつめ
③
みっつめ
➁
ふたつめ
変化
変化
変化
何か
メッセージ
28
3つあることが一目でわかる
3カードのレイアウトテンプレート
カード① カード②
カードの見出し カードの見出し
カード③
カードの見出し
29
順序関係がある場合は並列よりこちらが良い
3カードのレイアウトテンプレートのアレンジ
カード①
カード②
カードの見出し
カードの見出し カード③
カードの見出し
30
カードの間隔やアスペクト比は適宜調整
4カードのレイアウトテンプレート
カード①
カードの見出し
カード②
カードの見出し
カード③
カードの見出し
カード④
カードの見出し
31
循環がある場合はこんな感じが良い
4カードのレイアウトテンプレートのアレンジ
カード①
カードの見出し
カード②
カードの見出し
カード③
カードの見出し
カード④
カードの見出し

survey on math transformer 2023 0628 sato

Editor's Notes

  • #8 これらのモジュールの違いは、前者が 比較的線形/浅い/平行な方法で計算できるのに対し(勾配降下法によって解法が比較的発見し やすい)、中値を計算する必要がある括弧付きの混合算術式を評価するには近道がないことを 推測しています。
  • #11 RNNの構造になっており,wから順にgridに変換されていく.
  • #13 後述するがUTがTransformerより性能がいい.
  • #17 先に謝る Halting Mechanismの方はACTをん進化させたPonderNetというend2endで
  • #18 where Am ij,ab is the attention that position ij pays to position ab at head m, ra−i,b−j ∈ R k×k×demb is a learned relative positional encoding, s ∈ R demb is a learned query encoding, Nk(i, j) is the neighborhood of position ij with spatial extent k. Our definition differs from [24] in 2 points: (1) we split vectors at two different points, contrary to SASA which can be interpreted as the special case g = h; (2) we added the query encoding s and extended ra−i,b−j . The use of both ra−i,b−j and s is meant to allow the network to build more expressive rules for aggregating value vectors. This can be seen by expanding the expression:
  • #19 where Am ij,ab is the attention that position ij pays to position ab at head m, ra−i,b−j ∈ R k×k×demb is a learned relative positional encoding, s ∈ R demb is a learned query encoding, Nk(i, j) is the neighborhood of position ij with spatial extent k. Our definition differs from [24] in 2 points: (1) we split vectors at two different points, contrary to SASA which can be interpreted as the special case g = h; (2) we added the query encoding s and extended ra−i,b−j . The use of both ra−i,b−j and s is meant to allow the network to build more expressive rules for aggregating value vectors. This can be seen by expanding the expression: トークンに支払われる注目度はトークンの内容(コンテンツベースのルール)とトークンの位置(ポジションベースのルール)の2つの混合結果によってわかる. 後述するV-Bによってモデルはこれらを学習することがわかる.
  • #20 Pnはnステップ目に計算を停止させる確率を示す.
  • #21 P_nはn回目のリカレントで停止する確率で Yとyハットは計算タスクの答えとmodelの予測回答である. 元の論文の正則化項はKLダイバージェンスを使って,平均の繰り返し計算の値を収束するように設定されていた. ーH()は負のクロスエントロピー モデルはp_nのクロスエントロピーを最大化するように学習をおこなう. →各ステップを平均的にやるようにする N_hはモデルの計算ステップなのでこれの期待値を下げようと学習する. →これにより簡単な問題に対して計算回数を減らすように学習する.
  • #22 2term = ? + ? N term = ? + ? .. ? + ? Char : 文字レベル有効なマッチングのためにすべての文字が考慮される Seq : シーケンス単位で正解しているかどうか N1~n2の数字の項数を持つ =[n1, n2], d1~d2の桁数=[d1, d2]
  • #23 2term = ? + ? N term = ? + ? .. ? + ? Char : 文字レベル有効なマッチングのためにすべての文字が考慮される Seq : シーケンス単位で正解しているかどうか