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
payanotty
January 18, 2024
Technology
4.4k
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.9k
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
1.1k
Other Decks in Technology
See All in Technology
ファミコンでPHPを動かす / PHP on the Famicom side b
tomzoh
0
140
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
130
20260930_Gemma4_Hands-on
tsho
0
230
転んだ話が背中を預ける理由になる / A_story_about_falling_down_gives_you_a_reason_to_watch_each_other_s_backs.pdf
pauli
3
310
Codex概要
ymiya55
0
440
検証フェーズはAIの回答を判断するための学習機会
toru_kubota
2
510
AIに攻撃される前に、AIに攻撃させる
tsuchikazu
0
150
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
310
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
450
分析AIエージェントを育てる、動く環境を育てる
codatum
0
120
More Freedom on the Same Shared GPU Cluster: A Small Team’s Experience with vCluster
nttcom
0
140
スキルを作る、その前に!複数人で使われるスキルを 作るためのプロセス
junkifurukawa
2
340
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
How to Talk to Developers About Accessibility
jct
2
560
We Have a Design System, Now What?
morganepeng
55
8.4k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
480
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
3
4.3k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
400
Git: the NoSQL Database
bkeepers
PRO
433
67k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
550
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
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によって 高品質なテキストベクトル化が実現可能になった • ベクトル化のクオリティが向上することで 検索だけでなく文章→画像や文章→音楽などマルチモーダルなモデルの クオリティも格段に向上している