DSPy Explained!
Connor Shorten Connor Shorten
48.7K subscribers
41,588 views
0

 Published On Jan 29, 2024

Hey everyone! Thank you so much for watching this explanation of DSPy! DSPy is a super exciting new framework for developing LLM programs! Pioneered by frameworks such as LangChain and LlamaIndex, we can build much more powerful systems by chaining together LLM calls! This means that the output of one call to an LLM is the input to the next, and so on. We can think of chains as programs, with each LLM call analogous to a function that takes text as input and produces text as output.

DSPy offers a new programming model, inspired by PyTorch, that gives you a massive amount of control over these LLM programs. Further, the Signature abstraction wraps prompts and structured input / outputs to clean up LLM program codebases. DSPy then pairs the syntax with a super novel compiler that jointly optimizes the instructions for each component of an LLM program, as well as sourcing examples of the task.

Here is my review of the ideas in DSPy, covering the core concepts and walking through the introduction notebooks showing how to compile a simple retrieve-then-read RAG program, as well as a more advanced Multi-Hop RAG program where you have 2 LLM components to be optimized with the DSPy compiler! I hope you find it useful!

Please send me a message @CShorten30 on X, I would love to discuss what you are working on and offer any help with DSPy and/or Weaviate!

Useful links:

Join the DSPy Discord!   / discord  

DSPy GitHub: https://github.com/stanfordnlp/dspy

DSPy Paper: https://arxiv.org/abs/2310.03714

DSPy Assertions: https://arxiv.org/abs/2312.13382

A Guide to LLM Abstractions: https://www.twosigma.com/articles/a-g...

Jason Liu: Pydantic is all you need:    • Pydantic is all you need: Jason Liu  

LlamaIndex Query Engines: https://docs.llamaindex.ai/en/stable/...

LangChain: https://js.langchain.com/docs/use_cases

Chapters
0:00 DSPy!
1:37 The DSPy Programming Model
5:07 LLM Programs
8:56 Programming, Not Prompting
13:48 PyTorch Analogy
19:16 The DSPy Compiler
27:50 Metrics
30:13 Teleprompters
30:50 Code Example
50:37 Start using DSPy!

show more

Share/Embed