DSPy: Programming—not prompting—Foundation Models#
Note
Hey guys, this is my personal reading note. I am not sure there might be some mistakes in my understanding. Please feel free to correct me (hsiangjenli@gmail.com) if you find any. Thanks!
Full name of DSPy is DSPy “Declarative Self-improving Language Programs (in Python)”
Developed by Stanford NLP
DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines [3]
Demonstrate-Search-Predict: Composing Retrieval and Language Models for Knowledge-Intensive {NLP} [2]
Contributions#
separate program from parameters
new optimizer, which is LM-driven and can be used to optimize prompt and weights
How to use DSPy [1]#
Define your task
Define your pipeline
Explore a few examples (Simply run the code and see the results)
Define data
Define metric
Collect data
Set up the optimizer
Train
Reference#
Using DSPy in 8 Steps | DSPy — dspy-docs.vercel.app. https://dspy-docs.vercel.app/docs/building-blocks/solving_your_task. [Accessed 13-10-2024].
Omar Khattab, Keshav Santhanam, Xiang Lisa Li, David Hall, Percy Liang, Christopher Potts, and Matei Zaharia. Demonstrate-search-predict: composing retrieval and language models for knowledge-intensive NLP. arXiv preprint arXiv:2212.14024, 2022.
Omar Khattab, Arnav Singhvi, Paridhi Maheshwari, Zhiyuan Zhang, Keshav Santhanam, Sri Vardhamanan, Saiful Haq, Ashutosh Sharma, Thomas T. Joshi, Hanna Moazam, Heather Miller, Matei Zaharia, and Christopher Potts. Dspy: compiling declarative language model calls into self-improving pipelines. arXiv preprint arXiv:2310.03714, 2023.