File size: 3,299 Bytes
3a46063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6e6966
 
3a46063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6e6966
3a46063
 
d6e6966
3a46063
d6e6966
3a46063
d6e6966
3a46063
d6e6966
3a46063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6e6966
 
 
 
 
 
3a46063
 
d6e6966
 
3a46063
 
d6e6966
 
3a46063
 
d6e6966
 
3a46063
 
d6e6966
 
 
 
 
 
3a46063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8e86740
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
---
license: apache-2.0
language:
- en
tags:
- rag
- retrieval
- semantic-search
- faiss
- bm25
- reranker
- cross-encoder
- sentence-transformers
- flan-t5
- hybrid-search
- dense-retrieval
- ai
- llm
- search
- question-answering
pipeline_tag: sentence-similarity
library_name: sentence-transformers
---
# ApexRetriever-Pro

A powerful 5-stage hybrid retrieval system combining sparse retrieval, dense semantic search, diversity optimization, reranking, and generative refinement.

Built for:
- RAG pipelines
- AI agents
- semantic search
- document QA
- memory systems
- knowledge retrieval
- research assistants

---

# Architecture

ApexRetriever-Pro uses a multi-stage retrieval pipeline:

## Stage β‘  β€” BM25 Sparse Retrieval
Fast keyword-based retrieval using BM25.

## Stage β‘‘ β€” Dense Semantic Retrieval
Semantic vector search powered by:

- `BAAI/bge-small-en-v1.5`

Uses FAISS for high-speed similarity search.

## Stage β‘’ β€” MMR Diversity Filtering
Maximal Marginal Relevance (MMR) improves result diversity and reduces duplicate-style retrieval.

## Stage β‘£ β€” CrossEncoder Reranking
High-quality neural reranking using:

- `cross-encoder/ms-marco-MiniLM-L-6-v2`

Improves relevance precision significantly.

## Stage β‘€ β€” FLAN-T5 Refinement
Final answer refinement using:

- `google/flan-t5-base`

Generates concise refined outputs from retrieved context.

---

# Features

- Hybrid sparse+dense retrieval
- FAISS accelerated search
- MMR diversity optimization
- Neural reranking
- Generative refinement
- GPU acceleration
- Plug-and-play pipeline
- Lightweight deployment
- Kaggle compatible
- HuggingFace compatible

---

# Repository Structure

```text
ApexRetriever-Pro/
β”‚
β”œβ”€β”€ bi_encoder/
β”œβ”€β”€ reranker/
β”œβ”€β”€ flan_t5/
β”œβ”€β”€ pipeline.py
└── README.md
````

---

# Installation

```bash
pip install -U \
    sentence-transformers \
    transformers \
    faiss-cpu \
    rank-bm25 \
    torch
```

---

# Quick Start

```python
from pipeline import ApexRetrieverPro

retriever = ApexRetrieverPro(model_dir=".")

# Example documents

docs = [
    "Python was created by Guido van Rossum.",
    "Paris is the capital of France.",
    "Transformers power modern LLMs."
]

# Build index

retriever.index_documents(docs)

# Retrieve

results = retriever.retrieve(
    "Who created Python?",
    top_k=3
)

print(results)
```

---

# Example Output

```python
[
    'Python was created by Guido van Rossum.'
]
```

---

# Use Cases

* Retrieval-Augmented Generation (RAG)
* AI chatbots
* Local document search
* Agent memory systems
* Knowledge bases
* Research copilots
* Semantic indexing
* QA systems
* Enterprise search

---

# Performance Notes

Recommended:

* CUDA GPU
* 16GB+ RAM
* Python 3.10+

Works on:

* Kaggle
* Colab
* Local GPU systems
* Linux
* Windows

---

# Model Components

| Component     | Model                                |
| ------------- | ------------------------------------ |
| Dense Encoder | BAAI/bge-small-en-v1.5               |
| Reranker      | cross-encoder/ms-marco-MiniLM-L-6-v2 |
| Refiner       | google/flan-t5-base                  |
| Vector Engine | FAISS                                |
| Sparse Search | BM25                                 |

---

# License

Apache 2.0

---
>QuantaSparkLabs