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 Si...
Search
Shunsuke Kanda
May 17, 2024
Technology
2
410
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
Leveraging LLMs for Unsupervised Dense Retriever Ranking (SIGIR 2024)
kampersanda
2
390
Lucene/Elasticsearch の Character Filter でユニコード正規化するとトークンのオフセットがズレるバグへの Workaround - Search Engineering Tech Talk 2024 Spring
kampersanda
0
1.4k
トライとダブル配列の基礎
kampersanda
1
1.3k
Binary search with modern processors
kampersanda
33
14k
AIP Open Seminar #6
kampersanda
0
240
ICDM2020
kampersanda
0
210
SIGSPATIAL20
kampersanda
0
200
EliasFano
kampersanda
1
240
Fast Succinct Trie
kampersanda
1
720
Other Decks in Technology
See All in Technology
AIエージェント就活入門 - MCPが履歴書になる未来
eltociear
0
620
広島銀行におけるAWS活用の取り組みについて
masakimori
0
150
実践アプリケーション設計 ②トランザクションスクリプトへの対応
recruitengineers
PRO
4
790
MySQL HeatWave:サービス概要のご紹介
oracle4engineer
PRO
4
1.7k
人と組織に偏重したEMへのアンチテーゼ──なぜ、EMに設計力が必要なのか/An antithesis to the overemphasis of people and organizations in EM
dskst
6
660
Gaze-LLE: Gaze Target Estimation via Large-Scale Learned Encoders
kzykmyzw
0
360
夢の印税生活 / Life on Royalties
tmtms
0
290
7月のガバクラ利用料が高かったので調べてみた
techniczna
3
670
進捗
ydah
1
160
コスト削減の基本の「キ」~ コスト消費3大リソースへの対策 ~
smt7174
2
230
知られざるprops命名の慣習 アクション編
uhyo
11
2.7k
ソフトウェア エンジニアとしての 姿勢と心構え
recruitengineers
PRO
10
3.8k
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
40
2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Mobile First: as difficult as doing things right
swwweet
223
9.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
Raft: Consensus for Rubyists
vanstee
140
7.1k
How to train your dragon (web standard)
notwaldorf
96
6.2k
How to Ace a Technical Interview
jacobian
279
23k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
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”