Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval
Search
Shunsuke Kanda
May 17, 2024
Technology
1
250
Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval
https://huggingface.co/blog/embedding-quantization
Shunsuke Kanda
May 17, 2024
Tweet
Share
More Decks by Shunsuke Kanda
See All by Shunsuke Kanda
Lucene/Elasticsearch の Character Filter でユニコード正規化するとトークンのオフセットがズレるバグへの Workaround - Search Engineering Tech Talk 2024 Spring
kampersanda
0
830
トライとダブル配列の基礎
kampersanda
0
760
Binary search with modern processors
kampersanda
30
13k
AIP Open Seminar #6
kampersanda
0
150
ICDM2020
kampersanda
0
140
SIGSPATIAL20
kampersanda
0
110
EliasFano
kampersanda
1
180
Fast Succinct Trie
kampersanda
1
580
StringBeginners#1
kampersanda
2
160
Other Decks in Technology
See All in Technology
AWSでRAGを作る法方
sonoda_mj
1
140
VPoEの視点から見た、ヘンリーがサーバーサイドKotlinを使う理由 / Why Server-side Kotlin 2024
cho0o0
1
420
Matterport を使ってクラスメソッド各拠点のバーチャルオフィスツアーを作成してみた
wakatsuki
0
160
What is DRE? - Road to SRE NEXT@広島
chanyou0311
3
630
エンジニアの生存戦略 〜クラウド潮流の経験から紐解く技術トレンドのメカニズムと乗りこなし方〜
shimy
9
1.9k
[2024最新版]AWS Control Towerを使ったセキュアなマルチアカウント環境の作り方
hiashisan
0
270
コンテナ・K8s研修 - 後半 Kubernetes 基礎&ハンズオン【MIXI 24新卒技術研修】
mixi_engineers
PRO
1
120
公共領域から学ぶ クラウド移行についてエンジニアが意識していること
kawakawa2222
0
140
JBUG岡山 #6 WordCamp男木島の チームビルディング
takeshifurusato
0
150
Classmethod流のPlatform Engineering / classmethod-platform-engineering-devio2024
tomoki10
0
470
目標設定は好きですか? アジャイルとともに目標と向き合い続ける方法 / Do you like target Management?
kakehashi
10
3k
成長期に歩みを止めないための創業期の開発文化形成
mayah
6
420
Featured
See All Featured
Designing for Performance
lara
604
67k
How GitHub (no longer) Works
holman
305
140k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
29
2.5k
Building Your Own Lightsaber
phodgson
101
5.9k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.9k
Creatively Recalculating Your Daily Design Routine
revolveconf
214
11k
It's Worth the Effort
3n
181
27k
The MySQL Ecosystem @ GitHub 2015
samlambert
248
12k
4 Signs Your Business is Dying
shpigford
178
21k
Six Lessons from altMBA
skipperchong
24
3.2k
No one is an island. Learnings from fostering a developers community.
thoeni
17
2.8k
Facilitating Awesome Meetings
lara
46
5.8k
Transcript
Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper
Retrieval Aamir Shakir, Tom Aarsen, and SeanLee https://huggingface.co/blog/embedding-quantization 発表者:Kampersanda
Summary 文埋め込みの各値を量子化してコンパクトに持ってみる • Binary Quantization (1 bit) • Scalar Quantization
(8 bits) Efficiency & Effectiveness にどれくらい影響がある?
背景 埋め込み(Embeddings)の保存には結構なメモリとお金が必要 ※ $3.8 per GB/mo with x2gd instances on
AWS
省メモリ化の方法 1. 次元数削減 • PCA • マトリョーシカ法 • など 2.
要素圧縮 • Quantization (Binary & Scalar) • など あとは LSH や Product Quantization などなど 今日のテーマ
Binary Quantization 方法 • 値の符号によって各要素を 0 or 1 に変換 •
距離計算はハミング距離(異なるビットの数) 以上です
Binary Quantization – Sentence Transformersでは
Binary Quantization – Vector Databasesでは
Scalar (int8) Quantization 手順 1. Calibration Dataset から各次元 について min,
max を算出 2. その範囲で値を 256 等分に (バケット化) 注意点 • Calibration Dataset は量子化バ ケットを定義するため、性能に 影響する
Scalar (int8) Quantization – Sentence Transformersでは
Scalar (int8) Quantization – Vector Databasesでは
リランキングによる検索精度改善 [Yamada et al., ACL21] 前提 • データベースには量子化されたベクトルが格納されている 手順 1.
検索ステップ ◦ クエリ埋め込みを量子化し、量子化されたドキュメントのデータベース に対してベクトル検索 ◦ K件より多めに取ってくる 2. リランキング ◦ 量子化する前のクエリ埋め込みと、量子化されたドキュメントとで内積 を再計算しリランキング
TopK検索の実験結果 • BinaryはTop400をリランキング • Scalar (int8) はリランキング無し
リランキングの実験結果 Binary Quantization • リランキング無しでは 92.53% • リランキングすると 96.45%(検索での件数を100〜1000にしても変化なし)
リランキングの実験結果 Scalar (int8) Quantization 400件 1000件 リランキング無し
速度の実験結果(次元数1024) • Binary Quantization: Faiss (Version 1.8.0) • Scalar (int8)
Quantization: USearch (Version 2.9.2)
まとめ 話さなかったこと • Binary と Scalar (int8) のハイブリットな方法 See Section
“Combining Binary and Scalar Quantization”