Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rust製ベクトル検索エンジンQdrant / qdrant-rust-vector-search
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Junichi Sato
January 24, 2022
Programming
820
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
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2k
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
490
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.7k
Building an Out-of-Order CPU
latte72
1
790
新卒PdEのリアル
ryu1013
1
500
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
250
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
170
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
370
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
350
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
1.7k
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
340
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
600
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
570
Raft: Consensus for Rubyists
vanstee
142
7.7k
How to train your dragon (web standard)
notwaldorf
97
6.8k
GraphQLとの向き合い方2022年版
quramy
50
15k
A Soul's Torment
seathinner
8
3.6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
How to Ace a Technical Interview
jacobian
281
24k
Agile that works and the tools we love
rasmusluckow
331
22k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
Product Roadmaps are Hard
iamctodd
55
13k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
530
Docker and Python
trallard
47
4.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はきれいに書かれていて色々勉強になる