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
Rust製ベクトル検索エンジンQdrant / qdrant-rust-vector-search
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Junichi Sato
January 24, 2022
Programming
800
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rust製ベクトル検索エンジンQdrant / qdrant-rust-vector-search
Junichi Sato
January 24, 2022
More Decks by Junichi Sato
See All by Junichi Sato
React Nativeを使ったリアルタイム配信サービスの開発 / React-Native-Matsuri-2021-BAKOON-Development
sat0b
0
1.5k
React NativeとFirebaseを使ったアプリ開発 / App Development using React Native and Firebase
sat0b
1
1.1k
React Nativeで新規事業開発に挑戦した話 / Challenging New Business Development with React Native
sat0b
0
970
Other Decks in Programming
See All in Programming
Webフレームワークの ベンチマークについて
yusukebe
0
180
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
410
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.8k
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Creating Composable Callables in Contemporary C++
rollbear
0
170
Inside Stream API
skrb
1
780
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
120
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
200
Lessons from Spec-Driven Development
simas
PRO
0
220
ふつうのFeature Flag実践入門
irof
8
4.2k
Featured
See All Featured
Paper Plane
katiecoart
PRO
1
52k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Navigating Team Friction
lara
192
16k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Odyssey Design
rkendrick25
PRO
2
710
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Skip the Path - Find Your Career Trail
mkilby
1
150
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
210
Making Projects Easy
brettharned
120
6.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Transcript
Rust製ベクトル検索エンジン Qdrantの紹介 Junichi Sato
発表の概要 • ベクトル検索エンジンとは ◦ ベクトル検索技術 • Qdrantについて ◦ 機能の紹介 •
Qdrantコードを読んでみて ◦ Rust初心者の視点で良いと思ったところ
自己紹介 • 佐藤純一 ◦ note: https://note.com/sat0b3ee • 類似画像検索に興味あり ◦ 先週、類似画像検索の本が
技術の泉シリーズで販売されました • Rustは入門したばかり ※ Qdrantの直接の関係者ではないです
ベクトル検索エンジンとは何か • 近似最近傍探索(ANN)の技術を利用して、 大規模なベクトルデータの中から近似ベクトルを探す • 活用例 ◦ 類似画像検索 ◦ セマンティックテキスト検索
• 代表的なベクトル検索エンジン(サービス) ◦ Milvus (Go) ◦ Vald (Go) ◦ Elasticsearch KNN (Java) ◦ Qdrant (Rust) 参考) https://github.com/currentsapi/awesome-vector-search
類似画像検索での活用例 ANN インデックス 数百万 ~ 数十億スケール 画像 Deep Learning 画像のベクトル化
[0.0232, -0.832, …, ]
ベクトル検索エンジンの課題 • 一般的なベクトル検索では「絞り込み」が利用できないことが多い ◦ 全文検索エンジンではよく使う機能 (Apache SolrやElasticsearchなど) ▪ 機能要件的によくある ◦
ECサイトでの商品の類似画像検索の例: 「ストアAに絞り込んで類似画像を検索したい」 • 対処法 ◦ 検索を多めに引いて、後段でフィルタする ▪ ただし、ごっそり後段のフィルタで消えてしまう可能性がある ◦ フィルタ条件ごとにインデックスを分割する ▪ ただし、構築が大変、柔軟性がない
Qdrantについて • Rust製のベクトル検索エンジン ◦ フィルタ条件による絞り込み検索が可能 ◦ 高い信頼性と高いパフォーマンス • GitHubリポジトリ ◦
https://github.com/qdrant/qdrant • 公式のデモ ◦ https://demo.qdrant.tech/#/ ◦ セマンティック検索のデモ(クエリの意味を把握して結果を返す) 余談)現在、Rustの開発者を募集しているらしいです。(LinkedIn) https://github.com/qdrant/qdrant より
Qdrantの詳細 • APIを持つサービスとして起動 ◦ REST API or gRPC API •
フィルタ検索 ◦ HNSWを元にした条件付き検索 ▪ 文字列、数値、Geo、... ◦ should / must / must_not • 分散システム(シャーディングなど)はTodo ◦ https://qdrant.tech/documentation/distributed_deployment/
フィルタ付き検索 POST /collections/{collection_name}/points/search { “filter”: { “must”: [ { “key”:
“city”, “match”: { “keyword”: “London” } } ] }, “params”: { “hnsw_ef”: 128 }, “vector”: [0.2, 0.1, 0.9, 0.7], “top”: 3 } • HNSWアルゴリズムをベース としてフィルター可能に変更 例 • キーcityがLondon のエンティティのみを検索
Qdrantのコード (Rust) を読んでみて 良いなと思ったところ 1. 列挙型とパターンマッチ 2. 排他制御
列挙型とパターンマッチ • RustではEnumでさまざまな型のデータを持てる • 例: インデックスへのUpsertとDelete ◦ それぞれ異なる型のデータを統一的に処理 pub enum
PointOperations { /// Insert or update points UpsertPoints(PointInsertOperations), /// Delete point if exists DeletePoints { ids: Vec<PointIdType> }, } pub(crate) fn process_point_operation(...) -> CollectionResult<usize> { match point_operation { PointOperations::DeletePoints { ids, .. } => delete_points(&segments.read(), op_num, &ids), PointOperations::UpsertPoints(operation) => { let (ids, vectors, payloads) = match operation { ... コードの引用: https://github.com/qdrant/qdrant/blob/bf3d8c25753188b4ca5e69a13c7f26e3c383f05b/lib/collection/src/collection_manager/segments_updater.rs#L234-L265
排他制御 • マルチスレッドでインデックスにアクセスする場合は排他制御が必要 ◦ 読み込みは同時アクセス OK、書き込みは一度に一つだけ • Arc<RwLock<Segment>> ◦ 所有権システムにより、
データ競合を起こせない 、明示的にアンロック不要 ▪ (デッドロックは起きうるので注意は必要 ) • 該当部分抜粋 ◦ read()でリードロック ◦ write()でライトロック コードの引用: https://github.com/qdrant/qdrant/blob/0f91c9a5e29ef9065c79a20e0ace25be898beff8/lib/collection/src/collection_manager/holders/segment_holder.rs // read let read_segment = segment_arc.read(); f(point, &read_segment); // write let mut write_segment = segment_arc.write(); f(point_id, *idx, &mut write_segment)?
おわりに • Qdrantはきれいに書かれていて色々勉強になる