Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Transformerによるテキストベクトル化を解説
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
payanotty
January 18, 2024
Technology
4.3k
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Transformerによるテキストベクトル化を解説
payanotty
January 18, 2024
More Decks by payanotty
See All by payanotty
トークナイザー入門
payanotty
5
2.8k
LLM_Prompt_Recovery
payanotty
3
1.1k
Embeddingモデルを使ったベクトル化のしくみ、fine-tuning手法を解説
payanotty
15
6.6k
Kaggle_LLMコンペの攻略法を解説.pdf
payanotty
1
1.7k
ManimMLでイケてるアニメーションを作ろう
payanotty
0
870
Lets Finetune LLM
payanotty
3
1.5k
Stable Diffusion Web UI, Let Your Fave Eat Ramen
payanotty
1
1.2k
Lets Finetune Stable Diffusion
payanotty
0
1.4k
Deffusion解説
payanotty
3
1k
Other Decks in Technology
See All in Technology
リアーキテクチャ後の障害ゼロを目指したShadow Testingの取り組み
nihonbuson
PRO
1
110
安心して変更できるWebフロントエンドの作り方
pirosikick
5
2.7k
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
0
290
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
350
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
740
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
5
630
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
1
2.3k
登壇の自信を奪う3匹のオバケ / 3 Ghosts That Rob You of Your Confidence in Public Speaking
pauli
9
980
beyond jj: config & tools ecosystem
indirect
0
510
新機種発売前に見直そう!端末移行で再ログインが要るアプリ・要らないアプリは何が違うのか 〜シームレスに再開できる設計と実装〜
zozotech
PRO
0
200
HHKBエバンジェリストになる方法
941
0
110
アプリをもっと"iOSアプリっぽく"する小さな工夫 / Small Touches That Make Your App Feel More Like an iOS App
matsuji
2
930
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
470
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
670
A Modern Web Designer's Workflow
chriscoyier
699
190k
Making Projects Easy
brettharned
120
6.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.8k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
RailsConf 2023
tenderlove
30
1.5k
Leo the Paperboy
mayatellez
10
2.3k
The agentic SEO stack - context over prompts
schlessera
0
940
Transcript
Transformerを使った テキストベクトル化の基本 早野康太
自己紹介 • 名前 ◦ 早野 康太 • お仕事 ◦ 自然言語モデルの改善
• 今期アニメ ◦ ダンジョン飯 ◦ 姫様“拷問”の時間です ◦ 魔法少女にあこがれて
• Attention Is All You Need (Łukasz Kaiser et al.,
2017) ◦ 文章の単語同士の関連度を測る (Attention) 機構を組み込むことで 自然言語処理モデルの性能が大きく向上 ◦ GPTなどの文章生成モデル ▪ → TransformerモデルのDecoder部分を利用 ◦ テキストベクトル化用のモデル ▪ → TransformerモデルのEncoder部分を利用 Transformerモデル
• A Survey of Transformers (TIANYANG LIN et. al.,
2021) ◦ Transformer派生についてのサーベイ ◦ 膨大な数のTransformer派生について 詳細にまとめられている ◦ もっと詳しく知りたい方は こちらを読まれるのをおすすめします Transformerから他のモデルへの派生
Transformerモデルを使ったテキストベクトル化 • Transformerモデルは文章をベクトル(数値)に落とし込むことが得意 ◦ ベクトル同士の類似度 (近さ) を測って検索に応用できる ◦ いったんベクトルに落とし込んでしまえば 画像処理や音声処理などと文章処理を組み合わせることもできる
吾輩は猫である Transformer 0.1, 0.3, 0.04, … 文章(文字列) ベクトル 画像生成 モデル 類似度 検索
Attentionによる単語のベクトル化 吾輩 は 猫 である 。 吾輩 は 猫 である
。 文章を単語単位に分かち書き(トークナイズ) 各単語に対応するベクトル
Attentionによる単語のベクトル化 吾輩 は 猫 である 。 吾輩 は 猫 である
。 0.1 0.3 -0.5 0.8 長方形はベクトルだと思ってください 文章を単語単位に分かち書き(トークナイズ)
Attentionによる単語のベクトル化 吾輩 は 猫 である 。 吾輩 は 猫 である
。 文章を単語単位に分かち書き(トークナイズ) 各単語に対応するベクトル 単語に対応する新しいベクトル ベクトル同士の内積の値(類似度) ×
余談: ベクトル同士の”類似度”の測り方 近い 遠い • 内積 ◦ 近い(同じ方向を向いている)ほど大きくなる • コサイン類似度
◦ 内積を-1 ~ 1に正規化 (要はcosθ ) 内積 = |a||b|cosθ
AttentionからTransformerへ 吾輩 は 猫 である 。 Attention Attention Transformer 吾輩
は 猫 である 。 BERTやGPTをはじめとしたTransformer系列のモデルは Attentionを繰り返して文章をベクトルの連なりに変換している
AttentionからTransformerへ 吾輩 は 猫 である 。 Attention Attention Transformer 吾輩
は 猫 である 。 BERTやGPTをはじめとしたTransformer系列のモデルは Attentionを繰り返して文章をベクトルの連なりに変換している 一番はじめのベクトルは ランダム初期化 (学習の中で最適化されていく)
文章のベクトル化 吾輩 は 猫 である 。 Attention Attention Transformer 吾輩
は 猫 である 。 [CLS] [CLS] 文頭に特別な トークンを追加 • CLS Pooling ◦ 文頭の特別なトークンのベクトルを文章ベクトルとして使う • Average Pooling ◦ 全トークンの値を平均して文章ベクトルとして使う
ベクトル化に特化させるためのfine-tuning Query: 吾輩は猫であるの作者は? Negative Passage: 『人間失格』(にんげんしっかく)は、太宰 治による中編小説。 ベクトル化&類似度計算 ポジティブ類似度
ネガティブ類似度 Positive Passage: 『吾輩は猫である』(わがはいはねこであ る)は、夏目漱石の長編小説であり、処女 小説である。 • ポジティブ類似度が高く、ネガティブ類似度が低くなるように ロス関数を設定して学習する ◦ ロス = - ポジティブ / (ポジティブ + ネガティブ)
ベクトル化のベンチマーク • MTEB: Massive Text Embedding Benchmark ◦ テキスト埋め込みモデルのための大規模ベンチマーク ◦
8つのタスクにわたり56のデータセットが含まれる
ベンチマーク上位のモデルたち • MTEB Leaderboard - a Hugging Face Space by
mteb ◦ AnglE-optimized Text Embeddings ◦ Cohere/Cohere-embed-english-v3.0 · Hugging Face ◦ BAAI/bge-large-en-v1.5 · Hugging Face ◦ intfloat/e5-large-v2 · Hugging Face
RAG (Retrieval Augmented Generation) 質問 + 選択肢 Wikipedia passages dump
Wikipedia embeddings あらかじめベクトル化 ベクトル化 embedding ベクトル類似度検索 関連する文章 (Context) LLMへのインプット Wikipedia記事から 検索してContextを取得 ベクトル検索用に調整された言語モデルを使う (質問に回答するモデルとは別物)
Stable Diffusion (画像生成モデルへの応用) raw pixel value VAE latent
noisy latent + noise input text Text Encoder embedding UNET prediction loss velocity 生成したい画像についての文章を ベクトル化して生成モデルに与える
音楽生成モデル • Suno AI ◦ 自然言語で歌詞や曲調を指定すると その通りに音楽を生成してくれる ◦
具体的なモデルは公開されていないが 内部では文章→ベクトルの変換を通して 文章情報を生成モデルに与えている......はず!
まとめ • Attention機構を利用したTransformerによって 高品質なテキストベクトル化が実現可能になった • ベクトル化のクオリティが向上することで 検索だけでなく文章→画像や文章→音楽などマルチモーダルなモデルの クオリティも格段に向上している