|
| 1 | +# Understanding the Dual Pipeline |
| 2 | + |
| 3 | +Vectorless uses a **dual pipeline architecture** that separates document processing from retrieval. This design enables efficient indexing and intelligent retrieval. |
| 4 | + |
| 5 | +## Architecture Overview |
| 6 | + |
| 7 | +``` |
| 8 | +┌─────────────────────────────────────────────────────────────────────────────┐ |
| 9 | +│ Vectorless Architecture │ |
| 10 | +├─────────────────────────────────────────────────────────────────────────────┤ |
| 11 | +│ │ |
| 12 | +│ ┌─────────────────────────────┐ ┌─────────────────────────────┐ │ |
| 13 | +│ │ INDEX PIPELINE │ │ RETRIEVAL PIPELINE │ │ |
| 14 | +│ │ │ │ │ │ |
| 15 | +│ │ Parse → Build → Enrich │ │ Analyze → Plan → Search │ │ |
| 16 | +│ │ ↓ ↓ ↓ │ │ ↓ ↓ ↓ │ │ |
| 17 | +│ │ Enhance → Optimize → │ │ Evaluate (Sufficiency) │ │ |
| 18 | +│ │ Persist │ │ ↑_____________│ │ │ |
| 19 | +│ │ │ │ │ (NeedMoreData)│ │ │ |
| 20 | +│ └─────────────────────────────┘ └─────────────────────────────┘ │ |
| 21 | +│ │ ▲ │ |
| 22 | +│ └──────────── Workspace ─────────────┘ │ |
| 23 | +│ │ |
| 24 | +└─────────────────────────────────────────────────────────────────────────────┘ |
| 25 | +``` |
| 26 | + |
| 27 | +## Index Pipeline |
| 28 | + |
| 29 | +The Index Pipeline processes documents and builds a searchable tree structure. |
| 30 | + |
| 31 | +### Stages |
| 32 | + |
| 33 | +| Stage | Purpose | |
| 34 | +|-------|---------| |
| 35 | +| **Parse** | Extract content from file (MD, PDF, DOCX, HTML) | |
| 36 | +| **Build** | Construct hierarchical document tree | |
| 37 | +| **Enrich** | Add metadata, TOC, references | |
| 38 | +| **Enhance** | Generate summaries (optional) | |
| 39 | +| **Optimize** | Prune, compress, optimize tree | |
| 40 | +| **Persist** | Save to workspace storage | |
| 41 | + |
| 42 | +### Example |
| 43 | + |
| 44 | +```rust |
| 45 | +// Index pipeline is triggered automatically |
| 46 | +let doc_id = engine.index(IndexContext::from_path("./manual.md")).await?; |
| 47 | + |
| 48 | +// With summary generation |
| 49 | +let doc_id = engine.index( |
| 50 | + IndexContext::from_path("./manual.md") |
| 51 | + .with_options(IndexOptions::new().with_summaries()) |
| 52 | +).await?; |
| 53 | +``` |
| 54 | + |
| 55 | +## Retrieval Pipeline |
| 56 | + |
| 57 | +The Retrieval Pipeline processes queries and retrieves relevant content. |
| 58 | + |
| 59 | +### Stages |
| 60 | + |
| 61 | +| Stage | Purpose | |
| 62 | +|-------|---------| |
| 63 | +| **Analyze** | Analyze query complexity, extract keywords | |
| 64 | +| **Plan** | Select retrieval strategy and algorithm | |
| 65 | +| **Search** | Navigate tree to find candidates | |
| 66 | +| **Evaluate** | Check sufficiency, aggregate content | |
| 67 | + |
| 68 | +### The Evaluate Stage |
| 69 | + |
| 70 | +The Evaluate stage is crucial - it determines if retrieved content is sufficient: |
| 71 | + |
| 72 | +```text |
| 73 | + ┌─────────────┐ |
| 74 | + │ Search │ |
| 75 | + └──────┬──────┘ |
| 76 | + │ |
| 77 | + ▼ |
| 78 | + ┌─────────────┐ |
| 79 | + │ Evaluate │ |
| 80 | + └──────┬──────┘ |
| 81 | + │ |
| 82 | + ┌────────────┼────────────┐ |
| 83 | + │ │ │ |
| 84 | + ▼ ▼ ▼ |
| 85 | + Sufficient PartialSufficient Insufficient |
| 86 | + │ │ │ |
| 87 | + ▼ ▼ ▼ |
| 88 | + Return More Search Expand Beam |
| 89 | + (1 iteration) (2 iterations) |
| 90 | +``` |
| 91 | + |
| 92 | +### Retrieval Strategies |
| 93 | + |
| 94 | +```rust |
| 95 | +// Three built-in strategies: |
| 96 | + |
| 97 | +// 1. Keyword - Fast, exact matching |
| 98 | +// 2. LLM - Semantic understanding via Pilot |
| 99 | +// 3. Structure - Hierarchy-aware navigation |
| 100 | +``` |
| 101 | + |
| 102 | +## The Pilot System |
| 103 | + |
| 104 | +Pilot is the "brain" of the Retrieval Pipeline: |
| 105 | + |
| 106 | +- **Query Analysis**: Understands what the user is asking |
| 107 | +- **Context Building**: Creates navigation context from TOC |
| 108 | +- **Decision Making**: Decides which branches to explore |
| 109 | +- **Fallback**: Algorithm takes over when LLM fails |
| 110 | + |
| 111 | +See [The Pilot System](./pilot-system.md) for details. |
| 112 | + |
| 113 | +## Data Flow |
| 114 | + |
| 115 | +``` |
| 116 | +Document ──► Index Pipeline ──► Workspace |
| 117 | + │ |
| 118 | +Query ──► Retrieval Pipeline ──────────┘ |
| 119 | + │ |
| 120 | + ▼ |
| 121 | + RetrievalResult |
| 122 | + ├── content |
| 123 | + ├── node_ids |
| 124 | + ├── confidence |
| 125 | + └── trace |
| 126 | +``` |
| 127 | + |
| 128 | +## Session-Based Operations |
| 129 | + |
| 130 | +For multi-document operations, use sessions: |
| 131 | + |
| 132 | +```rust |
| 133 | +// Create a session |
| 134 | +let session = engine.session().await; |
| 135 | + |
| 136 | +// Index multiple documents |
| 137 | +session.index(IndexContext::from_path("./doc1.md")).await?; |
| 138 | +session.index(IndexContext::from_path("./doc2.md")).await?; |
| 139 | + |
| 140 | +// Query across all documents |
| 141 | +let results = session.query_all("What is the architecture?").await?; |
| 142 | + |
| 143 | +for result in results { |
| 144 | + println!("From {}: {}", result.doc_id, result.content); |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +## See Also |
| 149 | + |
| 150 | +- [Multi-Strategy Retrieval](./multi-strategy.md) |
| 151 | +- [Content Aggregation](./content-aggregation.md) |
| 152 | +- [Sufficiency Checking](./sufficiency.md) |
0 commit comments