SlideShare a Scribd company logo
1 of 16
BERT Embeddingsの可視化
平 宏行
2021年5月29日
自己紹介
平 宏行
2
◼ 所属
➢ ファーボ株式会社
➢ 一般社団法人「データで考える力」イニシアティブ
◼ 職種
➢ データ利活用技術者(データサイエンティスト)
◼ 業務内容
➢ 事業課題をデータ利活用によって解決すること
• BIダッシュボード開発
• アイデア可視化によるチャンス発見
• 自然言語処理による文書分類
• 電力需給予測モデル構築
etc.
今回の発表内容は個人的なものであり,所属組織の公式見解とは無関係です.
Embedding(埋め込み)とは何か
3
◼ 離散的な変数を学習されたベクトルで表現したもの
◼ 高次元ベクトルを低次元空間へ変換
◼ 自然言語処理におけるEmbedding(埋め込み)とは,単語や文などに対して,
ある空間のベクトルを与えること
➢ テキストを数値化できるので数理演算が可能
➢ そのベクトルは特徴量として機械学習モデルへ入力可能
◼ ベクトルの座標から可視化が可能
➢ 単語や文など可視化することで意味の分布を読み取れる可能性あり
[1] 概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html
https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja
[1]
Embeddingアルゴリズムの種類 (1/2)
4
◼ One-hot表現(One-hot Encoding)
表現したい単語リストから,単語数の分だけ次元を設定し,
ある単語の次元に存在する単語は1,存在しなければ0を与える
ダミー変数のように0, 1で表現
例)「今日は勉強会」→今日 は 勉強会
今日 [1, 0, 0]
は [0, 1, 0]
勉強会 [0, 0, 1]
今日は勉強会 [1, 1, 1]
One-hot表現を足し合わせることで文を表現→Bag-of-words (BOW)→文のベクトル表現
[1] 堅山耀太郎, Word Embeddingモデル再訪, オペレーションズ・リサーチ学会,2017年11月号
http://www.orsj.or.jp/archive2/or62-11/or62_11_717.pdf
[1]
Embeddingアルゴリズムの種類(2/2)
5
◼ 共起関係
◼ LSI (Latent Semantic Indexing)
◼ Word2Vec
◼ Glove
◼ fastText
◼ Character-based Embedding
◼ Word Embeddingモデルのアンサンブル
◼ BERT
etc.
◆ マッピング先(写像先)の空間について
➢ ユークリッド空間
➢ 双曲空間
➢ 超球面
➢ リーマン多様体
etc.
[1] 堅山耀太郎, Word Embeddingモデル再訪, オペレーションズ・リサーチ学会,2017年11月号
http://www.orsj.or.jp/archive2/or62-11/or62_11_717.pdf
[1]
[1]
[1]
[1]
[1]
[1]
[1]
ユークリッド空間
[1]
自然言語以外のEmbedding (1/3)
6
◼ 画像のEmbedding
➢ 各ピクセルのRGBを画像認識ディープラーニング(CNNなど)などで特徴量抽出
➢ t-SNE,PCA(主成分分析)などで次元圧縮
• 低次元空間に可視化
[1] 概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html
https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja
Google ML ベースの t-SNE を使用して類似性マッピングが行われた画像 [1]
自然言語以外のEmbedding (2/3)
7
◼ マルチモーダルなEmbedding
➢ 画像とテキストを1つの空間にマッピング
➢ 画像とテキストで意味が近いものどうし近くに位置づけるように工夫
◆ マルチモーダルな機械学習
• CLIP (Contrastive Language-Image Pre-Training)
画像とテキストのペアでトレーニング
[1] GitHub - openai_CLIP_ Contrastive Language-Image Pretraining.html
https://github.com/openai/CLIP
CLIP (Contrastive Language-Image Pre-Training) [1]
自然言語以外のEmbedding (3/3)
8
◼ Node Embedding
➢ グラフ(ノード(点)とエッジ(辺)からなるネットワーク図)
• G=(N, E): グラフ(N: 頂点集合、E: 辺集合)
• f: N -> X: 単射
• X: Embedding Space
(連続的な空間:ユークリッド空間,超球面,双曲空間,リーマン多様体, etc.)
➢ “良い“ embeddingとは辺の情報がうまく反映されている
1. 一般的に、離散データ(グラフ自体)の取り扱いは難しいので、
embeddingにより頂点を連続の世界で取り扱え,微分が使える
2. Node embeddingは、以下のようなことをするために用いられる
➢ グラフに対するタスクを解く(pre-trainモデル)
• 頂点間の類似度を測る
• 頂点を可視化する
➢ ドラッグ デザイン、ソーシャル ネットワークでの友だちのおすすめ、タンパク質間の相互
作用の検出など、連鎖を多用する領域で役立つ
➢ グラフ畳み込みニューラル ネットワークやグラフ行列完成[2]
[1]良いnode embeddingとは? _ How to evaluate node embeddings - Speaker Deck.html
https://speakerdeck.com/sansandsoc/how-to-evaluate-node-embeddings
[2]概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html
https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja
[1]
Embedding活用のユースケース
9
◼ Embedding可視化によって
➢ 意味の整理
➢ レコメンデーション, etc.
◼ Embeddingの始まりはコラボレーションフィルタリング(CF)のタスク [1]
➢ 他の多くのユーザーの関心に基づいて、あるユーザーの関心を予測
[1]概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html
https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja
例)映画のおすすめ [1]
• ユーザーの視聴履歴に基づいて、似た内容の映画を調べる
• 100 万人のユーザー、50 万本の映画のカタログ、および各
ユーザーがどの映画を視聴したかを示す記録
• ユーザー ID、映画 ID、および watchedフラグのみ
• 非常にスパースなデータセットを作成
• 映画Embedding
➢ 特定のユーザーが観た映画を示す「映画の好み」空間
の近くにある、低次元の空間に映画を埋め込み
• ユーザーEmbedding
➢ さらにユーザーが視聴した映画に基づいて、同じ空間
にユーザー用の埋め込みを作成
• ユーザーの埋め込みの近くにあるのがおすすめ映画になる
• 行列分解、単一値分解、ニューラル コラボレーション フィ
ルタリング、ニューラル分解マシンなどの手法を使用して
学習 「シュレック」や「Mr. インクレディブル」のような映画は、埋め込み空間内で互いに近接.
どちらも子ども向け映画と見なされ、かつ大ヒット作と位置づけ
(プラスとマイナスの値は恣意的なもので、座標を決めるためにのみ使用)[1]
Embedding可視化ツールの種類 (1/5)
10
◼ Embedding Projector [1][2]
➢ Tensorflowの可視化ツール
➢ 2Dまたは3Dインタラクティブグラフに表示、ユーザーは多くのパラメーターを調整可能
➢ ブラウザで簡単に使用、オフラインでローカルで使用するのは困難
➢ 欠点は、複数のデータ セットを表示できないこと
➢ 軸としてベクトル演算を使用できない
[1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html
https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d
[2] Embedding projector - visualization of high-dimensional data.html
https://projector.tensorflow.org/?config=https://gist.githubusercontent.com/negedng/d2e31ca08eba402861bc480b2bbf72d8/raw/816196469c30a7ecae68d7a011057
a97977dc123/config.json
TF埋め込みプロジェクターv2.4.1を使用した「トマト」の例。 PCAで次元削減.
Embedding可視化ツールの種類 (2/5)
11
◼ vec2graph [1]
➢ 単語の埋め込みをグラフとして可視化することを目的としたライブラリ
➢ 使いやすさが魅力 (2 行のコードとグラフが表示)
➢ 大きな埋め込みスペースを視覚化するのには適していない
[1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html
https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d
Vec2graph v.0.3.0 の例。「トマト」という言葉を使用 [1]
Embedding可視化ツールの種類 (3/5)
12
◼ Whatlies
➢ 2Dインタラクティブグラフを作成するため使いやすい
➢ ベクトル演算を軸として使用することが可能
➢ 表示できるポイントの数が限られていること( 5,000 ポイント未満の可視化では優れたツール)
[1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html
https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d
Whatlies v.0.6.3 の例.PCA と同じ 10 ワードを使用.
Embedding可視化ツールの種類 (4/5)
13
◼ Parallax
➢ Jupyter Notebooks の単語埋め込みを視覚化する専用ツール
➢ ベクトル演算を軸として使用することが可能
• PCA、t-SNE、または UMAP の方法ではなく、軸としてベクトル演算を使用
• ユーザーは 2 つの単語の埋め込み平均またはセット内で最も頻繁に発生する単語を軸に使用
• 2 つのデータセットを比較することが可能
[1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html
https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d
Whatlies v.0.6.3 の例.PCA と同じ 10 ワードを使用.
Embedding可視化ツールの種類 (5/5)
14
◼ PROVEE (PROgressiVe
Explainable Embeddings)[1][2]
[1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html
https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d
[2] vig_provee_PROVEE Local Projector・GitLab.html
https://git.science.uu.nl/vig/provee/provee-local-projector
➢ 上述の可視化ツールの欠点を克服し,長所を組み
合わせようとしている(開発プロジェクト進行中)
➢ ビューを過度に変更しないことによって気を散ら
すものを最小限に抑える化しかを提供
➢ ポイントが最初から正しく配置され、さらにポイ
ントがロードされても位置があまり変わらない
➢ メモリ効率と組み合わせた入力データの高いス
ケーラビリティを備える
➢ PROVEE のアーキテクチャ
探索タスク中にユーザーの効率を維持するため
に、10 秒未満の待ち時間を持つ人間のアルゴリ
ズムのフィードバック ループを対象とする革新
的で進歩的な分析ワークフロー
① 分析アルゴリズム (特に IPCA)
② 直感的なローカル ユーザー インターフェイ
ス/可視化
③ 中間データの保存と転送
PROVEE(v.1.2.0)のプレビュー[1][2]
BERTによるEmbedding可視化
15
◼ TwitterのツイートをBERTでEmbedding
➢ 今までの自分のつぶやきを可視化して,つぶやきの傾向を知りたい
• Twitterからツイート履歴データをダウンロードしてCSVに変換
[1] BERTを理解しながら自分のツイートを可視化してみるハンズオン - Qiita.html
https://qiita.com/yuki_uchida/items/09fda4c5c608a9f53d2f
③ tweet.jsをCSVに変換
① Twitter管理画面でアーカイブ
をリクエスト
② ツイート履歴ファイル
tweet.jsをダウンロード
BERTによるEmbedding可視化
16
◼ Twitterの全ツイートをCSV形式に変換
➢ pandasのデータフレームに読込
[1] BERTを理解しながら自分のツイートを可視化してみるハンズオン - Qiita.html
https://qiita.com/yuki_uchida/items/09fda4c5c608a9f53d2f
今回はここまで!

More Related Content

Featured

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

Featured (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

Bert embedding visualization_20210529

  • 2. 自己紹介 平 宏行 2 ◼ 所属 ➢ ファーボ株式会社 ➢ 一般社団法人「データで考える力」イニシアティブ ◼ 職種 ➢ データ利活用技術者(データサイエンティスト) ◼ 業務内容 ➢ 事業課題をデータ利活用によって解決すること • BIダッシュボード開発 • アイデア可視化によるチャンス発見 • 自然言語処理による文書分類 • 電力需給予測モデル構築 etc. 今回の発表内容は個人的なものであり,所属組織の公式見解とは無関係です.
  • 3. Embedding(埋め込み)とは何か 3 ◼ 離散的な変数を学習されたベクトルで表現したもの ◼ 高次元ベクトルを低次元空間へ変換 ◼ 自然言語処理におけるEmbedding(埋め込み)とは,単語や文などに対して, ある空間のベクトルを与えること ➢ テキストを数値化できるので数理演算が可能 ➢ そのベクトルは特徴量として機械学習モデルへ入力可能 ◼ ベクトルの座標から可視化が可能 ➢ 単語や文など可視化することで意味の分布を読み取れる可能性あり [1] 概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja [1]
  • 4. Embeddingアルゴリズムの種類 (1/2) 4 ◼ One-hot表現(One-hot Encoding) 表現したい単語リストから,単語数の分だけ次元を設定し, ある単語の次元に存在する単語は1,存在しなければ0を与える ダミー変数のように0, 1で表現 例)「今日は勉強会」→今日 は 勉強会 今日 [1, 0, 0] は [0, 1, 0] 勉強会 [0, 0, 1] 今日は勉強会 [1, 1, 1] One-hot表現を足し合わせることで文を表現→Bag-of-words (BOW)→文のベクトル表現 [1] 堅山耀太郎, Word Embeddingモデル再訪, オペレーションズ・リサーチ学会,2017年11月号 http://www.orsj.or.jp/archive2/or62-11/or62_11_717.pdf [1]
  • 5. Embeddingアルゴリズムの種類(2/2) 5 ◼ 共起関係 ◼ LSI (Latent Semantic Indexing) ◼ Word2Vec ◼ Glove ◼ fastText ◼ Character-based Embedding ◼ Word Embeddingモデルのアンサンブル ◼ BERT etc. ◆ マッピング先(写像先)の空間について ➢ ユークリッド空間 ➢ 双曲空間 ➢ 超球面 ➢ リーマン多様体 etc. [1] 堅山耀太郎, Word Embeddingモデル再訪, オペレーションズ・リサーチ学会,2017年11月号 http://www.orsj.or.jp/archive2/or62-11/or62_11_717.pdf [1] [1] [1] [1] [1] [1] [1] ユークリッド空間 [1]
  • 6. 自然言語以外のEmbedding (1/3) 6 ◼ 画像のEmbedding ➢ 各ピクセルのRGBを画像認識ディープラーニング(CNNなど)などで特徴量抽出 ➢ t-SNE,PCA(主成分分析)などで次元圧縮 • 低次元空間に可視化 [1] 概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja Google ML ベースの t-SNE を使用して類似性マッピングが行われた画像 [1]
  • 7. 自然言語以外のEmbedding (2/3) 7 ◼ マルチモーダルなEmbedding ➢ 画像とテキストを1つの空間にマッピング ➢ 画像とテキストで意味が近いものどうし近くに位置づけるように工夫 ◆ マルチモーダルな機械学習 • CLIP (Contrastive Language-Image Pre-Training) 画像とテキストのペアでトレーニング [1] GitHub - openai_CLIP_ Contrastive Language-Image Pretraining.html https://github.com/openai/CLIP CLIP (Contrastive Language-Image Pre-Training) [1]
  • 8. 自然言語以外のEmbedding (3/3) 8 ◼ Node Embedding ➢ グラフ(ノード(点)とエッジ(辺)からなるネットワーク図) • G=(N, E): グラフ(N: 頂点集合、E: 辺集合) • f: N -> X: 単射 • X: Embedding Space (連続的な空間:ユークリッド空間,超球面,双曲空間,リーマン多様体, etc.) ➢ “良い“ embeddingとは辺の情報がうまく反映されている 1. 一般的に、離散データ(グラフ自体)の取り扱いは難しいので、 embeddingにより頂点を連続の世界で取り扱え,微分が使える 2. Node embeddingは、以下のようなことをするために用いられる ➢ グラフに対するタスクを解く(pre-trainモデル) • 頂点間の類似度を測る • 頂点を可視化する ➢ ドラッグ デザイン、ソーシャル ネットワークでの友だちのおすすめ、タンパク質間の相互 作用の検出など、連鎖を多用する領域で役立つ ➢ グラフ畳み込みニューラル ネットワークやグラフ行列完成[2] [1]良いnode embeddingとは? _ How to evaluate node embeddings - Speaker Deck.html https://speakerdeck.com/sansandsoc/how-to-evaluate-node-embeddings [2]概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja [1]
  • 9. Embedding活用のユースケース 9 ◼ Embedding可視化によって ➢ 意味の整理 ➢ レコメンデーション, etc. ◼ Embeddingの始まりはコラボレーションフィルタリング(CF)のタスク [1] ➢ 他の多くのユーザーの関心に基づいて、あるユーザーの関心を予測 [1]概要_ 機械学習のための特徴埋め込みの抽出と提供 _ Cloud アーキテクチャ センター _ Google Cloud.html https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning?hl=ja 例)映画のおすすめ [1] • ユーザーの視聴履歴に基づいて、似た内容の映画を調べる • 100 万人のユーザー、50 万本の映画のカタログ、および各 ユーザーがどの映画を視聴したかを示す記録 • ユーザー ID、映画 ID、および watchedフラグのみ • 非常にスパースなデータセットを作成 • 映画Embedding ➢ 特定のユーザーが観た映画を示す「映画の好み」空間 の近くにある、低次元の空間に映画を埋め込み • ユーザーEmbedding ➢ さらにユーザーが視聴した映画に基づいて、同じ空間 にユーザー用の埋め込みを作成 • ユーザーの埋め込みの近くにあるのがおすすめ映画になる • 行列分解、単一値分解、ニューラル コラボレーション フィ ルタリング、ニューラル分解マシンなどの手法を使用して 学習 「シュレック」や「Mr. インクレディブル」のような映画は、埋め込み空間内で互いに近接. どちらも子ども向け映画と見なされ、かつ大ヒット作と位置づけ (プラスとマイナスの値は恣意的なもので、座標を決めるためにのみ使用)[1]
  • 10. Embedding可視化ツールの種類 (1/5) 10 ◼ Embedding Projector [1][2] ➢ Tensorflowの可視化ツール ➢ 2Dまたは3Dインタラクティブグラフに表示、ユーザーは多くのパラメーターを調整可能 ➢ ブラウザで簡単に使用、オフラインでローカルで使用するのは困難 ➢ 欠点は、複数のデータ セットを表示できないこと ➢ 軸としてベクトル演算を使用できない [1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d [2] Embedding projector - visualization of high-dimensional data.html https://projector.tensorflow.org/?config=https://gist.githubusercontent.com/negedng/d2e31ca08eba402861bc480b2bbf72d8/raw/816196469c30a7ecae68d7a011057 a97977dc123/config.json TF埋め込みプロジェクターv2.4.1を使用した「トマト」の例。 PCAで次元削減.
  • 11. Embedding可視化ツールの種類 (2/5) 11 ◼ vec2graph [1] ➢ 単語の埋め込みをグラフとして可視化することを目的としたライブラリ ➢ 使いやすさが魅力 (2 行のコードとグラフが表示) ➢ 大きな埋め込みスペースを視覚化するのには適していない [1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d Vec2graph v.0.3.0 の例。「トマト」という言葉を使用 [1]
  • 12. Embedding可視化ツールの種類 (3/5) 12 ◼ Whatlies ➢ 2Dインタラクティブグラフを作成するため使いやすい ➢ ベクトル演算を軸として使用することが可能 ➢ 表示できるポイントの数が限られていること( 5,000 ポイント未満の可視化では優れたツール) [1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d Whatlies v.0.6.3 の例.PCA と同じ 10 ワードを使用.
  • 13. Embedding可視化ツールの種類 (4/5) 13 ◼ Parallax ➢ Jupyter Notebooks の単語埋め込みを視覚化する専用ツール ➢ ベクトル演算を軸として使用することが可能 • PCA、t-SNE、または UMAP の方法ではなく、軸としてベクトル演算を使用 • ユーザーは 2 つの単語の埋め込み平均またはセット内で最も頻繁に発生する単語を軸に使用 • 2 つのデータセットを比較することが可能 [1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d Whatlies v.0.6.3 の例.PCA と同じ 10 ワードを使用.
  • 14. Embedding可視化ツールの種類 (5/5) 14 ◼ PROVEE (PROgressiVe Explainable Embeddings)[1][2] [1] Steps towards visualizing Embedding spaces_ PROVEE _ by Sinievdben _ PROVEE _ May, 2021 _ Medium.html https://medium.com/provee/visualizing-large-embedding-spaces-provee-db4caed9f17d [2] vig_provee_PROVEE Local Projector・GitLab.html https://git.science.uu.nl/vig/provee/provee-local-projector ➢ 上述の可視化ツールの欠点を克服し,長所を組み 合わせようとしている(開発プロジェクト進行中) ➢ ビューを過度に変更しないことによって気を散ら すものを最小限に抑える化しかを提供 ➢ ポイントが最初から正しく配置され、さらにポイ ントがロードされても位置があまり変わらない ➢ メモリ効率と組み合わせた入力データの高いス ケーラビリティを備える ➢ PROVEE のアーキテクチャ 探索タスク中にユーザーの効率を維持するため に、10 秒未満の待ち時間を持つ人間のアルゴリ ズムのフィードバック ループを対象とする革新 的で進歩的な分析ワークフロー ① 分析アルゴリズム (特に IPCA) ② 直感的なローカル ユーザー インターフェイ ス/可視化 ③ 中間データの保存と転送 PROVEE(v.1.2.0)のプレビュー[1][2]
  • 15. BERTによるEmbedding可視化 15 ◼ TwitterのツイートをBERTでEmbedding ➢ 今までの自分のつぶやきを可視化して,つぶやきの傾向を知りたい • Twitterからツイート履歴データをダウンロードしてCSVに変換 [1] BERTを理解しながら自分のツイートを可視化してみるハンズオン - Qiita.html https://qiita.com/yuki_uchida/items/09fda4c5c608a9f53d2f ③ tweet.jsをCSVに変換 ① Twitter管理画面でアーカイブ をリクエスト ② ツイート履歴ファイル tweet.jsをダウンロード
  • 16. BERTによるEmbedding可視化 16 ◼ Twitterの全ツイートをCSV形式に変換 ➢ pandasのデータフレームに読込 [1] BERTを理解しながら自分のツイートを可視化してみるハンズオン - Qiita.html https://qiita.com/yuki_uchida/items/09fda4c5c608a9f53d2f 今回はここまで!