Preface
fin-qdrant-rag is a Retrieval-Augmented Generation stack for finance and trading PDFs. You upload books and reports, they get chunked and embedded into Qdrant, and a FastAPI chat layer answers questions with retrieved document context plus conversation memory.
The interesting part is not “call an LLM with a vector search.” It is how several specialized roles cooperate on every turn: expand the query, retrieve in parallel, fall back when recall is empty, rerank, then decide what is worth keeping in long-term memory.
The problem
Plain chat models do not know your PDFs. A single embedding search also fails often:
- Users ask the same idea with different wording
- Session chatter pollutes the prompt if you dump the whole history
- Important insights get lost when Redis TTL expires
- Naïve “store everything in the vector DB” creates noise and cost
This project splits short-term speed, long-term semantics, and document knowledge into separate stores, then orchestrates them like a small crew of specialists on each message.
Product preview
Chat UI on the assistant surface — upload PDFs, ask finance questions, keep session context warm.


Multi-agent orchestration
I did not bolt on a heavy agent framework. Instead I shaped the request path as cooperating specialists with clear contracts — closer to a production multi-agent layout than a single monolith function.
Amplification crew (document recall)
When a question hits the knowledge base, one role rewrites it into sub-questions, several roles search in parallel, a fallback role extracts keywords if vectors miss, and a final role reranks chunks with a score threshold before they enter the prompt.
Memory strategy crew (what to remember)
After the reply, Conversation / Insight / Risk strategies score the exchange. Only turns above an importance threshold are promoted from Redis into the Qdrant conversations collection — so long-term memory stays curated instead of becoming a dump.
Folder structure
Clear separation: src/core/ owns memory and clients, src/features/ owns HTTP and services, docker/ brings up Postgres, Redis, Qdrant, API, and the React UI.
Architecture
End-to-end path: React hits /chat and /upload; the API fans out to Redis (short-term), Qdrant (conversations + pdf_documents), Postgres (persist), and OpenAI for embed / amplify / answer.

Two Qdrant collections keep concerns clean: pdf_documents for ingested knowledge, conversations for curated long-term dialogue memory.
Hybrid memory
Every prompt can pull three layers:
| Layer | Store | Job |
|---|---|---|
| Short-term | Redis list + TTL | Recent turns — fast, session-scoped |
| Long-term | Qdrant conversations | Only high-importance exchanges |
| Knowledge | Qdrant pdf_documents | Chunked PDFs via amplification crew |
HybridMemoryManager is the facade: one call assembles short-term text, similar long-term memories, and amplified PDF chunks into a single context block for the chat model.
Under the hood
Three geeky pieces worth reading: parallel amplification, strategy-gated storage, and dual collection factories.
Query amplification with parallel retrieval
Sub-questions fan out with asyncio.gather, results are deduped, then an LLM reranker drops weak chunks below the threshold.
Strategy crew decides what becomes long-term memory
Each strategy votes with should_store + an importance score. The factory keeps the best score; only values above 0.5 promote a turn into Qdrant.
Dual Qdrant collections from one client
Factory constructors keep PDF knowledge and conversation memory on separate collections without duplicating client logic.
Features
Sub-questions, parallel search, keyword fallback, and LLM rerank on every document recall.
Redis for the live session, Qdrant for curated long-term turns and PDF knowledge.
Conversation / Insight / Risk scorers decide what survives beyond TTL.
pdf_documents and conversations stay isolated behind one Qdrant client API.
Upload → extract → chunk → embed → index, ready for chat in the same stack.
Postgres, Redis, Qdrant, FastAPI, and the React chat UI from one compose file.
Tech stack
Open source & links
Makefile targets, compose services, and the full memory design notes live in the repository.
If you care about retrieval that behaves like a small specialist crew — expand, search, fall back, rerank, then remember selectively — this is the project where hybrid memory stops being a buzzword and becomes the runtime path.

