Skip to main content

DSPy

DSPy from Stanford NLP is a framework for programming language models.

DSPy introduces two key concepts, the programming model and optimizers.

  • Programing model: The programming model lets you define a series of components that make a language model request. Components include input fields, output fields, task descriptions, and calls to a vector database like Weaviate.

  • Optimizers: Optimizers compile your DSPy program to tune the language model prompt and/or the weights.

DSPy and Weaviate

Weaviate is integrated with DSPy through the retriever model!

Connect your Weaviate cluster (WCD or local instance) to DSPy, use the retriever module and pass in your collection:

weaviate_client = weaviate.Client("http://localhost:8080") # or pass in your WCD cluster url

retriever_module = WeaviateRM("WeaviateBlogChunk", # collection name
weaviate_client=weaviate_client)

Our Resources

Here are a few resources from the Weaviate team on using DSPy!

The resources are broken into two categories:

  1. Hands on Learning: Build your technical understanding with end-to-end tutorials.

  2. Read and Listen: Develop your conceptual understanding of these technologies.

Hands on Learning

TopicDescriptionResource
Getting Started with RAG in DSPyLearn about DSPy and how to build a program: Installation, settings, datasets, LLM metrics, DSPy programming model, and optimization.Notebook, Video
DSPy + Weaviate for the Next Generation of LLM AppsBuild a 4-layer DSPy program for generating blog posts from queries.Notebook, Video
RAG with PersonaBuild a compound AI system with DSPy, Cohere, and Weaviate, where you'll add a persona to the language model.Notebook, Post
Adding Depth to RAG ProgramsEnhancing DSPy programs by integrating unique input-output examples and multiple LLMs.Notebook, Video
Hurricane: Writing Blog Posts with Generative Feedback LoopsIntroduction to Hurricane, a web app for demonstrating generative feedback loops with blog posts.Notebook, Blog
Structured Outputs with DSPyThe three methods for structuring outputs in DSPy programs.Notebook, Video
Building RAG with Command R+ from Cohere, DSPy, and WeaviateOverview of Command R+ with a quick RAG demo in DSPy.Notebook, Video
Advanced Optimizers in DSPyDive into optimizing DSPy programs with various techniques.Notebook
Llama 3 RAG Demo with DSPy Optimization, Ollama, and WeaviateIntegrating Llama3 with DSPy and optimizing prompts with MIPRO.Notebook, Video
BigQuery and Weaviate orchestrated with DSPyBuild an end-to-end RAG pipeline that uses BigQuery and Weaviate using DSPy.Notebook

Read and Listen

TopicDescriptionResource
DSPy and ColBERT with Omar Khattab! - Weaviate Podcast #85Omar Khattab joins the Weaviate podcast to discuss DSPy and ColBERT.Video
DSPy ExplainedLearn about the core concepts of DSPy. Walk through the introduction notebooks to compile a simple retrieve-then-read RAG program and Multi-Hop RAG Program.Video
XMC.dspy with Karel D'Oosterlinck - Weaviate Podcast #87Karel D'Oosterlinck joins the Weaviate podcast to discuss IReRa (Infer-Retrieve-Rank).Video
Intro to DSPy: Goodbye Prompting, Hello ProgrammingOverview of DSPy and how it solves the fragility problem in LLM-based applications.Blog
Fine-Tuning Cohere’s RerankerGenerate synthetic data with DSPy to fine-tune Cohere’s reranker model.Blog
Your Language Model Deserves Better PromptingOverview of the DSPy optimizers for prompt tuning.Blog

Questions and feedback

If you have any questions or feedback, let us know in the user forum.