RAG Visualization
In this tutorial we will explain how LangWatch can help observing optimization of RAG application with DSPy.
DSPy RAG Module
As an example of RAG application we will use the sample app that is provided in the official documentation of DSPy library, you can read more by following this link - RAG tutorial.
Firstly, lets access the dataset of wiki abstracts that will be used for example RAG optimization.
Next step - to define the RAG module itself. You can explain the task and what the expected outputs mean in this context that an LLM can optimize these commands later.
Finally, you can connect to LangWatch. After running this code snippet - you will get a link that will give you access to
an api_key
in the browser. Paste the API key into your code editor popup and press enter - now you are connected to LangWatch.
Last step is to actually run the prompt optitmizer. In this example BootstrapFewShot
is used and it will
bootstrap our prompt with the best demos from our dataset.
The result of optimization can be found on your LangWatch dashboard. On the graph you can see how many demos were boostrapped during the first optimization step.
Additionally, you can see each LLM call that has been done during the optimization with the corresponding costs and token counts.
Open in Notebook
You can access and run the code yourself in Jupyter Notebook