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
390
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
370
Lucene/Elasticsearch の Character Filter でユニコード正規化するとトークンのオフセットがズレるバグへの Workaround - Search Engineering Tech Talk 2024 Spring
kampersanda
0
1.4k
トライとダブル配列の基礎
kampersanda
0
1.2k
Binary search with modern processors
kampersanda
30
13k
AIP Open Seminar #6
kampersanda
0
230
ICDM2020
kampersanda
0
200
SIGSPATIAL20
kampersanda
0
190
EliasFano
kampersanda
1
230
Fast Succinct Trie
kampersanda
1
710
Other Decks in Technology
See All in Technology
In Praise of "Normal" Engineers (LDX3)
charity
2
870
「規約、知識、オペレーション」から考える中規模以上の開発組織のCursorルールの 考え方・育て方 / Cursor Rules for Coding Styles, Domain Knowledges and Operations
yuitosato
6
1.6k
宇宙パトロール ルル子から考える LT設計のコツ
masakiokuda
2
100
Cloud Native Scalability for Internal Developer Platforms
hhiroshell
2
460
「実体」で築く共通認識: 開発現場のコミュニケーション最適化 / Let's Get on the Same Page with Concrete Artifacts: Optimization of Communication in dev teams
kazizi55
0
140
QAはソフトウェアエンジニアリングを学んで実践するのが大事なの
ymty
1
390
活きてなかったデータを活かしてみた話 / Shirokane Kougyou vol 19
sansan_randd
1
280
マルチテナント+マルチプロダクト SaaS への AI Agent の組み込み方
kworkdev
PRO
2
330
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
5
38k
讓測試不再 BB! 從 BDD 到 CI/CD, 不靠人力也能 MVP
line_developers_tw
PRO
0
160
Securing your Lambda 101
chillzprezi
0
270
上長や社内ステークホルダーに対する解像度を上げて、より良い補完関係を築く方法 / How-to-increase-resolution-and-build-better-complementary-relationships-with-your-bosses-and-internal-stakeholders
madoxten
13
7.6k
Featured
See All Featured
Visualization
eitanlees
146
16k
Code Review Best Practice
trishagee
68
18k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
52
2.8k
Typedesign – Prime Four
hannesfritz
42
2.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Why Our Code Smells
bkeepers
PRO
337
57k
Raft: Consensus for Rubyists
vanstee
139
7k
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”