Using DSPy to build Retrieval-Augmented Generation (RAG) Apps

Dev Khant (~Dev-Khant)




Everyone might have used ChatGPT or Gemini for various use cases like code generation, creating content or learning about different topics. So With the increasing application of Large Language Models(LLMs) in various areas, people realize that these models are not always accurate. Despite these large language models storing impressive knowledge they often produce hallucinations. So Retrieval-Augmented Generation (RAG) helps in enhancing language models by allowing them to retrieve relevant information from large knowledge bases during generation.

In this talk, we will explore DSPy a Python framework used to develop RAG. It unifies techniques for prompting and fine-tuning LMs — and approaches for reasoning, self-improvement, and augmentation with retrieval and tools. DSPy is a framework for “programming with foundation models” developed by researchers at Stanford NLP. It emphasizes programming over prompting and moves building LM-based pipelines away from manipulating prompts and closer to programming.

DSPy can teach powerful models like GPT-3.5 or GPT-4 to be much more reliable at tasks, i.e. having higher quality. DSPy optimizers will "compile" the program and data into different instructions, few-shot prompts, and/or weight updates (finetunes) for LM.

This unleashes a new paradigm in which LMs and their prompts fade into the background as optimizable pieces of a larger system that can learn from data providing a systematic approach to solving hard tasks with LMs.

Don't miss this opportunity to learn about building trainable RAGs!


Familiarity with using LLMs via APIs, some experience with Python, and a basic understanding of PyTorch would be helpful but not strictly required.

Speaker Info:

Dev Khant is an ML Engineer at Polymerize. He has experience with building end-to-end ML pipelines for model training and showing explainable AI. He has also worked on building production-ready RAG for retrieving information from different document formats. Also, he is a Kaggle 4x Expert.

Dev also actively contributes to open-source projects and libraries around ML and LLMs.

Speaker Links:

Section: Artificial Intelligence and Machine Learning
Type: Talk
Target Audience: Intermediate
Last Updated: