Qdrant & Weaviate Vector Stores
Relevant source files
The following files were used as context for generating this wiki page:
The vector store module provides a pluggable abstraction layer for managing high-dimensional embeddings within the Agentic Medical Diagnosis system. It supports both Qdrant and Weaviate as backends, enabling semantic search and hybrid (dense + sparse) retrieval across four distinct collections: entities, relations, chunks, and community reports.
Sources: README.md:12, README.md:233-239, am_diag/db/vector/settings.py
Architecture Overview
The system utilizes an abstract base class, VectorStoreBase, to enforce a consistent API across different vector database implementations. This design allows the higher-level retrieval pipelines to remain storage-agnostic. The concrete implementations, QdrantVectorStore and WeaviateVectorStore, handle the low-level communication with their respective database engines using asynchronous clients.
The diagram below illustrates the inheritance structure and the relationship between the base class and concrete implementations.
Qdrant Implementation
The QdrantVectorStore leverages the AsyncQdrantClient for efficient, non-blocking operations. It maps system-level distance metrics (Cosine, Euclid, Dot) to native Qdrant constants and supports advanced features like vector quantization.
Quantization and Filtering
Qdrant supports native quantization modes which can be configured during collection creation. The implementation translates QdrantSettings into ScalarQuantization (INT8) or BinaryQuantization configs. Filters are compiled into Qdrant Filter objects using MatchValue for scalars and MatchAny for lists.
Sources: am_diag/db/vector/qdrant.py:47-113, am_diag/db/vector/settings.py:16-37
Data Flow for Search
The following sequence diagram shows the internal flow of a search request within the Qdrant backend.
Weaviate Implementation
The WeaviateVectorStore implementation standardizes collection names using PascalCase (e.g., text_chunks becomes TextChunks) and utilizes deterministic UUID generation for consistency across ingestion rounds.
Key Features
- gRPC Support: Uses a gRPC port (default 50051) for batch operations, which is significantly faster than REST.
- Hybrid Search: Unlike the Qdrant implementation's current fallback, Weaviate supports a native
hybridquery that combines dense vectors and BM25 scores. - Data Modeling: Objects are stored with an
original_idproperty (preserving the system's UUID) and a JSON-encodedpayloadstring to accommodate Weaviate's schema requirements.
Sources: am_diag/db/vector/weaviate.py:21-42, am_diag/db/vector/weaviate.py:236-267, am_diag/db/vector/settings.py:65-72
Configuration Settings
Both backends are configured via Pydantic settings that pull from environment variables.
| Option | Type | Default | Description |
|---|---|---|---|
QDRANT_URL | string | http://localhost:6333 | Endpoint for Qdrant service. |
QDRANT_QUANTIZATION | enum | none | Modes: none, scalar_int8, binary. |
WEAVIATE_URL | string | http://localhost:8080 | Endpoint for Weaviate service. |
WEAVIATE_GRPC_PORT | int | 50051 | Port for high-speed gRPC batching. |
WEAVIATE_BATCH_SIZE | int | 200 | Max objects per insert_many call. |
Sources: am_diag/db/vector/settings.py:21-72
Core Data Models
The vector store interacts with standardized data models to ensure compatibility between different storage backends and the retrieval engine.
VectorRecord
Used for ingestion and storage. Represents a single point in the vector space.
id: UUIDvector: List[float]payload: Dict[str, Any] (Metadata like source, type, or entity name)
VectorHit
Returned by search operations.
id: UUIDscore: float (Distance-based similarity)payload: Dict[str, Any]
Sources: am_diag/db/vector/base.py:12-14, am_diag/db/vector/qdrant.py:177-183, am_diag/db/vector/weaviate.py:302-315
Conclusion
The vector store module provides a robust foundation for the system's retrieval capabilities. By abstracting the complexities of Qdrant and Weaviate behind a unified VectorStoreBase interface, the project facilitates easy switching between backends while maintaining high performance through features like gRPC batching and native quantization. This architecture ensures that the medical diagnosis agent can effectively navigate entities, relations, and clinical knowledge regardless of the underlying storage technology.
Sources: README.md:22-26, am_diag/db/vector/base.py