sie-dspy
SIE integration for DSPy.
Installation
pip install sie-dspy
Features
- SIEEmbedder: Embedding function for use with
dspy.Embedderordspy.retrievers.Embeddings - SIEReranker: Module to rerank passages by relevance to a query
- SIEExtractor: Module to extract entities from text
Quick Start
Embeddings with FAISS Retriever
import dspy
from sie_dspy import SIEEmbedder
# Create SIE embedder
embedder = SIEEmbedder(
base_url="http://localhost:8080",
model="BAAI/bge-m3",
)
# Use with DSPy's built-in FAISS retriever
corpus = [
"Machine learning enables systems to learn from data.",
"Deep learning uses neural networks with multiple layers.",
"Natural language processing analyzes human language.",
]
retriever = dspy.retrievers.Embeddings(
corpus=corpus,
embedder=embedder,
k=2,
)
# Retrieve relevant passages
results = retriever("What is deep learning?")
print(results.passages)
Reranking Retrieved Passages
from sie_dspy import SIEReranker
# Create reranker module
reranker = SIEReranker(
base_url="http://localhost:8080",
model="jinaai/jina-reranker-v2-base-multilingual",
)
# Rerank passages
query = "How do neural networks learn?"
passages = [
"The weather is sunny today.",
"Neural networks learn through backpropagation.",
"Deep learning models require large datasets.",
]
result = reranker(query=query, passages=passages, k=2)
print(result.passages) # Top 2 most relevant passages
Entity Extraction
from sie_dspy import SIEExtractor
# Create extractor module
extractor = SIEExtractor(
base_url="http://localhost:8080",
model="urchade/gliner_multi-v2.1",
labels=["person", "organization", "location"],
)
# Extract entities
text = "John Smith is the CEO of TechCorp in San Francisco."
result = extractor(text=text)
print(result.entities) # [{"text": "John Smith", "label": "person", ...}, ...]
RAG Pipeline with Reranking
import dspy
from sie_dspy import SIEEmbedder, SIEReranker
class RAGWithReranking(dspy.Module):
def __init__(self, corpus, embedder, reranker, k=5, rerank_k=3):
super().__init__()
self.retriever = dspy.retrievers.Embeddings(
corpus=corpus,
embedder=embedder,
k=k,
)
self.reranker = reranker
self.rerank_k = rerank_k
self.generate = dspy.ChainOfThought("context, question -> answer")
def forward(self, question):
# Retrieve initial candidates
retrieved = self.retriever(question)
# Rerank to get most relevant
reranked = self.reranker(
query=question,
passages=retrieved.passages,
k=self.rerank_k,
)
# Generate answer
context = "\n".join(reranked.passages)
return self.generate(context=context, question=question)
# Usage
embedder = SIEEmbedder(base_url="http://localhost:8080", model="BAAI/bge-m3")
reranker = SIEReranker(base_url="http://localhost:8080")
rag = RAGWithReranking(
corpus=["...your documents..."],
embedder=embedder,
reranker=reranker,
)
result = rag("What is machine learning?")
SIE Server
Start the SIE server before using this integration:
mise run serve -- -d cpu -p 8080
Testing
# Unit tests (no server required)
pytest
# Integration tests (requires running server)
pytest -m integration
Metadata
Release files for sie-dspy 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sie_dspy-0.11.0.tar.gz | 16.4 kB | With provenance | Details for sie_dspy-0.11.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sie_dspy-0.11.0-py3-none-any.whl | Python 3 | none | any | Details for sie_dspy-0.11.0-py3-none-any.whl |
Total release size: 24.6 kB
Release files / sie_dspy-0.11.0.tar.gz
| Download URL | sie_dspy-0.11.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1dbd72e4bbade7dd1e4158d5011221e9514783be277ea1ad269ac8bb420e58df
|
|
BLAKE2b-256 checksum How to use checksums |
bdde54f4531ca4522bb4cea9e9da58e616791649e1d6049e641e7387e7705a10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / sie_dspy-0.11.0-py3-none-any.whl
| Download URL | sie_dspy-0.11.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df21935b5eaf0579f2b36d8aa15e19f6717d41df4441398f36437b5811ff0696
|
|
BLAKE2b-256 checksum How to use checksums |
f9126076853741ae06b8038e5a0172fa54cbf7b7169860dfacf227ddacae37d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for sie-dspy 0.11.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sie_dspy-0.11.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.