Aside: AI memory on 80K+ devicesHow Aside powers AI memory across 80,000+ devices · 113M documents · 24.8B tokens · 150+ countries

Read moreRead the case study
Moss
usemossStart Free
  1. Integrations
  2. /
  3. DSPy

Moss + DSPy

Sub-10ms Retrieval for Optimized LLM Programs

Get StartedTalk to an Engineer

About DSPy

DSPy replaces hand-written prompts with compiled, optimized LLM programs. The dspy-moss package provides MossRM, a retriever module that plugs into dspy.Retrieve to give DSPy programs sub-10ms semantic search. MossRM also works as a ReAct agent tool, letting DSPy agents autonomously decide when to search.

Why Use Moss with DSPy

01

Drop-in Retriever

MossRM extends dspy.Retrieve - use as a drop-in retriever in any DSPy program

02

Sub-10ms Retrieval

Sub-10ms retrieval for DSPy RAG pipelines, ChainOfThought, and MultiHop programs

03

Agent Tool Calling

moss_search function for ReAct agent tool calling: agents decide when to search

04

Hybrid Search

Hybrid search via alpha parameter blends semantic and BM25 keyword matching

05

DSPy Optimizers

Works with DSPy optimizers like BootstrapFewShot and MIPRO for compiled retrieval programs

Quick Start

Explore docs
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
import dspy
from dspy_moss import MossRM

rm = MossRM(index_name="my-index")
rm.load_index()

dspy.configure(lm=dspy.LM("openai/gpt-4o"), rm=rm)

retrieve = dspy.Retrieve(k=3)
result = retrieve("What is the refund policy?")

for passage in result.passages:
    print(f"[{passage['score']:.3f}] {passage['long_text']}")

Get Started in 3 Steps

01

Install dependencies

Run pip install dspy-moss to set up your environment.

02

Create a MossRM retriever

Initialize MossRM with your index name, call load_index(), then register it with dspy.configure(rm=...).

03

Use in DSPy programs

Call dspy.Retrieve(k=3) in your DSPy modules. MossRM handles the search. For agentic use, pass moss_search as a ReAct tool.

Frequently asked questions

Ready to ship faster AI products?

Moss gives you production-ready semantic retrieval without infrastructure complexity.

Test performanceTalk to an Engineer
Moss
AICPA SOC 2 Type 2HIPAA

Product

Founding AgentLocal Search

Use Cases

Voice AIAI CopilotsIn-App SearchOn-Device AI

Company

PricingBlogCareersBrand Kit

Resources

DocsGlossaryBenchmarks

Integrations

DSPyElevenLabsLangChainLiveKitMCP ServerNext.jsPipecatVAPIVercel AI SDKVitePress

© 2026 MOSS

Privacy PolicyTerms of ServiceTrust Center