dspy-retrieval
Installation
SKILL.md
Retrieval Modules in DSPy
Guide the user through DSPy's retrieval modules for searching documents, computing embeddings, and building RAG (retrieval-augmented generation) pipelines.
What retrieval modules are
DSPy provides retrieval modules that fetch relevant documents or passages given a query. These modules plug into DSPy programs just like dspy.Predict or dspy.ChainOfThought -- declare them in __init__, call them in forward(), and optimizers handle the rest.
There are four key components:
| Component | Purpose | When to use |
|---|---|---|
dspy.Retrieve |
Base retriever class | Wrap any search backend (Elastic, Pinecone, etc.) |
dspy.ColBERTv2 |
ColBERTv2 retrieval client | Query a hosted ColBERTv2 server |
dspy.Embedder |
Compute embeddings | Turn text into vectors using any LiteLLM-supported model |
dspy.retrievers.Embeddings |
Local vector search | Build a retriever from an embedder + corpus, uses FAISS |