Skip to main content

DSPy and Weaviate Integration

DSPy is a framework for programming language models created by Stanford NLP. DSPy introduces two key concepts: 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 and 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 module! You only need to connect to your Weaviate cluster through WCS or localhost, and pass in your collection:

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

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

Our Resources

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

The resources are broken into two categories:

  1. Hands on Learning: Content framed to build your technical understanding with end-to-end tutorials.

  2. Read and Listen: Content designed to help develop your conceptual understanding of these technologies.

Hands on Learning

TopicDetails
Getting Started with RAG in DSPyLearn about the four components needed to build a DSPy program: Installation, settings, datasets with dspy.Example, LLM metrics, DSPy programming model, and optimization. Notebook and Video
DSPy + Weaviate for the Next Generation of LLM AppsBuild a 4-layer DSPy program for generating blog posts from queries. Notebook and Video
RAG with PersonaBuild a compound AI system with DSPy, Cohere, and Weaviate, where you'll add a persona to the language model. Notebook and Post
Adding Depth to RAG ProgramsEnhancing DSPy programs by integrating unique input-output examples and multiple LLMs. Notebook and Video
Hurricane: Writing Blog Posts with Generative Feedback LoopsIntroduction to Hurricane, a web app for demonstrating generative feedback loops with blog posts. Notebook and Blog
Structured Outputs with DSPyThe three methods for structuring outputs in DSPy programs. Notebook and Video
Building RAG with Command R+ from Cohere, DSPy, and WeaviateOverview of Command R+ with a quick RAG demo in DSPy. Notebook and 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 and Video
BigQuery and Weaviate orchestrated with DSPyBuild an end-to-end RAG pipeline that uses BigQuery and Weaviate using DSPy. Notebook

Read and Listen

TopicDetails
DSPy and ColBERT with Omar Khattab! - Weaviate Podcast #85Omar Khattab joins the Weaviate podcast to discuss DSPy and ColBERT. Video
DSPy ExplainedThe core concepts of DSPy and walks through the introduction notebooks showing how 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.