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
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
530
5分で問診!Composer セキュリティ健康診断
codmoninc
0
420
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
400
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
120
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
4.7k
act2-costs.pdf
sumedhbala
0
120
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
170
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.2k
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
320
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
370
act1-costs.pdf
sumedhbala
0
240
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
420
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Side Projects
sachag
455
43k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
640
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
730
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
390
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
330
[SF Ruby Conf 2025] Rails X
palkan
2
1.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
We Have a Design System, Now What?
morganepeng
55
8.2k
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はきれいに書かれていて色々勉強になる