File size: 2,696 Bytes
4267104
 
 
 
 
 
 
 
 
 
 
b92d96d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: DashVector Experiment Matrix
emoji: 
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 4.44.1
app_file: app.py
pinned: false
---

# dashVectorspace (xVector)

**Production-Grade Learned Hybrid Retrieval Engine**

This project implements a high-efficiency vector search engine using a **Learned Router** and **Custom Sharding** on top of **Qdrant**. It optimizes search efficiency by ~90% by routing queries to specific data clusters instead of performing a brute-force search across the entire dataset.

## Core Architecture

1.  **The Brain (Router)**: A Machine Learning model (LightGBM/Logistic/MLP) predicts which cluster contains the answer.
2.  **The Body (Vector DB)**: Qdrant with **Custom Sharding**. Data is partitioned into 32 Clusters + 1 Freshness Shard.
3.  **The Optimization**: **Matryoshka Representation Learning (MRL)**. The Router uses sliced 64-dim vectors for speed, while the DB stores full vectors for accuracy.

## Project Structure

```
dashVectorspace/
├── config.py                   # Configuration (Clusters, Models, Paths)
├── main.py                     # Benchmark Runner (P&C Matrix)
├── requirements.txt            # Dependencies
├── src/
│   ├── data_pipeline.py        # Data loading & MRL slicing
│   ├── router.py               # LearnedRouter (Train/Predict)
│   ├── vector_db.py            # UnifiedQdrant (Custom Sharding)
│   └── active_learning.py      # Hard Negative Logging
└── notebooks/
    └── xVector_Analysis.ipynb  # Analysis Notebook
```

## Setup & Usage

1.  **Install Dependencies**:
    ```bash
    pip install -r requirements.txt
    ```

2.  **Run Benchmarks**:
    Execute the main script to run the Permutation & Combination matrix of experiments:
    ```bash
    python main.py
    ```
    This will:
    - Generate/Load Data (MS MARCO or Synthetic).
    - Train different Router models (LightGBM, Logistic, MLP).
    - Index data into Qdrant with Custom Sharding.
    - Run test queries and report Accuracy, Latency, and Compute Savings.

3.  **Analyze Results**:
    Open `notebooks/xVector_Analysis.ipynb` to visualize the active learning logs and performance metrics.

## Key Features

-   **Custom Sharding**: Explicit control over where data lives (Clusters 0-31) and a dedicated **Freshness Shard (999)** for new data.
-   **Drift Defense**:
    -   **Layer 1**: Always searches the Freshness Shard.
    -   **Layer 2**: Falls back to **Global Search** if Router confidence is low (< 0.5).
-   **Active Learning**: Logs "Hard Negatives" (low confidence or zero results) to `logs/active_learning_queue.jsonl` for future model retraining.