Qdrant powered retriever for DSPy
Project description
DSPy-Qdrant
Qdrant powered custom retriever module for DSPy.
Installation
pip install dspy-qdrant
Usage
from dspy_qdrant import QdrantRM
The QdrantRM class enables semantic search by retrieving the top-k most relevant documents from a Qdrant collection using a sentence embedding model.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
qdrant_collection_name |
str |
Name of the Qdrant collection used for retrieval. | Required |
qdrant_client |
QdrantClient |
An initialized instance of qdrant_client.QdrantClient. |
Required |
k |
int |
Number of top documents to retrieve per query. | 3 |
document_field |
str |
Field in the Qdrant payload that contains the raw document content. | "document" |
vectorizer |
BaseSentenceVectorizer |
Embedding model for vectorizing queries. Uses FastEmbedVectorizer if not provided. |
None |
vector_name |
str |
Name of the vector field in Qdrant collection to use for search. Defaults to the first found. | None |
Use in a Module's forward() Function
import dspy
from qdrant_client import QdrantClient
from dspy_qdrant import QdrantRM
qdrant_client = QdrantClient()
class MyModule(dspy.Module):
def __init__(self, num_passages: int = 5):
super().__init__()
self.num_passages = num_passages
def forward(self, question: str):
retrieve = QdrantRM(
qdrant_collection_name="my_collection_name",
qdrant_client=qdrant_client,
k=self.num_passages
)
# Do something with results...
📚 See Also
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dspy_qdrant-0.1.4.tar.gz
(120.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dspy_qdrant-0.1.4.tar.gz.
File metadata
- Download URL: dspy_qdrant-0.1.4.tar.gz
- Upload date:
- Size: 120.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
677b12a62fe2bfe1a52e712d71d596134fbd2d93d39c7fa3ae9b5fd96067ded8
|
|
| MD5 |
94758854a979575b32d7805a5e6f84fb
|
|
| BLAKE2b-256 |
bd15404edb2da7922c811e7e2d5ad88840390222faad2e732681c98bbcd57eda
|
File details
Details for the file dspy_qdrant-0.1.4-py3-none-any.whl.
File metadata
- Download URL: dspy_qdrant-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
929d43ee041ded1263d86d003e55c8ec24f4be15e60090319246422561b02bad
|
|
| MD5 |
35de975c47346e799dd3a52cd6c41253
|
|
| BLAKE2b-256 |
c645d1fa3fda2a048ecd15661b3662c17ee0d431186a4504bbb0a8ce10ef484a
|