Qdrant retriever for DSPy
Project description
DSPy-Qdrant
Qdrant powered custom retriever module for DSPy.
Installation
pip install dspy-ai 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
)
results = retrieve(question)
# 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.2.tar.gz
(108.0 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.2.tar.gz.
File metadata
- Download URL: dspy_qdrant-0.1.2.tar.gz
- Upload date:
- Size: 108.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
182ef33fe818385102ce40a940dbc268be51a9f73ca7f68221472bdacc903c80
|
|
| MD5 |
d3870d3e55e37ecd753c52f3f0b37f3c
|
|
| BLAKE2b-256 |
2691e763497e40c6a4ff6f3615bfb4e90c8201587b071b794401cac04bd4d1e5
|
File details
Details for the file dspy_qdrant-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dspy_qdrant-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaca3abc4709a63777ff9598da00bf381706d81d0bdc782642115d6b33e536d1
|
|
| MD5 |
feadcbf51de3d07dce2ec99b22b20f76
|
|
| BLAKE2b-256 |
5d938ded6932432c98240fcf68465312e6bfe47b4fa252ef8ad9e027e476f400
|